Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active October 13, 2017 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/d05acfc56798ee0a33470d2cac85b27f to your computer and use it in GitHub Desktop.
Save kenwebb/d05acfc56798ee0a33470d2cac85b27f to your computer and use it in GitHub Desktop.
A more flexible Xholon
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Fri Oct 13 2017 10:31:03 GMT-0400 (EDT)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: A more flexible Xholon
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: d05acfc56798ee0a33470d2cac85b27f
Keywords:
My Notes
--------
October 10, 2017
see my notebook Oct 8
Xholon re-imagined, using ideas from Category Theory (CT), Set Theory, Bigraphs, etc.
I'm trying to simulate some new insights into how a Xholon app might be implemented, by simulating the ideas using Xholon.
I almost certainly won't be able to do this particularly well.
My approach:
- I will create sets of nodes, using Xholon XML.
- I will then use JavaScript to connect elements of sets.
- The sets are CT objects, and the connections between sets are CT morphisms/arrows.
This is a meta-model for Xholon apps.
Perhaps Identifiers should create corresponding Nodes.
This is probably not a good way to design a system,
but it may be a good intermediate format that can be easily exported.
Ideally, it would work between Xholon, Category Theory, SQL, Neo4j, Bigraph, etc.
Possibly all ports from a Node could be arrays.
- arrays are required for attributes and behaviors
- arrays would also allow multiple parents, etc.
Everything is a String or an array.
Possible names:
Xholon Intermediate Format
Xholon Common Format
Xholon Meta Format
]]></Notes>
<_-.XholonClass>
<CategorySystem/>
<!-- Category Theory Objects, Sets -->
<CtObject superClass="XholonSet">
<Identifiers/>
<NodeTypes/> <!-- node type names -->
<Behaviors/>
<Attributes/>
<RoleNames/>
<Nodes/>
<NodesTest01/>
<Decorations/>
<Mechanisms/>
</CtObject>
<!-- elements that belong to sets -->
<SElement>
<IdentifierSE superClass="Attribute_String"/>
<NodeTypeSE superClass="Attribute_String"/>
<BehaviorSE superClass="Attribute_String"/>
<AttributeSE superClass="Attribute_String"/>
<RoleNameSE superClass="Attribute_String"/>
<NodeSE superClass="XholonNull"/>
<!--<NodeSE/>-->
<DecorationSE/>
<MechanismSE/>
</SElement>
<NodeSE01/> <!-- implName is XhChameleon -->
</_-.XholonClass>
<xholonClassDetails>
<Avatar><Color>rgba(255,215,0,0.8)</Color></Avatar>
<NodeSE xhType="XhtypePureActiveObject">
<!--<port name="arrows.nodeType" connector="../../NodeTypes/NodeTypeSE"/>
<port name='arrows_nodeType' connector="../../NodeTypes/NodeTypeSE"/>-->
</NodeSE>
<NodeSE01 xhType="XhtypePureActiveObject"/>
<NodeTypeSE xhType="XhtypePureActiveObject"/>
</xholonClassDetails>
<CategorySystem>
<!-- identifiers as strings -->
<Identifiers roleName="I">
<IdentifierSE>1000</IdentifierSE> <!-- OR <IdentifierSE roleName="0"/> -->
<IdentifierSE>1001</IdentifierSE>
<IdentifierSE>1002</IdentifierSE>
<IdentifierSE>1003</IdentifierSE>
<IdentifierSE>1004</IdentifierSE>
<IdentifierSE>1005</IdentifierSE>
<IdentifierSE>1006</IdentifierSE>
<IdentifierSE>1007</IdentifierSE>
<IdentifierSE>1008</IdentifierSE>
<IdentifierSE>1009</IdentifierSE>
</Identifiers>
<!-- node type names -->
<NodeTypes roleName="NT">
<NodeTypeSE>Star</NodeTypeSE>
<NodeTypeSE>Planet
<port name="d" connector="../../Decorations/DecorationSE[2]"/> <!-- this doesn't work -->
</NodeTypeSE>
<NodeTypeSE>DwarfPlanet</NodeTypeSE>
</NodeTypes>
<RoleNames roleName="R">
<RoleNameSE>Sun</RoleNameSE>
<RoleNameSE>Mercury</RoleNameSE>
<RoleNameSE>Venus</RoleNameSE>
<RoleNameSE>Earth</RoleNameSE>
<RoleNameSE>Mars</RoleNameSE>
<RoleNameSE>Jupiter</RoleNameSE>
<RoleNameSE>Saturn</RoleNameSE>
<RoleNameSE>Uranus</RoleNameSE>
<RoleNameSE>Neptune</RoleNameSE>
<RoleNameSE>Pluto</RoleNameSE> <!-- I like having 9 planets -->
</RoleNames>
<!-- possibly divide this into Attribute names and Atttribute values; or possibly "State" is the name of an edge arrows.attributes.State -->
<Attributes roleName="A">
<AttributeSE>0</AttributeSE> <!-- initial state of one or more nodes -->
</Attributes>
<Behaviors roleName="B">
<BehaviorSE>var me, beh = {postConfigure: function() {me = this.cnode.parent(); me.println(me.name());}}</BehaviorSE>
<BehaviorSE>var me, beh = {postConfigure: function() {me = this.cnode.parent(); me.println(me.role());}}</BehaviorSE>
</Behaviors>
<Decorations roleName="D">
<DecorationSE><Color>red</Color></DecorationSE>
<DecorationSE><Color>green</Color></DecorationSE>
</Decorations>
<!--
These are raw nodes with no identifying or other attributes.
They don't even have an index because they are contained within a Set rather than a List.
At runtime, as a Node is being created, assign an element from Identifiers (during configure() or postConfigure() ).
-->
<Nodes roleName="N">
<NodeSE multiplicity="10"/>
</Nodes>
<!-- test of Attribute_arrayString -->
<Attribute_arrayString>abc,def,ghi</Attribute_arrayString>
<!-- test of CollectionBuilder -->
<CollectionBuilder roleName="Test" collName="Identifiers" eleName="IdentifierSE" sep=",">
One,
Two,
Three,
Four
</CollectionBuilder>
<!-- test use of explicit ports, instead of using Nodesbehavior
TODO instead of including all the port tags, I could just provide the indices for each arrow.
ex: 1,1,1,1,1 2,2,1,1,2 3,3,1,1,2
<NodeSE01 indices="1,1,1,1,1"/>
<NodeSE01 indices="2,2,1,1,2"/>
<NodeSE01 indices="3,3,1,1,2"/>
OR it could be done with JavaScript
ex: node.i = ...;
OR if everything is an array:
ex: [[3],[3],[1,4,5],[1,2,7,8],[2]]
-->
<NodesTest01>
<NodeSE01>
<port name="i" connector="../../Identifiers/IdentifierSE[1]"/>
<port name="nt" connector="../../RoleNames/RoleNameSE[1]"/>
<port name="b" connector="../../Behaviors/BehaviorSE[1]"/>
<port name="a" connector="../../Attributes/AttributeSE[1]"/>
<port name="r" connector="../../NodeTypes/NodeTypeSE[1]"/>
<port name="d" connector="../../Decorations/DecorationSE[1]"/>
</NodeSE01>
<NodeSE01>
<port name="i" connector="../../Identifiers/IdentifierSE[2]"/>
<port name="nt" connector="../../RoleNames/RoleNameSE[2]"/>
<port name="b" connector="../../Behaviors/BehaviorSE[1]"/>
<port name="a" connector="../../Attributes/AttributeSE[1]"/>
<port name="r" connector="../../NodeTypes/NodeTypeSE[2]"/>
</NodeSE01>
<NodeSE01>
<port name="i" connector="../../Identifiers/IdentifierSE[3]"/>
<port name="nt" connector="../../RoleNames/RoleNameSE[3]"/>
<!-- there could be multiple (or no) behaviors and attributes -->
<port name="b" index="0" connector="../../Behaviors/BehaviorSE[1]"/>
<port name="b" index="1" connector="../../Behaviors/BehaviorSE[2]"/>
<port name="a" index="0" connector="../../Attributes/AttributeSE[1]"/>
<port name="r" connector="../../NodeTypes/NodeTypeSE[2]"/>
<port name="p" connector="../NodeSE01[2]"/> <!-- parent -->
<port name="port" index="0" connector="../NodeSE01[1]"/>
</NodeSE01>
</NodesTest01>
</CategorySystem>
<Nodesbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var nodes, beh = {
postConfigure: function() {
nodes = this.cnode.parent();
// Give each node the id from a corresponding identifier node, and the roleName from a corresponding roleName node.
var ids = nodes.xpath("../Identifiers");
var rns = nodes.xpath("../RoleNames");
var iid = ids.first();
var node = nodes.first();
var rn = rns.first();
while (iid && node && rn) {
if (!node.arrows) {
node.arrows = {}; // Category Theory morphisms/arrows; links, ports
}
var oldId = node.id();
node._id(Number(iid.text()));
node.arrows.identifier = iid; // create a link to the Identifier node
node.role(rn.text());
node.arrows.roleName = rn;
var newId = node.id();
//nodes.println(" Converted " + oldId + " --> " + newId);
$wnd.console.log(node);
$wnd.console.log(node.arrows);
iid = iid.next();
node = node.next();
rn = rn.next();
}
$wnd.xh.root().append(this.cnode.remove());
},
act: function() {
nodes.println("Test");
}
}
]]></Nodesbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Identifiers</title>
<rect id="CategorySystem/Identifiers" fill="#98FB98" height="50" width="50" x="25" y="0"/>
<g>
<title>NodeSE</title>
<rect id="CategorySystem/Nodes/NodeSE" fill="#6AB06A" height="50" width="10" x="80" y="0"/>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment