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("\u000500FFCR000120260C")) read = "\u0002" + PlcHelper.GetDemountStatusStream(0) + PlcStream.CalculateCheckSum(PlcHelper.GetDemountStatusStream(0)); }); DemountPlc target = new DemountPlc(plcComm.Object); target.Open(); IDemountStatus target1 = target.GetStatus(); Assert.AreEqual<bool>(false, target1.IsCarrierPlateArrived); Assert.AreEqual<bool>(false, target1.IsCarrierPlateDemountStarted); Assert.AreEqual<int>(2, target1.DemountInfo.DemountedWaferCount); Assert.AreEqual<bool>(false, target1.DemountInfo.Completed); Assert.AreEqual<DemountCassetteHopper>(DemountCassetteHopper.Hopper4, target1.CanReadCassetteBarcode); Assert.AreEqual<bool>(true, target1.AreCassettes[0]); Assert.AreEqual<bool>(false, target1.AreCassettes[1]); Assert.AreEqual<bool>(true, target1.AreCassettes[2]); Assert.AreEqual<bool>(false, target1.AreCassettes[3]); Assert.AreEqual<DemountState>(DemountState.AutoDemount, target1.State); }
public void CassetteBarcodeSuccesfullyReaded1Test() { Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock(); DemountPlc target = new DemountPlc(plcComm.Object); target.Open(); target.CassetteBarcodeSuccesfullyRead(); plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1)); plcComm.Verify(x => x.Write(PlcHelper.GetBoolWriteCommand(true, 0x134)), Times.Exactly(1)); }
public void ChangeCassetteTest() { Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock(); DemountPlc privateTarget = new DemountPlc(plcComm.Object); DemountPlc_Accessor target = new DemountPlc_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(DemountPlc)))); target.Open(); target.ChangeCassette(DemountCassetteStation.Station1, WaferSize.Size8Inches, DemountCassetteHopper.Hopper1); plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1)); plcComm.Verify(x => x.Write(GetWriteCommandChangeCassette(DemountCassetteStation.Station1, WaferSize.Size8Inches, DemountCassetteHopper.Hopper1)), Times.Exactly(1)); }
public void CarrierPlateRoutingTest() { Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock(); DemountPlc privateTarget = new DemountPlc(plcComm.Object); DemountPlc_Accessor target = new DemountPlc_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(DemountPlc)))); target.Open(); target.CarrierPlateRouting(CarrierPlateRoutingType.BackThroughAwps); plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1)); plcComm.Verify(x => x.Write(GetWriteCommandCarrierPlateRouting(CarrierPlateRoutingType.BackThroughAwps)), Times.Exactly(1)); }
public void SpatulaInspectionRequired1Test() { Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock(); DemountPlc privateTarget = new DemountPlc(plcComm.Object); DemountPlc_Accessor target = new DemountPlc_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(DemountPlc)))); target.Open(); target.SpatulaInspectionRequired(); plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1)); plcComm.Verify(x => x.Write(PlcHelper.GetBoolWriteCommand(true, 0x140)), Times.Exactly(1)); }
public void DemountPlcIntegrationTest() { DemountSimulatorPlcCommunication simulator = DemountSimulatorPlcCommunication.Create(); IDemountPlc target = new DemountPlc(simulator); target.Open(); bool barcodeError = false; bool isCarrierPlateBarcodeReadedOk = false; WaferSize carrierPlateWaferSize = WaferSize.AnySize; int waferCount = 0; DemountCassetteStation station = DemountCassetteStation.Cleared; CarrierPlateRoutingType routingType = CarrierPlateRoutingType.Cleared; DemountCassetteStation from = DemountCassetteStation.Cleared; WaferSize cassetteWaferSize = WaferSize.AnySize; DemountCassetteHopper destination = DemountCassetteHopper.Cleared; bool isCassetteBarcodeReadedOk = false; bool spatulaInspectionRequired = false; IDemountStatus status = target.GetStatus(); CompareObjects(simulator, status); for (int i = 0; i < 10000; i++) { // "PLC" randomly clear memory if (_random.NextDouble() > 0.40) { switch (_random.Next(2, 8)) { case 2: isCarrierPlateBarcodeReadedOk = false; simulator.IsCarrierPlateBarcodeReadedOk = isCarrierPlateBarcodeReadedOk; break; case 3: carrierPlateWaferSize = WaferSize.AnySize; simulator.CarrierPlateWaferSize = carrierPlateWaferSize; waferCount = 0; simulator.CarrierPlateWaferCount = waferCount; station = DemountCassetteStation.Cleared; simulator.DemountCassetteStation = station; break; case 4: routingType = CarrierPlateRoutingType.Cleared; simulator.CarrierPlateRoutingType = routingType; break; case 5: from = DemountCassetteStation.Cleared; simulator.RemoveCassetteFromDemountStation = from; cassetteWaferSize = WaferSize.AnySize; simulator.CassetteWaferSize = cassetteWaferSize; destination = DemountCassetteHopper.Cleared; simulator.DestinationStation = destination; break; case 6: isCassetteBarcodeReadedOk = false; simulator.IsCassetteBarcodeReadedOk = isCassetteBarcodeReadedOk; break; case 7: spatulaInspectionRequired = false; simulator.ShouldInspectSpatula = spatulaInspectionRequired; break; } } // "Information system" randomly write to memory if (_random.NextDouble() > 0.50) { switch (_random.Next(1, 8)) { case 1: barcodeError = (_random.NextDouble() > 0.5) ? true : false; target.WriteBarcodeError(barcodeError); CompareObjects(simulator, barcodeError, isCarrierPlateBarcodeReadedOk, carrierPlateWaferSize, waferCount, station, routingType, from, cassetteWaferSize, destination, isCassetteBarcodeReadedOk, spatulaInspectionRequired); break; case 2: target.CarrierPlateBarcodeSuccesfullyReaded(); isCarrierPlateBarcodeReadedOk = true; CompareObjects(simulator, barcodeError, isCarrierPlateBarcodeReadedOk, carrierPlateWaferSize, waferCount, station, routingType, from, cassetteWaferSize, destination, isCassetteBarcodeReadedOk, spatulaInspectionRequired); break; case 3: carrierPlateWaferSize = SimulatorHelper.GetRandomWaferSize(); waferCount = _random.Next(3, 6); station = SimulatorHelper.GetRandomDemountCassetteStation(); target.StartDemounting(carrierPlateWaferSize, waferCount, station); CompareObjects(simulator, barcodeError, isCarrierPlateBarcodeReadedOk, carrierPlateWaferSize, waferCount, station, routingType, from, cassetteWaferSize, destination, isCassetteBarcodeReadedOk, spatulaInspectionRequired); break; case 4: routingType = (_random.NextDouble() > 0.5) ? CarrierPlateRoutingType.BackThroughAwps : CarrierPlateRoutingType.InspectionRequired; target.CarrierPlateRouting(routingType); CompareObjects(simulator, barcodeError, isCarrierPlateBarcodeReadedOk, carrierPlateWaferSize, waferCount, station, routingType, from, cassetteWaferSize, destination, isCassetteBarcodeReadedOk, spatulaInspectionRequired); break; case 5: from = SimulatorHelper.GetRandomDemountCassetteStation(); cassetteWaferSize = SimulatorHelper.GetRandomWaferSize(); destination = SimulatorHelper.GetRandomDemountCassetteHopper(); target.ChangeCassette(from, cassetteWaferSize, destination); CompareObjects(simulator, barcodeError, isCarrierPlateBarcodeReadedOk, carrierPlateWaferSize, waferCount, station, routingType, from, cassetteWaferSize, destination, isCassetteBarcodeReadedOk, spatulaInspectionRequired); break; case 6: target.CassetteBarcodeSuccesfullyRead(); isCassetteBarcodeReadedOk = true; CompareObjects(simulator, barcodeError, isCarrierPlateBarcodeReadedOk, carrierPlateWaferSize, waferCount, station, routingType, from, cassetteWaferSize, destination, isCassetteBarcodeReadedOk, spatulaInspectionRequired); break; case 7: target.SpatulaInspectionRequired(); spatulaInspectionRequired = true; CompareObjects(simulator, barcodeError, isCarrierPlateBarcodeReadedOk, carrierPlateWaferSize, waferCount, station, routingType, from, cassetteWaferSize, destination, isCassetteBarcodeReadedOk, spatulaInspectionRequired); break; } } ChangeStatusData(simulator); status = target.GetStatus(); CompareObjects(simulator, status); } }