public void Test08() { var code = @" new Stage ID = 'MyStage' Name = 'MySweetStage' Procs add p1 = new Process ID = 'PROCP1' Name = 'MyPROCP1' add p2 = new Process add p3 = new Process "; var jac = new JacInterpreter(); jac.Exec(code); //-------------------------------------------------------- code = $@" MyStage // To find Stage object named 'MyStage' Procs remove PROCP1 // find JitProcess instance by ID (not by ID as string) remove p2 // find JitProcess instance by variable "; jac.Exec(code); var MyStage = jac.GetStage("MyStage"); var MySweetStage = jac.GetStage("MySweetStage"); Assert.IsNotNull(MyStage); Assert.IsNotNull(MySweetStage); Assert.AreEqual(MyStage, MySweetStage); Assert.AreEqual(MyStage.GetChildProcesses().Count(), 1); }
public void Test06_1() { var code = @" st = new Stage Procs add new Process add new Process ID = 'IgnoreProcess' "; var jac = new JacInterpreter(); jac.Exec(code); Assert.IsNotNull(jac.GetProcess("IgnoreProcess")); var name = jac.GetProcess("IgnoreProcess").Name; Assert.IsNotNull(jac.GetProcess(name)); //-------------------------------------------------------- code = $@" st Procs remove IgnoreProcess // Can specify ID (Cannot specify 'IgnoreProcess' as string) "; jac.Exec(code); Assert.AreEqual(jac.GetStage("st")?.GetChildProcesses().Count(), 1); Assert.AreNotEqual(jac.GetStage("st")?.GetChildProcess(0).Name, "IgnoreProcess"); Assert.IsNull(jac.GetProcess("IgnoreProcess")); // removed from VarBuffer Assert.IsNull(jac.GetProcess(name)); // removed from InstanceBuffer }
public void Test34() { var code = @" st = new Stage Works add datetime('2020/7/31 9:00:00'):new Work Name = 'Work1' "; var jac = new JacInterpreter(); jac.Exec(code); var st = jac.GetStage("st"); var dat = st.Events.Peeks(99).ToList(); Assert.IsTrue(CMP(dat[0], "Work1", EventTypes.Out, $"9:00")); code = @" st Works remove Work1 // remove command is for GUI(undo) only. "; jac.Exec(code); dat = st.Events.Peeks(99).ToList(); Assert.AreEqual(0, dat.Count); }
public void Test33_4() { var code = @" st = new Stage Works add datetime('2020/7/31 9:00:00'):new Work Name = 'Work1' "; var jac = new JacInterpreter(); jac.Exec(code); var st = jac.GetStage("st"); var dat = st.Events.Peeks(99).ToList(); Assert.IsTrue(CMP(dat[0], "Work1", EventTypes.Out, $"9:00")); }
public void Test14_2() { var code = @" st = new Stage Procs add p1 = new Process Name = 'PROCP1' Cio add i1 = new CiPickTo Delay = 1.5M TargetWorkClass = ':Car' DestProcessKey = 'SUPERLAZY' "; var jac = new JacInterpreter(); jac.Exec(code); var st = jac.GetStage("st"); var i1 = jac["i1"] as CiPickTo; Assert.IsNotNull(i1); var i1dest = st.FindChildProcess("SUPERLAZY", isReturnNull: true); Assert.IsNull(i1dest); // Expected Null because of no registered yet. var code2 = @" st Procs add p2 = new Process Name = 'SUPERLAZY' "; jac.Exec(code2); i1dest = st.FindChildProcess("SUPERLAZY", isReturnNull: true); var p2 = jac.GetProcess("p2"); Assert.AreEqual(i1dest, p2); // Then FindProcess can find p2 named SUPERLAZY i1dest = st.FindChildProcess(p2.ID, isReturnNull: true); // You can also find by ID Assert.AreEqual(i1dest, p2); }
public void Test14() { var code = @" st = new Stage Procs add sink = new Process add p1 = new Process Name = 'PROCP1' Cio add i1 = new CiPickTo Delay = 1.5M TargetWorkClass = ':Car' DestProcessKey = sink.ID add i2 = new CiDelay Delay = 2.5H add i3 = new CiSwitchNextLink NextLinkVarName = new Variable Value = 'AA' "; var jac = new JacInterpreter(); jac.Exec(code); var st = jac.GetStage("st"); var i1 = jac["i1"] as CiPickTo; Assert.IsNotNull(i1); Assert.AreEqual(i1.Delay, TimeSpan.FromMinutes(1.5)); Assert.AreEqual(i1.TargetWorkClass, ":Car"); Assert.AreEqual(st.FindChildProcess(i1.DestProcessKey, true), jac.GetProcess("sink")); // check lazy method var i2 = jac["i2"] as CiDelay; Assert.IsNotNull(i2); Assert.AreEqual(i2.Delay, TimeSpan.FromHours(2.5)); var i3 = jac["i3"] as CiSwitchNextLink; Assert.IsNotNull(i3); Assert.AreEqual(i3.NextLinkVarName, JitVariable.From("AA")); }
public void Test20() { var code = @" st = new Stage Name = 'st' p1 = new Process Name = 'p1' p2 = new Process Name = 'p2' w1 = new Work k1 = new Kanban PullFrom = new Location Stage = st Path = '\' Process = p1 PullTo = new Location Stage = st Path = '\' Process = p2 Work = w1 "; var jac = new JacInterpreter(); jac.Exec(code); var st = jac.GetStage("st"); var k1 = jac.GetKanban("k1"); var p1 = jac.GetProcess("p1"); var p2 = jac.GetProcess("p2"); var w1 = jac.GetWork("w1"); Assert.IsNotNull(k1); Assert.IsNotNull(p1); Assert.IsNotNull(p2); Assert.IsNotNull(w1); Assert.AreEqual(k1.PullFrom.Stage, st); Assert.AreEqual(k1.PullFrom.Process.ID, p1.ID); Assert.AreEqual(k1.PullTo.Process.ID, p2.ID); Assert.AreEqual(k1.Work, w1); }
public void Test07() { var code = @" st = new Stage Procs add p1 = new Process ID = 'PROCP1' add p2 = new Process "; var jac = new JacInterpreter(); jac.Exec(code); //-------------------------------------------------------- code = $@" st Procs remove PROCP1 // Can specify ID (Cannot specify 'PROCP1' as string) remove p2 "; jac.Exec(code); Assert.AreEqual(jac.GetStage("st")?.GetChildProcesses().Count(), 0); }
public void Test09() { var code = @" new Stage Procs add p1 = new Process ID = 'PROCP1' add p2 = new Process ID = 'MyStage' "; var jac = new JacInterpreter(); jac.Exec(code); //-------------------------------------------------------- code = $@" MyStage // You can also to find with variable name 'MyStage' Procs remove PROCP1 // find JitProcess instance by ID remove p2 // find JitProcess instance by variable "; jac.Exec(code); Assert.AreEqual(jac.GetStage("MyStage")?.GetChildProcesses().Count(), 0); }
public void Test18() { var code = @" st = new Stage Procs add sink = new Process add p1 = new Process Name = 'MyProc' Cio add o1 = new CoMaxCost "; var jac = new JacInterpreter(); jac.Exec(code); var st = jac.GetStage("st"); Assert.AreEqual(jac.GetProcess("MyProc")?.Name, "MyProc"); Assert.AreEqual(jac.GetProcess("MyProc")?.Cios.Count(), 1); var code2 = @" w1 = new Work Next = l1 = new Location Stage = st SubsetCache = st Path = '\' Process = p1 = new Process w2 = new Work Current = w1.Next w3 = new Work Previous = w2.Current w4 = new Work Current = l1 "; jac.Exec(code2); var w1 = jac.GetWork("w1"); var w2 = jac.GetWork("w2"); var w3 = jac.GetWork("w3"); var w4 = jac.GetWork("w4"); var p1 = jac.GetProcess("p1"); var l1 = jac.GetLocation("l1"); Assert.IsNotNull(p1); Assert.IsNull(w1.Previous); Assert.IsNull(w1.Current); Assert.AreEqual(w1.Next.SubsetCache, st); Assert.AreEqual(w1.Next.Process, p1); Assert.AreEqual(w2.Current.SubsetCache, w1.Next.SubsetCache); Assert.AreEqual(w2.Current.SubsetCache, st); Assert.AreEqual(w2.Current.Process, p1); Assert.AreEqual(w3.Previous.SubsetCache, st); Assert.AreEqual(w3.Previous.Process, p1); Assert.AreEqual(w4.Current, l1); var code3 = @" o1 ReferenceVarName = 'Weight' Value = 500 "; jac.Exec(code3); var o1 = jac["o1"] as CoMaxCost; Assert.IsNotNull(o1); Assert.AreEqual(o1.ReferenceVarName, JitVariable.From("Weight")); Assert.AreEqual(o1.Value, 500.0); }
public void Test29() { var code = @" st = new Stage Procs add p1 = new Process Name = 'PROC1' add p2 = new Process Name = 'PROC2' add new Process Name = 'PROC3' add new Process ID = 'PROCID4' "; var jac = new JacInterpreter(); jac.Exec(code); var st = jac.GetStage("st"); code = @" st ProcLinks add p1 -> p2 "; jac.Exec(code); var p1 = jac.GetProcess("p1"); var tos = st.GetProcessLinkPathes(p1).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 1); Assert.AreEqual(tos[0], jac.GetProcess("p2")); code = @" st ProcLinks add p1->'PROC3' // try to confirm super lazy link by Name "; jac.Exec(code); tos = st.GetProcessLinkPathes(p1).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 2); Assert.AreEqual(tos[0], jac.GetProcess("p2")); Assert.AreEqual(tos[1], jac.GetProcess("PROC3")); code = @" st ProcLinks add p1 ->'PROCID4' // try to confirm lazy link by ID "; jac.Exec(code); tos = st.GetProcessLinkPathes(p1).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 3); Assert.AreEqual(tos[0], jac.GetProcess("p2")); Assert.AreEqual(tos[1], jac.GetProcess("PROC3")); Assert.AreEqual(tos[2], jac.GetProcess("PROCID4")); code = @" st ProcLinks remove p1 -> p2 "; jac.Exec(code); tos = st.GetProcessLinkPathes(p1).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 2); Assert.AreEqual(tos[0], jac.GetProcess("PROC3")); Assert.AreEqual(tos[1], jac.GetProcess("PROCID4")); code = @" st ProcLinks remove p1->'PROC3' // try to confirm super lazy link by Name "; jac.Exec(code); tos = st.GetProcessLinkPathes(p1).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 1); Assert.AreEqual(tos[0], jac.GetProcess("PROCID4")); code = @" st ProcLinks remove p1 ->'PROCID4' // try to confirm lazy link by ID "; jac.Exec(code); tos = st.GetProcessLinkPathes(p1).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 0); //-------------------------------------------------------------------------------------------- code = @" st ProcLinks add 'PROC3'-> p2 "; jac.Exec(code); var PROC3 = jac.GetProcess("PROC3"); tos = st.GetProcessLinkPathes(PROC3).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 1); Assert.AreEqual(tos[0], jac.GetProcess("p2")); code = @" st ProcLinks remove 'PROC3'-> p2 "; jac.Exec(code); tos = st.GetProcessLinkPathes(PROC3).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 0); //-------------------------------------------------------------------------------------------- code = @" st ProcLinks add 'PROCID4' ->p2 "; jac.Exec(code); var PROCID4 = jac.GetProcess("PROCID4"); tos = st.GetProcessLinkPathes(PROCID4).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 1); Assert.AreEqual(tos[0], jac.GetProcess("p2")); code = @" st ProcLinks remove 'PROCID4' ->p2 "; jac.Exec(code); tos = st.GetProcessLinkPathes(PROCID4).Select(key => st.FindChildProcess(key)).ToArray(); Assert.AreEqual(tos.Length, 0); }