예제 #1
0
        public SensorData GetSensorData([PexAssumeUnderTest] PLCController target)
        {
            SensorData result = target.GetSensorData();

            return(result);
            // TODO: add assertions to method PLCControllerTest.GetSensorData(PLCController)
        }
예제 #2
0
        public bool CheckIsAlarmSilenced([PexAssumeUnderTest] PLCController target)
        {
            bool result = target.CheckIsAlarmSilenced();

            return(result);
            // TODO: add assertions to method PLCControllerTest.CheckIsAlarmSilenced(PLCController)
        }
예제 #3
0
        public PLCController Constructor(string fileName)
        {
            PLCController target = new PLCController(fileName);

            return(target);
            // TODO: add assertions to method PLCControllerTest.Constructor(String)
        }
예제 #4
0
        public bool CheckMainTankIsEmpty([PexAssumeUnderTest] PLCController target)
        {
            bool result = target.CheckMainTankIsEmpty();

            return(result);
            // TODO: add assertions to method PLCControllerTest.CheckMainTankIsEmpty(PLCController)
        }
예제 #5
0
        public bool CheckIsFinishedAcknowledged([PexAssumeUnderTest] PLCController target)
        {
            bool result = target.CheckIsFinishedAcknowledged();

            return(result);
            // TODO: add assertions to method PLCControllerTest.CheckIsFinishedAcknowledged(PLCController)
        }
예제 #6
0
        public bool CheckSmallValveIsOpen([PexAssumeUnderTest] PLCController target)
        {
            bool result = target.CheckSmallValveIsOpen();

            return(result);
            // TODO: add assertions to method PLCControllerTest.CheckSmallValveIsOpen(PLCController)
        }
예제 #7
0
        /// <summary>
        /// Stage 4.
        /// </summary>
        /// <param name="plc">The PLC.</param>
        public static void MakeBatchFillAdditives(PLCController plc)
        {
            plc.OpenAdditiveValves();

            System.Threading.Thread.Sleep(500);

            plc.CloseAdditiveValves();
        }
예제 #8
0
        /// <summary>
        /// Stage 3.
        /// </summary>
        /// <param name="plc">The PLC.</param>
        public static void MakeBatchFillSecondTank(PLCController plc)
        {
            plc.OpenSmallValve();

            while (plc.CheckMainTankIsEmpty())
            {
            }

            plc.CloseSmallValve();
        }
예제 #9
0
        /// <summary>
        /// Stage 2.
        /// </summary>
        /// <param name="plc">The PLC.</param>
        public static void MakeBatchFillFirstTank(PLCController plc)
        {
            plc.OpenLargeValve();

            while (plc.CheckMainTankIsEmpty())
            {
            }

            plc.CloseLargeValve();
        }
예제 #10
0
        /// <summary>
        /// Stage 6.
        /// </summary>
        /// <param name="plc">The PLC.</param>
        /// <param name="newBatch">The new batch.</param>
        public static void MakeBatchWaitForFinish(PLCController plc, Batch newBatch)
        {
            DateTime   start = DateTime.Now;
            DateTime   stop;
            SensorData readings;

            //stop furnace and motor and open dishcarge gate once requirements are met
            if (!newBatch.Type.TimeRequirement.HasValue)
            {
                if (newBatch.Type.TemperatureRequirement.HasValue)
                {
                    while (true)
                    {
                        readings = plc.GetSensorData();
                        if (readings.Temperature >= newBatch.Type.TemperatureRequirement)
                        {
                            break;
                        }
                    }
                }
                else if (newBatch.Type.ViscosityRequirement.HasValue)
                {
                    //calculate viscosity
                }
            }
            else
            {
                while (true)
                {
                    readings = plc.GetSensorData();
                    stop     = DateTime.Now;
                    if (readings.Speed >= newBatch.Type.SpeedRequirement && (stop - start).TotalSeconds >= newBatch.Type.TimeRequirement)
                    {
                        break;
                    }
                }
            }

            newBatch.Success   = true;
            newBatch.BatchDate = DateTime.Now;
            plc.TurnOffFurnace();
            plc.StopMotor();
            plc.OpenDischargeGate();
            plc.SignalFinishedBatch();
        }
예제 #11
0
        /// <summary>
        /// Stage 1.
        /// </summary>
        /// <param name="plc">The PLC.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static Batch MakeBatch_EmptyTank(PLCController plc, BatchType type)
        {
            Batch newBatch = new Batch();

            newBatch.BatchDate = DateTime.Now;
            newBatch.MachineID = MachineController.InitializeMachine().ID;
            newBatch.Type      = type;

            if (!plc.CheckMainTankIsEmpty())
            {
                plc.OpenDischargeGate();

                while (!plc.CheckMainTankIsEmpty())
                {
                }
            }

            plc.CloseDischargeGate();

            return(newBatch);
        }
예제 #12
0
 /// <summary>
 /// Stage 5.
 /// </summary>
 /// <param name="plc">The PLC.</param>
 public static void MakeBatchStart(PLCController plc)
 {
     plc.StartMotor();
     plc.TurnOnFurnace();
 }
예제 #13
0
 public void OpenAdditiveValves([PexAssumeUnderTest] PLCController target)
 {
     target.OpenAdditiveValves();
     // TODO: add assertions to method PLCControllerTest.OpenAdditiveValves(PLCController)
 }
예제 #14
0
 public void CloseLargeValve([PexAssumeUnderTest] PLCController target)
 {
     target.CloseLargeValve();
     // TODO: add assertions to method PLCControllerTest.CloseLargeValve(PLCController)
 }
예제 #15
0
        /// <summary>
        /// Makes the batch.
        /// </summary>
        /// <param name="mac">The machine the batch is being mixed on.</param>
        /// <param name="type">The type of batch.</param>
        /// <param name="worker">The worker.</param>
        /// <returns></returns>
        public static Batch MakeBatch(Machine mac, BatchType type, BackgroundWorker worker)
        {
            DateTime      start, stop;
            SensorData    readings;
            PLCController plc      = new PLCController("PLC.txt");
            Batch         newBatch = new Batch();

            newBatch.MachineID = mac.ID;
            newBatch.Type      = type;

            //If the main tank is not empty drain it
            if (!plc.CheckMainTankIsEmpty())
            {
                plc.OpenDischargeGate();

                while (!plc.CheckMainTankIsEmpty())
                {
                    Thread.Sleep(500);
                }
            }

            worker.ReportProgress(1);

            //Close the gate
            if (plc.CheckDischargeGateIsOpen())
            {
                plc.CloseDischargeGate();
            }

            worker.ReportProgress(2);

            //Open large valve until main tank is full
            plc.OpenLargeValve();
            worker.ReportProgress(3);

            Thread.Sleep(1000);

            plc.CloseLargeValve();
            worker.ReportProgress(4);

            //Open small valve for a set time
            plc.OpenSmallValve();
            worker.ReportProgress(5);

            Thread.Sleep(1000);

            plc.CloseSmallValve();
            worker.ReportProgress(6);


            //Open additive valves for a set time
            plc.OpenAdditiveValves();
            worker.ReportProgress(7);

            Thread.Sleep(1000);

            plc.CloseAdditiveValves();
            worker.ReportProgress(8);

            //start motor
            plc.StartMotor();
            worker.ReportProgress(9);

            //start furnace
            plc.TurnOnFurnace();
            worker.ReportProgress(10);

            start = DateTime.Now;

            //stop furnace and motor and open dishcarge gate once requirements are met
            if (!type.TimeRequirement.HasValue)
            {
                if (type.TemperatureRequirement.HasValue)
                {
                    while (true)
                    {
                        readings = plc.GetSensorData();
                        if (readings.Temperature >= type.TemperatureRequirement)
                        {
                            break;
                        }
                    }
                }
                else if (type.ViscosityRequirement.HasValue)
                {
                    //calculate viscosity
                }
            }
            else
            {
                while (true)
                {
                    readings = plc.GetSensorData();
                    stop     = DateTime.Now;
                    if (readings.Speed >= type.SpeedRequirement && (stop - start).TotalSeconds >= type.TimeRequirement)
                    {
                        break;
                    }
                }
            }

            plc.StopMotor();
            plc.TurnOffFurnace();
            plc.OpenDischargeGate();

            //signal batch done
            plc.SignalFinishedBatch();

            return(newBatch);
        }
예제 #16
0
 public void TurnOnFurnace([PexAssumeUnderTest] PLCController target)
 {
     target.TurnOnFurnace();
     // TODO: add assertions to method PLCControllerTest.TurnOnFurnace(PLCController)
 }
예제 #17
0
 public void StopMotor([PexAssumeUnderTest] PLCController target)
 {
     target.StopMotor();
     // TODO: add assertions to method PLCControllerTest.StopMotor(PLCController)
 }
예제 #18
0
 public void SoundAlarm([PexAssumeUnderTest] PLCController target)
 {
     target.SoundAlarm();
     // TODO: add assertions to method PLCControllerTest.SoundAlarm(PLCController)
 }
예제 #19
0
 public void SignalFinishedBatch([PexAssumeUnderTest] PLCController target)
 {
     target.SignalFinishedBatch();
     // TODO: add assertions to method PLCControllerTest.SignalFinishedBatch(PLCController)
 }
예제 #20
0
 public void OpenSmallValve([PexAssumeUnderTest] PLCController target)
 {
     target.OpenSmallValve();
     // TODO: add assertions to method PLCControllerTest.OpenSmallValve(PLCController)
 }