//-------------------------------------------------------------------------------------------------// public LabEquipmentManager(string rootFilePath) { const string STRLOG_MethodName = "LabEquipmentManager"; Logfile.WriteCalled(null, STRLOG_MethodName); this.rootFilePath = rootFilePath; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Create thread objects // this.managerLock = new Object(); if (this.managerLock == null) { throw new ArgumentNullException(STRERR_managerLock); } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public LabEquipmentManager(string rootFilePath) { const string STRLOG_MethodName = "LabEquipmentManager"; Logfile.WriteCalled(null, STRLOG_MethodName); this.rootFilePath = rootFilePath; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Create thread objects // this.managerLock = new Object(); if (this.managerLock == null) { throw new ArgumentNullException(STRERR_managerLock); } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public EquipmentManager(string rootFilePath) : base(rootFilePath) { // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); }
//-------------------------------------------------------------------------------------------------// public EquipmentManager(string rootFilePath) : base(rootFilePath) { // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); }
//-------------------------------------------------------------------------------------------------// public DriverHardware(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "DriverHardware"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.disposed = true; this.initialised = false; this.lastError = null; this.configured = false; // // Initialise properties // this.initialiseDelay = DELAY_INITIALISE; this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // YOUR CODE HERE // Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public DriverHardware(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "DriverHardware"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.disposed = true; this.initialised = false; this.lastError = null; this.configured = false; // // Initialise properties // this.initialiseDelay = DELAY_INITIALISE; this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // YOUR CODE HERE // Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public PowerMeter(string ipaddr, int port) { const string STRLOG_MethodName = "PowerMeter"; Logfile.WriteCalled(null, STRLOG_MethodName); this.ipaddr = ipaddr; this.port = port; try { // // Initialise local variables // this.lastError = null; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); } catch (Exception ex) { // // Log the message and throw the exception back to the caller // Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public PowerMeter(ModbusIpMaster master) { const string STRLOG_MethodName = "PowerMeter"; Logfile.WriteCalled(null, STRLOG_MethodName); this.master = master; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public PowerMeter(ModbusIpMaster master) { const string STRLOG_MethodName = "PowerMeter"; Logfile.WriteCalled(null, STRLOG_MethodName); this.master = master; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public EquipmentEngine(string rootFilePath) : base(rootFilePath) { const string STRLOG_MethodName = "EquipmentEngine"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); try { // // Create an instance of the RedLion class // this.redLion = new RedLion(this.xmlNodeEquipmentConfig); // // Check the minimum initialise delay and update if necessary // //int initialiseDelay = this.redLion.InitialiseDelay; //if (initialiseDelay > this.InitialiseDelay) //{ // this.InitialiseDelay = initialiseDelay; // Logfile.Write(STRLOG_InitialiseDelay + initialiseDelay.ToString() + STRLOG_Seconds); //} // // Get the intialise equipment flag // bool initialiseEquipment = XmlUtilities.GetBoolValue(this.xmlNodeEquipmentConfig, Consts.STRXML_initialiseEquipment, false); Logfile.Write(STRLOG_InitialiseEquipment + initialiseEquipment.ToString()); this.redLion.InitialiseEquipment = initialiseEquipment; // // Get the delay in seconds to wait before taking a measurement // int measurementDelay = XmlUtilities.GetIntValue(this.xmlNodeEquipmentConfig, Consts.STRXML_measurementDelay); if (measurementDelay < 1) { throw new Exception(STRERR_NumberIsInvalid); } Logfile.Write(STRLOG_MeasurementDelay + measurementDelay.ToString()); this.redLion.MeasurementDelay = measurementDelay; } catch (Exception ex) { // // Log the message and throw the exception back to the caller // Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public RedLion(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "RedLion"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.initialised = false; this.lastError = null; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Get the IP address of the RedLion unit // this.machineIP = XmlUtilities.GetXmlValue(xmlNodeEquipmentConfig, Consts.STRXML_machineIP, false); IPAddress machineIP = IPAddress.Parse(this.machineIP); Logfile.Write(STRLOG_MachineIP + this.machineIP.ToString()); // // Get the port number to use with the RedLion unit // this.machinePort = XmlUtilities.GetIntValue(xmlNodeEquipmentConfig, Consts.STRXML_machinePort); if (this.machinePort < 0) { throw new Exception(STRERR_NumberIsNegative); } Logfile.Write(STRLOG_MachinePort + this.machinePort.ToString()); // // Get the intialise equipment flag // this.initialiseEquipment = XmlUtilities.GetBoolValue(xmlNodeEquipmentConfig, Consts.STRXML_initialiseEquipment, false); Logfile.Write(STRLOG_InitialiseEquipment + this.initialiseEquipment.ToString()); // // Get the measurement delay // this.measurementDelay = XmlUtilities.GetIntValue(xmlNodeEquipmentConfig, Consts.STRXML_measurementDelay); Logfile.Write(STRLOG_MeasurementDelay + this.measurementDelay.ToString()); Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public RedLion(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "RedLion"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.initialised = false; this.lastError = null; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Get the IP address of the RedLion unit // this.machineIP = XmlUtilities.GetXmlValue(xmlNodeEquipmentConfig, Consts.STRXML_machineIP, false); IPAddress machineIP = IPAddress.Parse(this.machineIP); Logfile.Write(STRLOG_MachineIP + this.machineIP.ToString()); // // Get the port number to use with the RedLion unit // this.machinePort = XmlUtilities.GetIntValue(xmlNodeEquipmentConfig, Consts.STRXML_machinePort); if (this.machinePort < 0) { throw new Exception(STRERR_NumberIsNegative); } Logfile.Write(STRLOG_MachinePort + this.machinePort.ToString()); // // Get the intialise equipment flag // this.initialiseEquipment = XmlUtilities.GetBoolValue(xmlNodeEquipmentConfig, Consts.STRXML_initialiseEquipment, false); Logfile.Write(STRLOG_InitialiseEquipment + this.initialiseEquipment.ToString()); // // Get the measurement delay // this.measurementDelay = XmlUtilities.GetIntValue(xmlNodeEquipmentConfig, Consts.STRXML_measurementDelay); Logfile.Write(STRLOG_MeasurementDelay + this.measurementDelay.ToString()); Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public PowerMeter(string ipaddr, int port) { const string STRLOG_MethodName = "PowerMeter"; Logfile.WriteCalled(null, STRLOG_MethodName); this.ipaddr = ipaddr; this.port = port; try { // // Initialise local variables // this.lastError = null; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); } catch (Exception ex) { // // Log the message and throw the exception back to the caller // Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public ST360Counter(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "ST360Counter"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.disposed = true; this.initialised = false; this.lastError = null; this.configured = false; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Get initialisation delay // XmlNode xmlNodeST360Counter = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_st360Counter); try { this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodeST360Counter, 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); } // // Get Geiger tube voltage from application's configuration file // this.geigerTubeVoltage = XmlUtilities.GetIntValue(xmlNodeST360Counter, Consts.STRXML_voltage, DEFAULT_HighVoltage); // // Make sure that the high voltage is within range // if (this.geigerTubeVoltage < MIN_HighVoltage) { this.geigerTubeVoltage = MIN_HighVoltage; } else if (this.geigerTubeVoltage > MAX_HighVoltage) { this.geigerTubeVoltage = MAX_HighVoltage; } Logfile.Write(STRLOG_HighVoltage + this.geigerTubeVoltage.ToString()); // // Get speaker volume from application's configuration file // this.speakerVolume = XmlUtilities.GetIntValue(xmlNodeST360Counter, Consts.STRXML_volume, MIN_SpeakerVolume); // // Make sure that the speaker volume is within range // if (this.speakerVolume < MIN_SpeakerVolume) { this.speakerVolume = MIN_SpeakerVolume; } else if (this.speakerVolume > MAX_SpeakerVolume) { this.speakerVolume = MAX_SpeakerVolume; } Logfile.Write(STRLOG_SpeakerVolume + this.speakerVolume.ToString()); // // Get capture time adjustment: y = Mx + C // XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlNodeST360Counter, Consts.STRXML_timeAdjustment, false); string capture = XmlUtilities.GetXmlValue(xmlNode, Consts.STRXML_capture, false); string[] strSplit = capture.Split(new char[] { Engine.Consts.CHR_CsvSplitterChar }); this.timeAdjustmentCapture = new double[strSplit.Length]; for (int i = 0; i < strSplit.Length; i++) { this.timeAdjustmentCapture[i] = Double.Parse(strSplit[i]); } // // Create the receive objects // this.receiveDataInfo = new ReceiveDataInfo(); this.responseSignal = new Object(); Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public EquipmentEngine(string rootFilePath) : base(rootFilePath) { const string STRLOG_MethodName = "EquipmentEngine"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); try { // // Create an instance of the RedLion class // this.redLion = new RedLion(this.xmlNodeEquipmentConfig); // // Check the minimum initialise delay and update if necessary // //int initialiseDelay = this.redLion.InitialiseDelay; //if (initialiseDelay > this.InitialiseDelay) //{ // this.InitialiseDelay = initialiseDelay; // Logfile.Write(STRLOG_InitialiseDelay + initialiseDelay.ToString() + STRLOG_Seconds); //} // // Get the intialise equipment flag // bool initialiseEquipment = XmlUtilities.GetBoolValue(this.xmlNodeEquipmentConfig, Consts.STRXML_initialiseEquipment, false); Logfile.Write(STRLOG_InitialiseEquipment + initialiseEquipment.ToString()); this.redLion.InitialiseEquipment = initialiseEquipment; // // Get the delay in seconds to wait before taking a measurement // int measurementDelay = XmlUtilities.GetIntValue(this.xmlNodeEquipmentConfig, Consts.STRXML_measurementDelay); if (measurementDelay < 1) { throw new Exception(STRERR_NumberIsInvalid); } Logfile.Write(STRLOG_MeasurementDelay + measurementDelay.ToString()); this.redLion.MeasurementDelay = measurementDelay; } catch (Exception ex) { // // Log the message and throw the exception back to the caller // Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//---------------------------------------------------------------------------------------// public SerialLcd(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "SerialLcd"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.disposed = true; this.initialised = false; this.lastError = null; this.reportRunning = false; this.captureData = -1; this.lcdKey = LCDKey.None; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Get initialisation delay // XmlNode xmlNodeSerialLcd = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_serialLcd); try { this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodeSerialLcd, 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); } // // Get WriteLine() time // try { this.writeLineTime = XmlUtilities.GetRealValue(xmlNodeSerialLcd, Consts.STRXML_writeLineTime, 0.0); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw new ArgumentException(ex.Message, Consts.STRXML_writeLineTime); } // // Create the receive and report objects // this.receiveDataInfo = new ReceiveDataInfo(); this.reportQueue = new Queue <LCDPacket>(); this.reportSignal = new Object(); this.responseSignal = new Object(); Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public LabEquipmentEngine(string rootFilePath, string xmlEquipmentConfig, string equipmentConfigFilename) { const string STRLOG_MethodName = "LabEquipmentEngine"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.disposed = true; this.rootFilePath = rootFilePath; // // Initialise properties // this.powerupInitialiseDelay = 0; this.slRunning = false; this.slIsReady = false; this.slPowerdownSuspended = false; this.slOnline = false; this.slStatusMessage = STR_NotInitialised; this.debug_Retry = false; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); try { XmlDocument xmlDocument; // // Check if an XML equipment configuration string is specified // if (xmlEquipmentConfig != null) { // // Load the equipment configuration from an XML string // xmlDocument = XmlUtilities.GetXmlDocument(xmlEquipmentConfig); } else { // // Check if an XML equipment configuration filename is specified // if (equipmentConfigFilename == null) { // // Get equipment configuration filename from Application's configuration file // this.filename = Utilities.GetAppSetting(Consts.STRCFG_XmlEquipmentConfigFilename); this.filename = Path.Combine(this.rootFilePath, this.filename); } else { // Prepend full file path this.filename = Path.Combine(this.rootFilePath, equipmentConfigFilename); } Logfile.Write(STRLOG_Filename + this.filename); // Load the equipment configuration from the specified file xmlDocument = XmlUtilities.GetXmlDocumentFromFile(this.filename); } // // Get the equipment configuration XML node and save a copy // XmlNode xmlNode = XmlUtilities.GetXmlRootNode(xmlDocument, Consts.STRXML_equipmentConfig); this.xmlNodeEquipmentConfig = xmlNode.Clone(); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw; } Logfile.Write(STRLOG_ParsingEquipmentConfig); // // Get information from the equipment configuration node // this.title = XmlUtilities.GetXmlValue(this.xmlNodeEquipmentConfig, Consts.STRXMLPARAM_title, false); this.version = XmlUtilities.GetXmlValue(this.xmlNodeEquipmentConfig, Consts.STRXMLPARAM_version, false); Logfile.Write(STRLOG_Title + this.title); Logfile.Write(STRLOG_Version + this.version); // // Get powerup delay, may not be specified // try { this.powerupDelay = XmlUtilities.GetIntValue(this.xmlNodeEquipmentConfig, Consts.STRXML_powerupDelay); if (this.powerupDelay < 0) { throw new ArgumentException(STRERR_NumberIsNegative); } } catch (ArgumentNullException) { Logfile.Write(STRLOG_PowerupDelayNotSpecified); // Powerup delay is not specified, set default powerup delay this.powerupDelay = DEFAULT_DelayPowerup; } catch (FormatException) { // Value cannot be converted throw new ArgumentException(STRERR_NumberIsInvalid, Consts.STRXML_powerupDelay); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw new ArgumentException(ex.Message, Consts.STRXML_powerupDelay); } this.slPowerupTimeRemaining = this.powerupDelay; // // Get powerdown timeout, may not be specified // try { this.powerdownTimeout = XmlUtilities.GetIntValue(this.xmlNodeEquipmentConfig, Consts.STRXML_powerdownTimeout); if (this.powerdownTimeout < 0) { // Value cannot be negative throw new Exception(STRERR_NumberIsNegative); } // // Powerdown timeout is specified so enable powerdown // this.powerdownEnabled = true; this.poweroffDelay = MIN_DelayPoweroff; } catch (ArgumentNullException) { Logfile.Write(STRLOG_PowerdownTimeoutNotSpecified); // // Powerdown timeout is not specified, disable powerdown // this.powerdownEnabled = false; this.poweroffDelay = 0; } catch (FormatException) { // Value cannot be converted throw new ArgumentException(STRERR_NumberIsInvalid, Consts.STRXML_powerdownTimeout); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw new ArgumentException(ex.Message, Consts.STRXML_powerdownTimeout); } this.slPowerdownTimeRemaining = this.powerdownTimeout; // // Log details // string logMessage = STRLOG_PowerupDelay + this.powerupDelay.ToString() + STRLOG_Seconds; if (this.powerdownEnabled == true) { logMessage += Logfile.STRLOG_Spacer + STRLOG_PowerdownTimeout + this.PowerdownTimeout.ToString() + STRLOG_Seconds + Logfile.STRLOG_Spacer + STRLOG_PoweroffDelay + this.PoweroffDelay + STRLOG_Seconds; } else { logMessage += Logfile.STRLOG_Spacer + STRLOG_PowerdownDisabled; } Logfile.Write(logMessage); try { // // Create thread objects // this.executeCommandLock = new Object(); if (this.executeCommandLock == null) { throw new ArgumentNullException(STRERR_executeCommandLock); } this.signalCommand = new Object(); if (this.signalCommand == null) { throw new ArgumentNullException(STRERR_signalCommand); } this.signalResult = new Object(); if (this.signalResult == null) { throw new ArgumentNullException(STRERR_signalResult); } this.statusLock = new Object(); if (this.statusLock == null) { throw new ArgumentNullException(STRERR_statusLock); } this.threadLabEquipmentEngine = new Thread(new ThreadStart(LabEquipmentEngineThread)); if (this.threadLabEquipmentEngine == null) { throw new ArgumentNullException(STRERR_threadLabEquipmentEngine); } // // Don't start the thread yet, the method Start() must be called to start the thread // after the derived class has completed its initialisation. // this.slOnline = true; this.slPowerupInitialiseStartTime = DateTime.Now; } catch (Exception ex) { // Log the message and throw the exception back to the caller Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//---------------------------------------------------------------------------------------// public SerialLcd(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "SerialLcd"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.disposed = true; this.initialised = false; this.lastError = null; this.reportRunning = false; this.captureData = -1; this.lcdKey = LCDKey.None; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Get initialisation delay // XmlNode xmlNodeSerialLcd = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_serialLcd); try { this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodeSerialLcd, 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); } // // Get WriteLine() time // try { this.writeLineTime = XmlUtilities.GetRealValue(xmlNodeSerialLcd, Consts.STRXML_writeLineTime, 0.0); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw new ArgumentException(ex.Message, Consts.STRXML_writeLineTime); } // // Create the receive and report objects // this.receiveDataInfo = new ReceiveDataInfo(); this.reportQueue = new Queue<LCDPacket>(); this.reportSignal = new Object(); this.responseSignal = new Object(); Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public DCDrive(XmlNode xmlNodeEquipmentConfig, DriverMachine.KeepAliveCallback keepAliveCallback) { const string STRLOG_MethodName = "DCDrive"; Logfile.WriteCalled(null, STRLOG_MethodName); try { // // Initialise local variables // this.keepAliveCallback = keepAliveCallback; this.initialised = false; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; this.lastError = null; this.connectionOpen = false; this.speedSetpoint = 0; // // Get the IP address and port number to use // XmlNode xmlNodeDCdrive = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_dcDrive); XmlNode xmlNodeNetwork = XmlUtilities.GetXmlNode(xmlNodeDCdrive, Consts.STRXML_network, false); this.ipaddr = XmlUtilities.GetXmlValue(xmlNodeNetwork, Consts.STRXML_ipAddr, false); IPAddress ipaddr = IPAddress.Parse(this.ipaddr); this.ipport = XmlUtilities.GetIntValue(xmlNodeNetwork, Consts.STRXML_ipPort); Logfile.Write(STRLOG_IPaddr + this.ipaddr.ToString() + Logfile.STRLOG_Spacer + STRLOG_IPport + this.ipport.ToString()); // // Get the network timeouts // XmlNode xmlNodeTimeouts = XmlUtilities.GetXmlNode(xmlNodeNetwork, Consts.STRXML_timeouts, false); this.receiveTimeout = XmlUtilities.GetIntValue(xmlNodeTimeouts, Consts.STRXML_receive); Logfile.Write(STRLOG_ReceiveTimout + this.receiveTimeout.ToString() + STRLOG_MilliSecs); // // Get Modbus slave identity // XmlNode xmlNodeModbus = XmlUtilities.GetXmlNode(xmlNodeDCdrive, Consts.STRXML_modbus, false); this.slaveId = XmlUtilities.GetIntValue(xmlNodeModbus, Consts.STRXML_slaveId); Logfile.Write(STRLOG_ModbusSlaveId + this.slaveId.ToString()); // // Get the flag to determine if equipment initialisation is required // this.doInitialise = XmlUtilities.GetBoolValue(xmlNodeDCdrive, Consts.STRXML_doInitialise, false); Logfile.Write(STRLOG_DoInitialise + this.doInitialise.ToString()); // // Get the time it takes to initialise // this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodeDCdrive, Consts.STRXML_initialiseDelay); // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); } catch (Exception ex) { // // Log the message and throw the exception back to the caller // Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public DCDrive(XmlNode xmlNodeEquipmentConfig, DriverMachine.KeepAliveCallback keepAliveCallback) { const string STRLOG_MethodName = "DCDrive"; Logfile.WriteCalled(null, STRLOG_MethodName); try { // // Initialise local variables // this.keepAliveCallback = keepAliveCallback; this.initialised = false; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; this.lastError = null; this.connectionOpen = false; this.speedSetpoint = 0; // // Get the IP address and port number to use // XmlNode xmlNodeDCdrive = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_dcDrive); XmlNode xmlNodeNetwork = XmlUtilities.GetXmlNode(xmlNodeDCdrive, Consts.STRXML_network, false); this.ipaddr = XmlUtilities.GetXmlValue(xmlNodeNetwork, Consts.STRXML_ipAddr, false); IPAddress ipaddr = IPAddress.Parse(this.ipaddr); this.ipport = XmlUtilities.GetIntValue(xmlNodeNetwork, Consts.STRXML_ipPort); Logfile.Write(STRLOG_IPaddr + this.ipaddr.ToString() + Logfile.STRLOG_Spacer + STRLOG_IPport + this.ipport.ToString()); // // Get the network timeouts // XmlNode xmlNodeTimeouts = XmlUtilities.GetXmlNode(xmlNodeNetwork, Consts.STRXML_timeouts, false); this.receiveTimeout = XmlUtilities.GetIntValue(xmlNodeTimeouts, Consts.STRXML_receive); Logfile.Write(STRLOG_ReceiveTimout + this.receiveTimeout.ToString() + STRLOG_MilliSecs); // // Get Modbus slave identity // XmlNode xmlNodeModbus = XmlUtilities.GetXmlNode(xmlNodeDCdrive, Consts.STRXML_modbus, false); this.slaveId = XmlUtilities.GetIntValue(xmlNodeModbus, Consts.STRXML_slaveId); Logfile.Write(STRLOG_ModbusSlaveId + this.slaveId.ToString()); // // Get the flag to determine if equipment initialisation is required // this.doInitialise = XmlUtilities.GetBoolValue(xmlNodeDCdrive, Consts.STRXML_doInitialise, false); Logfile.Write(STRLOG_DoInitialise + this.doInitialise.ToString()); // // Get the time it takes to initialise // this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodeDCdrive, Consts.STRXML_initialiseDelay); // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); } catch (Exception ex) { // // Log the message and throw the exception back to the caller // Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public ST360Counter(XmlNode xmlNodeEquipmentConfig) { const string STRLOG_MethodName = "ST360Counter"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Initialise local variables // this.disposed = true; this.initialised = false; this.lastError = null; this.configured = false; // // Initialise properties // this.online = false; this.statusMessage = STRLOG_NotInitialised; // // Determine the logging level for this class // try { this.logLevel = (Logfile.LoggingLevels)Utilities.GetIntAppSetting(STRLOG_ClassName); } catch { this.logLevel = Logfile.LoggingLevels.Minimum; } Logfile.Write(Logfile.STRLOG_LogLevel + this.logLevel.ToString()); // // Get initialisation delay // XmlNode xmlNodeST360Counter = XmlUtilities.GetXmlNode(xmlNodeEquipmentConfig, Consts.STRXML_st360Counter); try { this.initialiseDelay = XmlUtilities.GetIntValue(xmlNodeST360Counter, 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); } // // Get Geiger tube voltage from application's configuration file // this.geigerTubeVoltage = XmlUtilities.GetIntValue(xmlNodeST360Counter, Consts.STRXML_voltage, DEFAULT_HighVoltage); // // Make sure that the high voltage is within range // if (this.geigerTubeVoltage < MIN_HighVoltage) { this.geigerTubeVoltage = MIN_HighVoltage; } else if (this.geigerTubeVoltage > MAX_HighVoltage) { this.geigerTubeVoltage = MAX_HighVoltage; } Logfile.Write(STRLOG_HighVoltage + this.geigerTubeVoltage.ToString()); // // Get speaker volume from application's configuration file // this.speakerVolume = XmlUtilities.GetIntValue(xmlNodeST360Counter, Consts.STRXML_volume, MIN_SpeakerVolume); // // Make sure that the speaker volume is within range // if (this.speakerVolume < MIN_SpeakerVolume) { this.speakerVolume = MIN_SpeakerVolume; } else if (this.speakerVolume > MAX_SpeakerVolume) { this.speakerVolume = MAX_SpeakerVolume; } Logfile.Write(STRLOG_SpeakerVolume + this.speakerVolume.ToString()); // // Get capture time adjustment: y = Mx + C // XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlNodeST360Counter, Consts.STRXML_timeAdjustment, false); string capture = XmlUtilities.GetXmlValue(xmlNode, Consts.STRXML_capture, false); string[] strSplit = capture.Split(new char[] { Engine.Consts.CHR_CsvSplitterChar }); this.timeAdjustmentCapture = new double[strSplit.Length]; for (int i = 0; i < strSplit.Length; i++) { this.timeAdjustmentCapture[i] = Double.Parse(strSplit[i]); } // // Create the receive objects // this.receiveDataInfo = new ReceiveDataInfo(); this.responseSignal = new Object(); Logfile.WriteCompleted(null, STRLOG_MethodName); }