예제 #1
0
        public void AcceptMagazine2Test()
        {
            Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock();
            StockerPlc target = new StockerPlc(plcComm.Object);

            target.Open();
            target.AcceptMagazine(MagazineSelection.DoesNotHaveRequestedSize);

            plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1));
            plcComm.Verify(x => x.Write(GetAcceptMagazineCommand(MagazineSelection.DoesNotHaveRequestedSize)), Times.Exactly(1));
        }
예제 #2
0
        public void AcceptCarrierPlate2Test()
        {
            Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock();
            StockerPlc target = new StockerPlc(plcComm.Object);

            target.Open();
            target.AcceptCarrierPlate(CarrierPlateRouting.Reject);

            plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1));
            plcComm.Verify(x => x.Write(GetAcceptCarrierPlateCommand(CarrierPlateRouting.Reject)), Times.Exactly(1));
        }
        public void StockerPlcIntegrationTest()
        {
            StockerSimulatorPlcCommunication simulator = StockerSimulatorPlcCommunication.Create();

            IStockerPlc target = new StockerPlc(simulator);
            target.Open();

            bool barcodeError = false;
            CarrierPlateRouting routing = CarrierPlateRouting.Cleared;
            bool isMagazineChanged = false;
            bool isMagazineBarcodeReadedOk = false;
            StockerInventory inventory = StockerInventory.Cleared;
            MagazineSelection selection = MagazineSelection.Cleared;

            IStockerStatus status = target.GetStatus();
            CompareObjects(simulator, status);

            for (int i = 0; i < 100000; i++)
            {
                // "PLC" randomly clear memory
                if (_random.NextDouble() > 0.40)
                {
                    switch (_random.Next(2, 7))
                    {
                        case 2:
                            routing = CarrierPlateRouting.Cleared;
                            simulator.CarrierPlateRouting = routing;
                            break;
                        case 3:
                            isMagazineChanged = false;
                            simulator.IsMagazineChange = isMagazineChanged;
                            break;
                        case 4:
                            isMagazineBarcodeReadedOk = false;
                            simulator.IsInputMagazineBarcodeOK = isMagazineBarcodeReadedOk;
                            break;
                        case 5:
                            inventory = StockerInventory.Cleared;
                            simulator.StockerInventory = inventory;
                            break;
                        case 6:
                            selection = MagazineSelection.Cleared;
                            simulator.Selection = selection;
                            break;
                    }
                }

                // "Information system" randomly write to memory
                if (_random.NextDouble() > 0.50)
                {
                    switch (_random.Next(1, 7))
                    {
                        case 1:
                            barcodeError = (_random.NextDouble() > 0.5) ? true : false;
                            target.WriteBarcodeError(barcodeError);
                            CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection);
                            break;
                        case 2:
                            routing = (_random.NextDouble() > 0.5) ? CarrierPlateRouting.InsertIntoMagazine : CarrierPlateRouting.Reject;
                            target.AcceptCarrierPlate(routing);
                            CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection);
                            break;
                        case 3:
                            target.MagazineChange();
                            isMagazineChanged = true;
                            CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection);
                            break;
                        case 4:
                            target.MagazineBarcodeSuccesfullyReaded();
                            isMagazineBarcodeReadedOk = true;
                            CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection);
                            break;
                        case 5:
                            inventory = (_random.NextDouble() > 0.5) ? StockerInventory.SizeAvailable : StockerInventory.SizeNotInStocker;
                            target.SetWaferSizeAvailable(inventory);
                            CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection);
                            break;
                        case 6:
                            selection = (_random.NextDouble() > 0.5) ? MagazineSelection.HasRequestedSize : MagazineSelection.DoesNotHaveRequestedSize;
                            target.AcceptMagazine(selection);
                            CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection);
                            break;
                    }
                }

                ChangeStatusData(simulator);
                status = target.GetStatus();
                CompareObjects(simulator, status);
            }
        }
예제 #4
0
        public void GetStatus1Test()
        {
            Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock();
            string read = string.Empty;
            plcComm.Setup(x => x.Read()).Returns(() => { return read; });
            plcComm.Setup(x => x.Write(It.IsAny<string>())).Callback<string>((s) =>
            {
                if (s.StartsWith("\u000500FFCR00012016"))
                    read = "\u0002" + PlcHelper.GetStockerStatusStream(0) + PlcStream.CalculateCheckSum(PlcHelper.GetStockerStatusStream(0));
            });

            StockerPlc target = new StockerPlc(plcComm.Object);
            target.Open();

            IStockerStatus target1 = target.GetStatus();

            Assert.AreEqual<bool>(true, target1.IsCarrierPlateArrived);
            Assert.AreEqual<bool>(false, target1.MagazineChangeRequest.IsMagazineFull);
            Assert.AreEqual<bool>(false, target1.MagazineChangeRequest.IsOperatorChangeRequest);
            Assert.AreEqual<bool>(true, target1.IsMagazineChangeStarted);
            Assert.AreEqual<WaferSize>(WaferSize.Size6Inches, target1.MagazineRequest.WaferSize);
            Assert.AreEqual<bool>(true, target1.MagazineRequest.IsRequested);
            Assert.AreEqual<int>(1, target1.MagazineRequest.PolishLineNumber);
            Assert.AreEqual<bool>(true, target1.IsMagazineArrived);
            Assert.AreEqual<MagazineSelection>(MagazineSelection.Cleared, target1.MagazineSelection);
        }
예제 #5
0
        public void WriteBarcodeError2Test()
        {
            Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock();
            StockerPlc privateTarget = new StockerPlc(plcComm.Object);
            StockerPlc_Accessor target = new StockerPlc_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(StockerPlc))));

            target.Open();
            target.WriteBarcodeError(true);

            plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1));
            plcComm.Verify(x => x.Write(PlcHelper.GetBoolWriteCommand(true, 0x121)), Times.Exactly(1));
        }
예제 #6
0
        public void SetWaferSizeAvailable2Test()
        {
            Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock();
            StockerPlc target = new StockerPlc(plcComm.Object);

            target.Open();
            target.SetWaferSizeAvailable(StockerInventory.SizeNotInStocker);

            plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1));
            plcComm.Verify(x => x.Write(GetSetWaferSizeAvailableCommand(StockerInventory.SizeNotInStocker)), Times.Exactly(1));
        }
예제 #7
0
        public void MagazineChangeTest()
        {
            Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock();
            StockerPlc target = new StockerPlc(plcComm.Object);

            target.Open();
            target.MagazineChange();

            plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1));
            plcComm.Verify(x => x.Write(PlcHelper.GetBoolWriteCommand(true, 0x125)), Times.Exactly(1));
        }