Ejemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------//
        public Specification(Configuration configuration, EquipmentService equipmentServiceProxy)
            : base(configuration, equipmentServiceProxy)
        {
            const string STRLOG_MethodName = "Specification";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Save these for use by the Parse() method
            //
            this.configuration = configuration;

            //
            // Check that the specification template is valid. This is used by the LabClient to submit
            // the experiment specification to the LabServer for execution.
            //
            try
            {
                //
                // Check that all required XML nodes exist
                //
                //
                // Nothing to do here
                //
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------------------------//
        public DriverNetwork(EquipmentService equipmentServiceProxy, Configuration configuration, CancelExperiment cancelExperiment)
            : base(equipmentServiceProxy, configuration, cancelExperiment)
        {
            const string STRLOG_MethodName = "DriverNetwork";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // YOUR CODE HERE
            //

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //---------------------------------------------------------------------------------------//
        public DriverAbsorbers(EquipmentService equipmentServiceProxy, Configuration configuration, CancelExperiment cancelExperiment)
            : base(equipmentServiceProxy, configuration, cancelExperiment)
        {
            const string STRLOG_MethodName = "DriverAbsorbers";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Nothing to do here
            //

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
Ejemplo n.º 4
0
        //---------------------------------------------------------------------------------------//
        public DriverNoLoad(EquipmentService equipmentServiceProxy, Configuration configuration, CancelExperiment cancelExperiment)
            : base(equipmentServiceProxy, configuration, cancelExperiment)
        {
            const string STRLOG_MethodName = "DriverNoLoad";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Save for use by this driver
            //
            this.measurementCount = configuration.MeasurementCount;

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------------------------------//
        public Specification(Configuration configuration, EquipmentService equipmentServiceProxy)
            : base(configuration, equipmentServiceProxy)
        {
            const string STRLOG_MethodName = "Specification";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Save these for use by the Parse() method
            //
            this.configuration = configuration;

            //
            // Check that the specification template is valid. This is used by the LabClient to submit
            // the experiment specification to the LabServer for execution.
            //
            try
            {
                //
                // Check that all required XML nodes exist
                //
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_speedMin, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_speedMax, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_speedStep, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_fieldMin, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_fieldMax, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_fieldStep, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_loadMin, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_loadMax, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_loadStep, true);

                //
                // Create an instance fo the Validation class
                //
                this.validation = new Validation(configuration);
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//
        public ExperimentSpecification(LabConfiguration labConfiguration, EquipmentService equipmentServiceProxy)
        {
            const string STRLOG_MethodName = "ExperimentSpecification";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Save these for use by the Parse() method
            //
            this.labConfiguration = labConfiguration;
            this.equipmentServiceProxy = equipmentServiceProxy;

            try
            {
                //
                // Load XML specification string from the lab configuration and save a copy of the XML node
                //
                XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(labConfiguration.XmlSpecification);
                XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, Consts.STRXML_experimentSpecification);
                this.xmlNodeSpecification = xmlRootNode.Clone();

                //
                // Check that all required XML specification nodes exist
                //
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_setupId, true);

                //
                // Load XML configuration string from the lab configuration and save a copy of the XML node
                //
                xmlDocument = XmlUtilities.GetXmlDocument(labConfiguration.XmlConfiguration);
                xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, Consts.STRXML_configuration);
                this.xmlNodeConfiguration = xmlRootNode.Clone();
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
Ejemplo n.º 7
0
 //---------------------------------------------------------------------------------------//
 public DriverNoLoad(EquipmentService equipmentServiceProxy, Configuration configuration)
     : this(equipmentServiceProxy, configuration, null)
 {
 }
        //-------------------------------------------------------------------------------------------------//
        public LabExperimentEngine(int unitId, AppData appData)
        {
            const string STRLOG_MethodName = "LabExperimentEngine";

            string logMessage = STRLOG_unitId + unitId.ToString();

            Logfile.WriteCalled(null, STRLOG_MethodName, logMessage);

            //
            // Initialise local variables
            //
            this.disposed = true;
            this.unitId = unitId;
            this.labExperimentInfo = null;

            //
            // Initialise private properties
            //
            this.slRunning = false;

            try
            {
                //
                // Initialise local variables from application data
                //
                if (appData == null)
                {
                    throw new ArgumentNullException(STRERR_appData);
                }

                this.allowedServiceBrokers = appData.allowedServiceBrokers;
                if (this.allowedServiceBrokers == null)
                {
                    throw new ArgumentNullException(STRERR_allowedServiceBrokers);
                }

                this.experimentQueue = appData.experimentQueue;
                if (this.experimentQueue == null)
                {
                    throw new ArgumentNullException(STRERR_experimentQueue);
                }

                this.experimentResults = appData.experimentResults;
                if (this.experimentResults == null)
                {
                    throw new ArgumentNullException(STRERR_experimentResults);
                }

                this.experimentStatistics = appData.experimentStatistics;
                if (this.experimentStatistics == null)
                {
                    throw new ArgumentNullException(STRERR_experimentStatistics);
                }

                this.labConfiguration = appData.labConfiguration;
                if (this.labConfiguration == null)
                {
                    throw new ArgumentNullException(STRERR_labConfiguration);
                }

                this.signalCompleted = appData.signalCompleted;
                if (this.signalCompleted == null)
                {
                    throw new ArgumentNullException(STRERR_signalCompleted);
                }

                //
                // Try to get a proxy to the equipment service, it may not exist
                //
                this.equipmentServiceProxy = null;
                this.equipmentServiceAPI = null;
                try
                {
                    this.equipmentServiceAPI = new EquipmentServiceAPI(this.unitId);
                    this.equipmentServiceProxy = this.equipmentServiceAPI.EquipmentServiceProxy;
                    if (this.equipmentServiceProxy != null)
                    {
                        this.equipmentServiceProxy.GetTimeUntilReady();
                    }
                }
                catch
                {
                    // No equipment service available
                }

                //
                // Save email addresses for experiment completion notification
                //
                this.emailAddressLabServer = appData.emailAddressLabServer;
                this.emailAddressesExperimentCompleted = appData.emailAddressesExperimentCompleted;
                this.emailAddressesExperimentFailed = appData.emailAddressesExperimentFailed;

                //
                // Create thread objects
                //
                this.statusLock = new Object();
                if (this.statusLock == null)
                {
                    throw new ArgumentNullException(STRERR_statusLock);
                }
                this.threadLabExperimentEngine = new Thread(new ThreadStart(LabExperimentEngineThread));
                if (this.threadLabExperimentEngine == null)
                {
                    throw new ArgumentNullException(STRERR_threadLabExperimentEngine);
                }

                //
                // Don't start the thread yet, the method Start() must be called to start the thread
                // after the derived class has completed its initialisation.
                //
                Logfile.Write(STRLOG_LabExperimentEngineIsReady + STRLOG_unitId + this.unitId.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 DriverVoltageVsField(EquipmentService equipmentServiceProxy, Configuration configuration)
     : this(equipmentServiceProxy, configuration, null)
 {
 }
 //---------------------------------------------------------------------------------------//
 public DriverSynchronousSpeed(EquipmentService equipmentServiceProxy, Configuration configuration)
     : this(equipmentServiceProxy, configuration, null)
 {
 }
 //---------------------------------------------------------------------------------------//
 public DriverAbsorbers(EquipmentService equipmentServiceProxy, Configuration configuration)
     : this(equipmentServiceProxy, configuration, null)
 {
 }
 //---------------------------------------------------------------------------------------//
 public DriverRadioactivity(EquipmentService equipmentServiceProxy, Configuration configuration)
     : this(equipmentServiceProxy, configuration, null)
 {
 }
 //-------------------------------------------------------------------------------------------------//
 public DriverEquipmentGeneric(EquipmentService equipmentServiceProxy, LabConfiguration labConfiguration, CancelExperiment cancelExperiment)
 {
     this.equipmentServiceProxy = equipmentServiceProxy;
     this.labConfiguration = labConfiguration;
     this.cancelExperiment = cancelExperiment;
 }
 //---------------------------------------------------------------------------------------//
 public DriverEquipmentGeneric(EquipmentService equipmentServiceProxy, LabConfiguration labConfiguration)
     : this(equipmentServiceProxy, labConfiguration, null)
 {
 }
 //---------------------------------------------------------------------------------------//
 public DriverSpeedVsVoltage(EquipmentService equipmentServiceProxy, Configuration configuration)
     : this(equipmentServiceProxy, configuration, null)
 {
 }
        //---------------------------------------------------------------------------------------//

        public EquipmentServiceAPI(int unitId)
        {
            const string STRLOG_MethodName = "EquipmentServiceAPI";

            string logMessage = STRLOG_UnitId + unitId.ToString();

            Logfile.WriteCalled(null, STRLOG_MethodName, logMessage);

            try
            {
                //
                // Get the equipment service values from the Application's configuration file
                //
                string[] equipmentServices = null;
                try
                {
                    equipmentServices = Utilities.GetAppSettings(Consts.STRCFG_EquipmentService);
                }
                catch
                {
                }
                if (equipmentServices == null || equipmentServices.Length == 0)
                {
                    //
                    // No equipment services specified, but that's ok because this LabServer may not use any
                    //
                    Logfile.Write(STRLOG_NoEquipmentServicesSpecified);
                }
                else
                {
                    if (unitId >= equipmentServices.Length)
                    {
                        throw new ArgumentException(STRERR_EquipmentServiceNotSpecifiedForUnit + unitId.ToString());
                    }

                    //
                    // Split the equipment service CSV string into its parts
                    //
                    string[] strSplit = equipmentServices[unitId].Split(new char[] { Consts.CHR_CsvSplitterChar });
                    if (strSplit.Length != (int)CsvFields.Length)
                    {
                        throw new FormatException(STRERR_CsvStringFieldCount);
                    }

                    //
                    // Get the equipment service URL
                    //
                    string equipmentServiceUrl = strSplit[(int)CsvFields.EquipmentServiceUrl].Trim();
                    if (equipmentServiceUrl.Length == 0)
                    {
                        throw new ArgumentNullException(CsvFields.EquipmentServiceUrl.ToString(), STRERR_CsvStringEmptyField);
                    }

                    //
                    // Get the equipment service passkey
                    //
                    string equipmentServicePasskey = strSplit[(int)CsvFields.EquipmentServicePasskey].Trim();
                    if (equipmentServicePasskey.Length == 0)
                    {
                        throw new ArgumentNullException(CsvFields.EquipmentServicePasskey.ToString(), STRERR_CsvStringEmptyField);
                    }

                    // Get LabServer identifier
                    string labServerGuid = Utilities.GetAppSetting(Consts.STRCFG_LabServerGuid);

                    //
                    // Create equipment service interface
                    //
                    this.equipmentServiceProxy     = new EquipmentService();
                    this.equipmentServiceProxy.Url = equipmentServiceUrl;
                    Logfile.Write(STRLOG_Url + this.equipmentServiceProxy.Url);

                    //
                    // Create and fill in authorisation information
                    //
                    AuthHeader authHeader = new AuthHeader();
                    authHeader.identifier = labServerGuid;
                    authHeader.passKey    = equipmentServicePasskey;
                    this.equipmentServiceProxy.AuthHeaderValue = authHeader;
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //---------------------------------------------------------------------------------------//
        public EquipmentServiceAPI(int unitId)
        {
            const string STRLOG_MethodName = "EquipmentServiceAPI";

            string logMessage = STRLOG_UnitId + unitId.ToString();

            Logfile.WriteCalled(null, STRLOG_MethodName, logMessage);

            try
            {
                //
                // Get the equipment service values from the Application's configuration file
                //
                string[] equipmentServices = null;
                try
                {
                    equipmentServices = Utilities.GetAppSettings(Consts.STRCFG_EquipmentService);
                }
                catch
                {
                }
                if (equipmentServices == null || equipmentServices.Length == 0)
                {
                    //
                    // No equipment services specified, but that's ok because this LabServer may not use any
                    //
                    Logfile.Write(STRLOG_NoEquipmentServicesSpecified);
                }
                else
                {
                    if (unitId >= equipmentServices.Length)
                    {
                        throw new ArgumentException(STRERR_EquipmentServiceNotSpecifiedForUnit + unitId.ToString());
                    }

                    //
                    // Split the equipment service CSV string into its parts
                    //
                    string[] strSplit = equipmentServices[unitId].Split(new char[] { Consts.CHR_CsvSplitterChar });
                    if (strSplit.Length != (int)CsvFields.Length)
                    {
                        throw new FormatException(STRERR_CsvStringFieldCount);
                    }

                    //
                    // Get the equipment service URL
                    //
                    string equipmentServiceUrl = strSplit[(int)CsvFields.EquipmentServiceUrl].Trim();
                    if (equipmentServiceUrl.Length == 0)
                    {
                        throw new ArgumentNullException(CsvFields.EquipmentServiceUrl.ToString(), STRERR_CsvStringEmptyField);
                    }

                    //
                    // Get the equipment service passkey
                    //
                    string equipmentServicePasskey = strSplit[(int)CsvFields.EquipmentServicePasskey].Trim();
                    if (equipmentServicePasskey.Length == 0)
                    {
                        throw new ArgumentNullException(CsvFields.EquipmentServicePasskey.ToString(), STRERR_CsvStringEmptyField);
                    }

                    // Get LabServer identifier
                    string labServerGuid = Utilities.GetAppSetting(Consts.STRCFG_LabServerGuid);

                    //
                    // Create equipment service interface
                    //
                    this.equipmentServiceProxy = new EquipmentService();
                    this.equipmentServiceProxy.Url = equipmentServiceUrl;
                    Logfile.Write(STRLOG_Url + this.equipmentServiceProxy.Url);

                    //
                    // Create and fill in authorisation information
                    //
                    AuthHeader authHeader = new AuthHeader();
                    authHeader.identifier = labServerGuid;
                    authHeader.passKey = equipmentServicePasskey;
                    this.equipmentServiceProxy.AuthHeaderValue = authHeader;
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
 //---------------------------------------------------------------------------------------//
 public DriverLockedRotor(EquipmentService equipmentServiceProxy, Configuration configuration)
     : this(equipmentServiceProxy, configuration, null)
 {
 }