public void UpdateAirStatusIndicators(AirChanStatusEnum air_state) { bool air_on = false; bool high_n2_on = false; bool low_n2_on = false; switch (air_state) { case AirChanStatusEnum.Air: air_on = true; break; case AirChanStatusEnum.HighN2: high_n2_on = true; break; case AirChanStatusEnum.LowN2: low_n2_on = true; break; default: //do nothing - air is off break; } if (air_on) SetAirIndicator_ToOn(); else SetAirIndicator_ToOff(); if (high_n2_on) SetHighN2Indicator_ToOn(); else SetHighN2Indicator_ToOff(); if (low_n2_on) SetLowN2Indicator_ToOn(); else SetLowN2Indicator_ToOff(); this.BeginInvoke((Action)(() => this.Refresh())); }
//This function toggles the Air/Nitrogen Relay Valves open and closed //using Digital Output TTL logic //Uses values from the AirChanStatusEnum enumerator to //choose its actions private void SetAirRelayChannelOutput(AirChanStatusEnum state) { MccDaq.ErrorInfo RetVal; //Turn all channels off, first for (int i = 3; i < 6; i++) { RetVal = oven_board.DBitOut(DigitalPortType.AuxPort, i, DigitalLogicState.Low); IsError(this, RetVal, true); } switch (state) { case AirChanStatusEnum.AirOff: //Already done above. break; case AirChanStatusEnum.LowN2: RetVal = oven_board.DBitOut(DigitalPortType.AuxPort, 5, DigitalLogicState.High); IsError(this, RetVal, true); break; case AirChanStatusEnum.HighN2: RetVal = oven_board.DBitOut(DigitalPortType.AuxPort, 3, DigitalLogicState.High); IsError(this, RetVal, true); break; case AirChanStatusEnum.Air: RetVal = oven_board.DBitOut(DigitalPortType.AuxPort, 4, DigitalLogicState.High); IsError(this, RetVal, true); break; default: RetVal = new ErrorInfo(1); MessageBox.Show("Set Air Relay Channel Output error -- invalid Air Relay Channel output state inputed.", " " + "ERROR!"); break; } air_status = state; UpdateAirStatusIndicators(state); }
private void air_channel_out(AirChanStatusEnum state) { MccBoard daq = new MccDaq.MccBoard(BoardNum); MccDaq.ErrorInfo RetVal; for (int i = 3; i < 6; i++) { RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i, DigitalPortDirection.DigitalOut); IsError(this, RetVal, true); } switch (state) { case AirChanStatusEnum.air_off: for (int i = 3; i < 6; i++) { RetVal = daq.DBitOut(DigitalPortType.AuxPort, i, DigitalLogicState.Low); IsError(this, RetVal, true); } break; case AirChanStatusEnum.low_n2: RetVal = daq.DBitOut(DigitalPortType.AuxPort, 5, DigitalLogicState.High); IsError(this, RetVal, true); break; case AirChanStatusEnum.high_n2: RetVal = daq.DBitOut(DigitalPortType.AuxPort, 3, DigitalLogicState.High); IsError(this, RetVal, true); break; case AirChanStatusEnum.air: RetVal = daq.DBitOut(DigitalPortType.AuxPort, 4, DigitalLogicState.High); IsError(this, RetVal, true); break; default: RetVal = new ErrorInfo(1); MessageBox.Show("air_channel_out() called with invalid parameter!", " " + "ERROR!"); break; } RetVal = daq.DConfigBit(DigitalPortType.AuxPort, 0, DigitalPortDirection.DigitalOut); if (IsError(this, RetVal, true) == 0) { air_status = state; } }