public static void DrainVessels() { PressureRegulator.CancelAsync(); ElementRegulator.CancelAsync(); while (PressureRegulator.CancellationPending == true) { Thread.Sleep(100); } //Fill the system with air so it is at a neutral pressure before pumping any fluids -- note that the system will pull air from the drain valve //since it eventually vents somewhere that is at atmospheric pressure BackGroundWorkers.EnableRelay(SystemProperties.StillDrainValve); while (CurrentState.StillEmpty == false || CurrentState.Pressure <= -0.2M) { Thread.Sleep(RefreshRate); } BackGroundWorkers.DisableRelay(SystemProperties.StillDrainValve); Thread.Sleep(3000); //Make sure that the switches are working then pump the Recieving vessels contents into a storage tank so the next run can begin BackGroundWorkers.EnableRelay(SystemProperties.RVDrainValve); Thread.Sleep(3000); //3 second delay so the valve has time to open BackGroundWorkers.EnableRelay(SystemProperties.RVFluidPump); while (CurrentState.RVEmpty == false) { Thread.Sleep(RefreshRate); } BackGroundWorkers.DisableRelay(SystemProperties.RVFluidPump); BackGroundWorkers.DisableRelay(SystemProperties.RVDrainValve); }
//public static void HeatUntilPlateau() //{ // RecordCurrentState(); // PressureRegulator.RunWorkerAsync(); // ElementRegulator.RunWorkerAsync(); // CurrentState.PlateauTemp = 0; // decimal StartTemp = CurrentRun.First().rrColumnHeadTemp; // decimal LastDelta = 0M; // decimal TotalDelta = 0M; // while (!CurrentState.StillEmpty && !CurrentState.RVFull && (CurrentState.ColumnTemp <= StartTemp * 1.1M || CurrentRun.Count < 20)) // { // if (CurrentState.ColumnTemp > StartTemp) // { // RecordCurrentState(); // } // Thread.Sleep(RefreshRate); // } // while ((!CurrentState.StillEmpty && !CurrentState.RVFull && (LastDelta >= 0.02M) || TotalDelta < 0.25M)) // { // decimal Temp1 = CurrentRun[CurrentRun.Count - 1].rrColumnHeadTemp; // decimal Temp2 = CurrentRun[CurrentRun.Count - 20].rrColumnHeadTemp; // LastDelta = Temp2 != 0 ? ((Temp2 - Temp1) / Temp2) : 0; // if (Temp2 > Temp1) // { TotalDelta = Temp2 != 0 ? ((Temp2 - StartTemp) / Temp2) : 0; } // RecordCurrentState(); // Thread.Sleep(RefreshRate); // } //} public static void Distill() { PressureRegulator.RunWorkerAsync(); ElementRegulator.RunWorkerAsync(); //CurrentState.PlateauTemp = CurrentRun.Last().rrColumnHeadTemp; BackGroundWorkers.EnableRelay(SystemProperties.CoolantPump); //Keep distilling as long as the theoretical boiling point is not overran allowing for a 2% margin of error in calculation while (!CurrentState.StillEmpty && !CurrentState.RVFull && CurrentState.ColumnTemp <= CurrentState.TheoreticalBoilingPoint * 1.02M) { RecordCurrentState(); Thread.Sleep(RefreshRate); } BackGroundWorkers.DisableRelay(SystemProperties.StillElement); CurrentState.ElementOn = false; }
public static void FillStill() { if (CurrentState.StillFull == false) { BackGroundWorkers.EnableRelay(SystemProperties.StillFillValve); CurrentState.StillValveOpen = true; Thread.Sleep(3000); //Wait 3 seconds for the valve to open BackGroundWorkers.EnableRelay(SystemProperties.StillFluidPump); CurrentState.StillPumpOn = true; while (CurrentState.StillFull == false) { Thread.Sleep(RefreshRate); } BackGroundWorkers.DisableRelay(SystemProperties.StillFillValve); CurrentState.StillValveOpen = false; BackGroundWorkers.DisableRelay(SystemProperties.StillFluidPump); CurrentState.StillPumpOn = false; } }