namespace skypesim; import DSM.metamodel.SkypeSim.SkypeSimEditor; @incremental machine Final_Rules_Random { pattern test_we(ND)= { ND(ND); ND(ND1); ND.we(WEI,ND,ND1); } pattern test_we_two(ND)= { ND(ND); ND(ND1); ND(ND2); ND.we(WEI,ND,ND1); ND.we(WI,ND,ND2); } pattern test_ns(ND)= { ND(ND); ND(ND1); ND.ns(WEI,ND,ND1); } gtrule Rule1_Create() = { precondition pattern lhs(ND,Network) = { ND(ND); Network(Network); neg find test_we_two(ND); neg find test_ns(ND); } action { let ND1=undef, NI=undef in seq { new(ND(ND1) in Network);// The first ND shows the Type of the Node and the second is the name of the varible. new(ND.ns(NI,ND,ND1));// the NI is varible it is going to rfer to relations } println(" Rule 1 applied"); // } } pattern check_ns(ND,ND1)= { ND(ND); ND(ND1); ND.ns(WEI,ND,ND1); } pattern check_ns_ns(ND,ND1)= { ND(ND); ND(ND1); ND(ND2); ND.ns(WA,ND,ND1); ND.ns(WI,ND,ND2); } gtrule Rule2_Create() = { precondition pattern lhs(ND,ND1,Network) = { ND(ND); ND(ND1); Network(Network); find check_ns(ND,ND1); neg find test_we(ND); neg find test_we(ND1); neg find check_ns_ns(ND,ND1); } action { let ND2=undef, NI=undef in seq { new(ND(ND2) in Network); new(ND.we(NI,ND,ND2)); } println("ND2 created "); // } } pattern check3_we(ND,ND2)= { ND(ND); ND(ND2); ND.we(W3I,ND,ND2); } pattern check3_ns(ND,ND1)= { ND(ND); ND(ND1); ND.ns(W3I,ND,ND1); } pattern check3_ns_ns(ND,ND1)= { ND(ND); ND(ND1); ND(ND3); ND.ns(W3A,ND,ND1); ND.ns(W3I,ND,ND3); } gtrule Rule3_Create() = { precondition pattern lhs(ND,ND1,ND2,Network) = { ND(ND); ND(ND1); ND(ND2); Network(Network); find check3_ns(ND,ND1); find check3_we( ND,ND2); neg find test_we(ND2); neg find test_we(ND1); neg find test_ns(ND2); neg find check3_ns_ns(ND,ND1); } action { let ND3=undef, NI=undef in seq { new(ND(ND3) in Network); new(ND.ns(NI,ND2,ND3)); new(ND.we(NI,ND1,ND3)); } println("ND3 created"); } } pattern check4_we(ND1,ND3)= { ND(ND1); ND(ND3); ND.we(W4I,ND1,ND3); } gtrule Rule4_Create() = { precondition pattern lhs(ND1,ND3,Network) = { ND(ND1); ND(ND3); Network(Network); find check4_we( ND1,ND3); neg find test_ns(ND1); neg find test_ns(ND3); } action { let ND4=undef, NI=undef in seq { new(ND(ND4) in Network); new(ND.ns(NI,ND1,ND4)); } println("ND4 created"); } } pattern check5_we(ND,ND2)= { ND(ND); ND(ND2); ND.we(W5I,ND,ND2); } pattern check5_ns(ND,ND1)= { ND(ND); ND(ND1); ND.ns(N5I,ND,ND1); } pattern check51_ns(ND1,ND4)= { ND(ND1); ND(ND4); ND.ns(NSI,ND1,ND4); } pattern check5test_ns_we(ND1,ND2)= { ND(ND); ND(ND1); ND(ND2); ND.we(W5A,ND,ND2); ND.ns(W5I,ND,ND1); } gtrule Rule5_Create() = { precondition pattern lhs(ND,ND1,ND2,ND4,Network) = { ND(ND); ND(ND1); ND(ND2); ND(ND4); Network(Network); find check5_we(ND,ND2); find check5_ns(ND,ND1); find check51_ns(ND1,ND4); neg find test_we(ND2); //neg find check5test_ns_we(ND1,ND2); neg find test_we(ND4); } action { let ND5=undef, NI=undef in seq { new(ND(ND5) in Network); new(ND.we(NI,ND1,ND5)); new(ND.ns(NI,ND2,ND5)); } println("ND5 created "); } } // gtrule Ruledelete() = // { // precondition pattern lhs(ND) = // { // ND(ND); // } //action { // delete (ND); //println("ND3 created, registered and Attribute Memory is set="); //} //} gtrule Count() = { precondition pattern lhs(X) = { ND(X); } action {println("found node: "+fqn(X));} } rule main() = seq { // Create clients //forall with apply Rule1_Create() do skip; //forall with apply Rule2_Create() do skip; forall with apply Rule3_Create() do skip; //forall with apply Rule4_Create() do skip; //forall with apply Rule5_Create() do skip; //forall with apply Ruledelete() do skip; } }