Esempio n. 1
0
        public void ForcedInspection()
        {
            DateTime now = DateTime.UtcNow;

            //set up a program
            var inspProg  = new JobInspectionData("insp1", "counter1", 13, TimeSpan.FromHours(11));
            var inspProg2 = new JobInspectionData(inspProg);

            //set the count as zero, otherwise it chooses a random
            InspectCount cnt = new InspectCount();

            cnt.Counter = "counter1";
            cnt.Value   = 0;
            cnt.LastUTC = DateTime.UtcNow.AddHours(-10);
            _insp.SetInspectCounts(new InspectCount[] { cnt });

            //try making a decision
            _insp.ForceInspection(2, "insp1");

            _insp.MakeInspectionDecisions(1, 1, new[] { inspProg }, now);
            _insp.MakeInspectionDecisions(1, 1, new[] { inspProg }, now);
            CheckDecision(1, "insp1", "counter1", false, now);
            CheckCount("counter1", 1);

            _insp.MakeInspectionDecisions(2, 1, new[] { inspProg2 }, now);
            CheckDecision(2, "insp1", "counter1", true, now, true);

            CheckCount("counter1", 2);
        }
Esempio n. 2
0
        public void NextPiece()
        {
            DateTime now = DateTime.UtcNow;
            var      job = new JobPlan("job1", 1);

            job.PartName = "part1";

            //set up a program
            var inspProg = new JobInspectionData("insp1", "counter1", 3, TimeSpan.FromHours(11));

            job.AddInspection(inspProg);

            //set the count as zero, otherwise it chooses a random
            InspectCount cnt = new InspectCount();

            cnt.Counter = "counter1";
            cnt.Value   = 0;
            cnt.LastUTC = DateTime.UtcNow.AddHours(-10);
            _insp.SetInspectCounts(new InspectCount[] { cnt });

            PalletLocation palLoc = new PalletLocation(PalletLocationEnum.Machine, "MC", 1);

            _insp.NextPieceInspection(palLoc, "insp1");
            _insp.CheckMaterialForNextPeiceInspection(palLoc, 1);

            CheckCount("counter1", 0);

            _insp.MakeInspectionDecisions(1, 1, new[] { inspProg }, now);
            CheckCount("counter1", 1);
            CheckDecision(1, "insp1", "counter1", true, now, true);
        }
Esempio n. 3
0
        public void Inspections()
        {
            var now = DateTime.UtcNow;
            //set the count as zero, otherwise it chooses a random
            InspectCount cnt = new InspectCount();

            cnt.Counter = "counter1";
            cnt.Value   = 0;
            cnt.LastUTC = DateTime.UtcNow.AddHours(-11).AddMinutes(2);
            _insp.SetInspectCounts(new InspectCount[] { cnt });

            //set up a program
            var inspProg  = new JobInspectionData("insp1", "counter1", 3, TimeSpan.FromHours(11));
            var inspProg2 = new JobInspectionData(inspProg);

            //the lastutc should be 2 minutes too short, so only inspections from the counter should take place

            _insp.MakeInspectionDecisions(1, 2, new[] { inspProg }, now);
            _insp.MakeInspectionDecisions(1, 2, new[] { inspProg }, now); // twice should have no effect
            CheckDecision(1, "insp1", "counter1", false, now);
            CheckCount("counter1", 1);
            CheckLastUTC("counter1", cnt.LastUTC);

            _insp.MakeInspectionDecisions(2, 2, new[] { inspProg2 }, now);
            CheckDecision(2, "insp1", "counter1", false, now);
            CheckCount("counter1", 2);
            CheckLastUTC("counter1", cnt.LastUTC);

            _insp.MakeInspectionDecisions(3, 2, new[] { inspProg }, now);
            CheckDecision(3, "insp1", "counter1", true, now);

            CheckCount("counter1", 0);
            CheckLastUTC("counter1", DateTime.UtcNow);

            //now check lastutc. set lastutc to be 2 minutes
            cnt         = new InspectCount();
            cnt.Counter = "counter1";
            cnt.Value   = 0;
            cnt.LastUTC = DateTime.UtcNow.AddHours(-11).AddMinutes(-2);
            _insp.SetInspectCounts(new InspectCount[] { cnt });

            _insp.MakeInspectionDecisions(4, 2, new[] { inspProg });
            CheckDecision(4, "insp1", "counter1", true, now);
            CheckLastUTC("counter1", now);
        }
Esempio n. 4
0
        public void Frequencies()
        {
            var freqProg = new JobInspectionData("insp1", "counter1", 0.5, TimeSpan.FromHours(100));

            for (int i = 0; i < 100; i++)
            {
                _insp.MakeInspectionDecisions(i, 1, new[] { freqProg });
            }

            int numInsp = 0;

            for (int i = 0; i < 100; i++)
            {
                if (FindDecision(i, "insp1", "counter1"))
                {
                    numInsp += 1;
                }
            }

            Assert.True(numInsp > 0);
            Assert.True(numInsp < 100);
        }
Esempio n. 5
0
        public void TranslateCounter()
        {
            var counter = "counter1-" +
                          JobInspectionData.LoadFormatFlag(1) + "-" +
                          JobInspectionData.UnloadFormatFlag(1) + "-" +
                          JobInspectionData.LoadFormatFlag(2) + "-" +
                          JobInspectionData.UnloadFormatFlag(2) + "-" +
                          JobInspectionData.PalletFormatFlag(1) + "-" +
                          JobInspectionData.PalletFormatFlag(2) + "-" +
                          JobInspectionData.StationFormatFlag(1, 1) + "-" +
                          JobInspectionData.StationFormatFlag(1, 2) + "-" +
                          JobInspectionData.StationFormatFlag(2, 1) + "-" +
                          JobInspectionData.StationFormatFlag(2, 2);

            var expandedCounter1 = "counter1-1-2-3-4-P1-P2-10-11-12-13";
            var expandedCounter2 = "counter1-6-8-7-9-P5-P4-15-16-18-19";

            //set the count as zero, otherwise it chooses a random
            var cnt = new InspectCount();

            cnt.Counter = expandedCounter1;
            cnt.Value   = 0;
            cnt.LastUTC = DateTime.UtcNow.AddHours(-10);
            var cnt2 = new InspectCount();

            cnt2.Counter = expandedCounter2;
            cnt2.Value   = 0;
            cnt2.LastUTC = DateTime.UtcNow.AddHours(-10);
            _insp.SetInspectCounts(new[] { cnt, cnt2 });


            var mat1Proc1 = new[] { new LogMaterial(1, "job1", 1, "part1", 2, "", "", "") };
            var mat1Proc2 = new[] { new LogMaterial(1, "job1", 2, "part1", 2, "", "", "") };
            var mat2Proc1 = new[] { new LogMaterial(2, "job1", 1, "part1", 2, "", "", "") };
            var mat2Proc2 = new[] { new LogMaterial(2, "job1", 2, "part1", 2, "", "", "") };

            _lastCycleTime = DateTime.UtcNow.AddDays(-1);

            AddCycle(mat1Proc1, "P1", LogType.LoadUnloadCycle, 1, false);
            AddCycle(mat2Proc1, "P5", LogType.LoadUnloadCycle, 6, false);
            AddCycle(mat1Proc1, "P1", LogType.MachineCycle, 10, false);
            AddCycle(mat2Proc1, "P5", LogType.MachineCycle, 15, false);
            AddCycle(mat1Proc1, "P1", LogType.MachineCycle, 11, false);
            AddCycle(mat2Proc1, "P5", LogType.MachineCycle, 16, false);
            AddCycle(mat1Proc1, "P1", LogType.LoadUnloadCycle, 2, false);
            AddCycle(mat2Proc1, "P5", LogType.LoadUnloadCycle, 8, false);

            AddCycle(mat1Proc2, "P2", LogType.LoadUnloadCycle, 3, false);
            AddCycle(mat2Proc2, "P4", LogType.LoadUnloadCycle, 7, false);
            AddCycle(mat1Proc2, "P2", LogType.MachineCycle, 12, false);
            AddCycle(mat2Proc2, "P4", LogType.MachineCycle, 18, false);
            AddCycle(mat1Proc2, "P2", LogType.MachineCycle, 13, false);
            AddCycle(mat2Proc2, "P4", LogType.MachineCycle, 19, false);
            AddCycle(mat1Proc2, "P2", LogType.LoadUnloadCycle, 4, true);
            AddCycle(mat2Proc2, "P4", LogType.LoadUnloadCycle, 9, true);

            var inspProg = new JobInspectionData("insp1", counter, 10, TimeSpan.FromDays(2));

            var now = DateTime.UtcNow;

            _insp.MakeInspectionDecisions(1, 2, new[] { inspProg }, now);
            CheckDecision(1, "insp1", expandedCounter1, false, now);
            Assert.Equal(2, _insp.LoadInspectCounts().Count);
            CheckCount(expandedCounter1, 1);
            CheckCount(expandedCounter2, 0);
            ExpectPathToBe(1, "insp1", new[] {
                new MaterialProcessActualPath()
                {
                    MaterialID  = 1,
                    Process     = 1,
                    Pallet      = "P1",
                    LoadStation = 1,
                    Stops       =
                    {
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 10
                        },
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 11
                        }
                    },
                    UnloadStation = 2,
                },
                new MaterialProcessActualPath()
                {
                    MaterialID  = 1,
                    Process     = 2,
                    Pallet      = "P2",
                    LoadStation = 3,
                    Stops       =
                    {
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 12
                        },
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 13
                        }
                    },
                    UnloadStation = 4,
                }
            });

            _insp.MakeInspectionDecisions(2, 2, new[] { inspProg });
            CheckDecision(2, "insp1", expandedCounter2, false, now);
            ExpectPathToBe(2, "insp1", new[] {
                new MaterialProcessActualPath()
                {
                    MaterialID  = 2,
                    Process     = 1,
                    Pallet      = "P5",
                    LoadStation = 6,
                    Stops       =
                    {
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 15
                        },
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 16
                        }
                    },
                    UnloadStation = 8,
                },
                new MaterialProcessActualPath()
                {
                    MaterialID  = 2,
                    Process     = 2,
                    Pallet      = "P4",
                    LoadStation = 7,
                    Stops       =
                    {
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 18
                        },
                        new MaterialProcessActualPath.Stop()
                        {
                            StationName = "MC", StationNum = 19
                        }
                    },
                    UnloadStation = 9,
                }
            });

            Assert.Equal(2, _insp.LoadInspectCounts().Count);
            CheckCount(expandedCounter1, 1);
            CheckCount(expandedCounter2, 1);
        }