コード例 #1
0
        public void Test06_3()
        {
            var code = @"
                st = new Stage
                p1 = new Process
                    ID = 'IgnoreProcess'
            ";
            var jac  = new JacInterpreter();

            jac.Exec(code);
            Assert.IsNotNull(jac.GetProcess("IgnoreProcess"));

            code = @"
                st
                    Procs
                        add IgnoreProcess
            ";
            jac.Exec(code);
            Assert.IsNotNull(jac.GetProcess("IgnoreProcess"));

            code = @"
                st
                    Procs
                        remove IgnoreProcess
            ";
            jac.Exec(code);
            Assert.IsNull(jac.GetProcess("IgnoreProcess"));
        }
コード例 #2
0
        public void Test06_2()
        {
            var code = @"
                st = new Stage
                    Procs
                        add new Process
                            ID = 'IgnoreProcess'
            ";
            var jac  = new JacInterpreter();

            jac.Exec(code);
            Assert.IsNotNull(jac.GetProcess("IgnoreProcess"));

            code = @"
                st
                    Procs
                        remove IgnoreProcess
            ";
            jac.Exec(code);
            Assert.IsNull(jac.GetProcess("IgnoreProcess"));

            code = @"
                st
                    Procs
                        add IgnoreProcess   // Expected cannot add removed process.
            ";
            jac.Exec(code);
            Assert.IsNull(jac.GetProcess("IgnoreProcess"));   // CANNOT ADD After Removed
        }
コード例 #3
0
        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
        }
コード例 #4
0
        public void Test17()
        {
            var code = @"
                new Stage
                    Procs
                        add sink = new Process
                            Name = 'SinkProc'
                        add p1 = new Process
                            Name = 'MyProc'
                            Cio
                                add o1 = new CoJoinFrom
                                    PullFromProcessKey = 'SinkProc'
                                    ChildWorkKey = 'TEPA'
                                    PorlingSpan = 0.5M                                    
            ";
            var jac  = new JacInterpreter();

            jac.Exec(code);
            var o1 = jac["o1"] as CoJoinFrom;

            Assert.IsNotNull(o1);
            Assert.AreEqual(o1.PullFromProcessKey, jac.GetProcess("SinkProc").Name);
            Assert.AreEqual(o1.ChildWorkKey, "TEPA");
            Assert.AreEqual(o1.PorlingSpan, TimeSpan.FromSeconds(30));
        }
コード例 #5
0
        public void Test10()
        {
            var code = @"
                new Stage
                    Procs
                        add p1 = new Process
                            Name = 'PROCP1'
                            Cio
                                add new CoSpan
                                    Span = 11S
                                add new CiDelay
                                    Delay = 66M
            ";
            var jac  = new JacInterpreter();

            jac.Exec(code);
            var proc = jac.GetProcess("p1");

            Assert.IsNotNull(proc);

            var span = proc.Cios.Select(a => a as CoSpan).Where(a => a != null).FirstOrDefault();

            Assert.AreEqual(span.Span, TimeSpan.FromSeconds(11));
            var delay = proc.Cios.Select(a => a as CiDelay).Where(a => a != null).FirstOrDefault();

            Assert.AreEqual(delay.Delay, TimeSpan.FromMinutes(66));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        public void Test06_4()
        {
            var code = @"
                st = new Stage
                    Procs
                        add new Process
                            ID = 'IgnoreProcess'
            ";
            var jac  = new JacInterpreter();

            jac.Exec(code);
            Assert.IsNotNull(jac.GetProcess("IgnoreProcess"));

            code = @"
                st
                    Procs
                        remove IgnoreProcess
                        add IgnoreProcess           // Expected success add because there is in the same jac code.
            ";
            jac.Exec(code);
            Assert.IsNotNull(jac.GetProcess("IgnoreProcess"));
        }
コード例 #8
0
        public void Test28()
        {
            var code = @"
                st = new Stage
                    Procs
                        add sink = new Process
                        add p1 = new Process
                            Name = 'PROCP1'
                            Cio
                                add pt = new CiPickTo
                                    Delay = 0MS
                                    TargetWorkClass = ':Car'
                                    DestProcessKey = sink.ID // To confirm Objct.Property style string set
            ";
            var jac  = new JacInterpreter();

            jac.Exec(code);
            var pt = jac["pt"] as CiPickTo;

            Assert.IsNotNull(pt);
            var p1 = jac.GetProcess("p1");

            Assert.IsNotNull(p1);
            var sink = jac.GetProcess("sink");

            Assert.IsNotNull(p1);
            var redo = $"{pt.ID}\r\n" +
                       $"    DestProcessKey = 'REDO_PROC'r\n";
            var undo = $"{pt.ID}\r\n" +
                       $"    DestProcessKey = '{sink.ID}'\r\n";

            Assert.AreEqual(pt.DestProcessKey, sink.ID);
            jac.Exec(redo);
            jac.Exec(undo);
            Assert.AreEqual(pt.DestProcessKey, sink.ID);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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"));
        }
コード例 #11
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);
        }
コード例 #12
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);
        }