//-------------------------------------------------------------------------------------------------// public RadiationCounter(XmlNode xmlNodeEquipmentConfig, SerialLcd serialLcd, FlexMotion flexMotion) { const string STRLOG_MethodName = "RadiationCounter"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.serialLcd = serialLcd; this.flexMotion = flexMotion; // // Get initialisation delay // XmlNode xmlNodePhysicsCounter = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_st360Counter); try { this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodePhysicsCounter, Consts.STRXML_initialiseDelay); if (this.initialiseDelay < 0) { throw new ArgumentException(STRERR_NumberIsNegative); } } catch (ArgumentNullException) { throw new ArgumentException(STRERR_InitialiseDelayNotSpecified); } catch (FormatException) { // Value cannot be converted throw new ArgumentException(STRERR_NumberIsInvalid, Consts.STRXML_initialiseDelay); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw new ArgumentException(ex.Message, Consts.STRXML_initialiseDelay); } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public PhysicsCounter(XmlNode xmlNodeEquipmentConfig, SerialLcd serialLcd, FlexMotion flexMotion) { const string STRLOG_MethodName = "RadiationCounter"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.serialLcd = serialLcd; this.flexMotion = flexMotion; // // Get initialisation delay // XmlNode xmlNodePhysicsCounter = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_st360Counter); try { this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodePhysicsCounter, Consts.STRXML_initialiseDelay); if (this.initialiseDelay < 0) { throw new ArgumentException(STRERR_NumberIsNegative); } } catch (ArgumentNullException) { throw new ArgumentException(STRERR_InitialiseDelayNotSpecified); } catch (FormatException) { // Value cannot be converted throw new ArgumentException(STRERR_NumberIsInvalid, Consts.STRXML_initialiseDelay); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw new ArgumentException(ex.Message, Consts.STRXML_initialiseDelay); } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public EquipmentEngine(string rootFilePath) : base(rootFilePath) { const string STRLOG_MethodName = "EquipmentEngine"; Logfile.WriteCalled(null, STRLOG_MethodName); int initialiseDelay = 0; bool hardwarePresent = true; try { // // Determine if hardware is to be used or whether this is running without hardware // for testing and debugging // try { hardwarePresent = XmlUtilities.GetBoolValue(this.xmlNodeEquipmentConfig, Consts.STRXML_hardwarePresent, false); } catch { // Key not found or invalid so assume hardware is present } // // Create an instance of the FlexMotion class, must be done before creating the Radiation Counter class // if (hardwarePresent == true) { this.flexMotion = new FlexMotionCntl(this.xmlNodeEquipmentConfig); } else { this.flexMotion = new FlexMotionNone(this.xmlNodeEquipmentConfig); } initialiseDelay += this.flexMotion.InitialiseDelay; // // Get the serial LCD communication type // XmlNode xmlNodeSerialLcd = XmlUtilities.GetXmlNode(this.xmlNodeEquipmentConfig, Consts.STRXML_serialLcd); string strSerialLcdCommType = XmlUtilities.GetXmlValue(xmlNodeSerialLcd, Consts.STRXML_type, false); this.serialLcdCommType = (CommunicationTypes)Enum.Parse(typeof(CommunicationTypes), strSerialLcdCommType); // // Create an instance of the SerialLcd class, must be done before creating the Radiation Counter class // if (hardwarePresent == true) { if (this.serialLcdCommType == CommunicationTypes.Network) { this.serialLcdTcp = new SerialLcdTcp(this.xmlNodeEquipmentConfig); this.serialLcd = this.serialLcdTcp; } else if (this.serialLcdCommType == CommunicationTypes.Serial) { this.serialLcdSer = new SerialLcdSer(this.xmlNodeEquipmentConfig); this.serialLcd = this.serialLcdSer; } else if (this.serialLcdCommType == CommunicationTypes.None) { this.serialLcdNone = new SerialLcdNone(this.xmlNodeEquipmentConfig); this.serialLcd = this.serialLcdNone; } else { throw new ArgumentException(STRERR_SerialLcdCommsTypeNotSpecified); } } else { this.serialLcdNone = new SerialLcdNone(this.xmlNodeEquipmentConfig); this.serialLcd = this.serialLcdNone; } initialiseDelay += this.serialLcd.InitialiseDelay; // // Get the radiation counter type // XmlNode xmlNodeRadiationCounter = XmlUtilities.GetXmlNode(this.xmlNodeEquipmentConfig, Consts.STRXML_radiationCounter, false); string strCounterType = XmlUtilities.GetXmlValue(xmlNodeRadiationCounter, Consts.STRXML_type, false); this.radiationCounterType = (RadiationCounterTypes)Enum.Parse(typeof(RadiationCounterTypes), strCounterType); // // Create an instance of the radiation counter class // if (this.radiationCounterType == RadiationCounterTypes.ST360) { // // Get the ST360 counter communication type // XmlNode xmlNodeST360Counter = XmlUtilities.GetXmlNode(this.xmlNodeEquipmentConfig, Consts.STRXML_st360Counter); string strST360CounterCommType = XmlUtilities.GetXmlValue(xmlNodeST360Counter, Consts.STRXML_type, false); this.st360CounterCommType = (CommunicationTypes)Enum.Parse(typeof(CommunicationTypes), strST360CounterCommType); // // Create an instance of the ST360 counter class depending on the communication type // if (hardwarePresent == true) { if (this.st360CounterCommType == CommunicationTypes.Network) { this.st360CounterTcp = new ST360CounterTcp(this.xmlNodeEquipmentConfig); this.st360Counter = st360CounterTcp; } else if (this.st360CounterCommType == CommunicationTypes.Serial) { this.st360CounterSer = new ST360CounterSer(this.xmlNodeEquipmentConfig); this.st360Counter = st360CounterSer; } else { throw new ArgumentException(STRERR_ST360CounterCommsTypeNotSpecified); } } else { this.st360CounterNone = new ST360CounterNone(this.xmlNodeEquipmentConfig); this.st360Counter = st360CounterNone; } initialiseDelay += this.st360Counter.InitialiseDelay; } else if (this.radiationCounterType == RadiationCounterTypes.Physics) { if (hardwarePresent == true) { if (this.serialLcdCommType == CommunicationTypes.Network) { this.physicsCounter = new PhysicsCounter(this.xmlNodeEquipmentConfig, this.serialLcdTcp, this.flexMotion); } else if (this.serialLcdCommType == CommunicationTypes.Serial) { this.physicsCounter = new PhysicsCounter(this.xmlNodeEquipmentConfig, this.serialLcdSer, this.flexMotion); } else { throw new ArgumentException(STRERR_SerialLcdCommsTypeNotSpecified); } } else { this.physicsCounter = new PhysicsCounter(this.xmlNodeEquipmentConfig, this.serialLcdNone, this.flexMotion); } initialiseDelay += this.physicsCounter.InitialiseDelay; } else { throw new ArgumentException(STRERR_RadiationCounterTypeNotSpecified); } // // Update the power initialisation delay // this.powerupInitialiseDelay = initialiseDelay; Logfile.Write(STRLOG_InitialiseDelay + initialiseDelay.ToString() + STRLOG_Seconds); } catch (Exception ex) { // // Log the message and throw the exception back to the caller // Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }