Пример #1
0
        /// <summary>
        /// Stage 2.
        /// </summary>
        /// <param name="plc">The PLC.</param>
        public static void MakeBatchFillFirstTank(PLCController plc)
        {
            plc.OpenLargeValve();

            while (plc.CheckMainTankIsEmpty())
            {
            }

            plc.CloseLargeValve();
        }
Пример #2
0
 public void CloseLargeValve([PexAssumeUnderTest] PLCController target)
 {
     target.CloseLargeValve();
     // TODO: add assertions to method PLCControllerTest.CloseLargeValve(PLCController)
 }
Пример #3
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);
        }