Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------//

        public override ExecuteCommandInfo ProcessCommand(ExecuteCommandInfo executeCommandInfo)
        {
            const string STRLOG_MethodName = "ProcessCommand";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            CommandInfo commandInfo = (CommandInfo)executeCommandInfo;

            bool   success      = true;
            string errorMessage = null;

            try
            {
                //
                // Process the execute command
                //
                ExecuteCommands executeCommand = (ExecuteCommands)commandInfo.command;

                switch (executeCommand)
                {
                //
                // YOUR CODE HERE
                //
                case ExecuteCommands.DoSomething:
                    // Remove this command in your implementation
                    break;

                default:

                    //
                    // Unknown command
                    //
                    errorMessage = STRERR_UnknownCommand + executeCommand.ToString();
                    success      = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                success      = false;
                errorMessage = ex.Message;
            }

            //
            // Update success of command execution
            //
            executeCommandInfo.success = success;

            string logMessage = STRLOG_Success + success.ToString();

            if (success == false)
            {
                executeCommandInfo.errorMessage = errorMessage;
                logMessage += Logfile.STRLOG_Spacer + STRLOG_ErrorMessage + errorMessage;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(executeCommandInfo);
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------------------------------//

        public override string ExecuteXmlRequest(string xmlRequest)
        {
            string strXmlResponse = string.Empty;

            const string STRLOG_MethodName = "ExecuteXmlRequest";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            EquipmentEngine equipmentEngine = (EquipmentEngine)this.labEquipmentEngine;

            try
            {
                bool        success      = true;
                string      errorMessage = string.Empty;
                CommandInfo commandInfo  = null;
                CommandInfo resultInfo   = null;

                //
                // Create the XML response
                //
                XmlDocument xmlResponseDocument = new XmlDocument();
                XmlElement  xmlElement          = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_Response);
                xmlResponseDocument.AppendChild(xmlElement);

                //
                // Add success of command execution and update later
                //
                xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspSuccess);
                xmlElement.InnerText = success.ToString();
                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);

                //
                // Parse XML request for the command
                //
                XmlDocument xmlRequestDocument = new XmlDocument();
                xmlRequestDocument.LoadXml(xmlRequest);
                XmlNode xmlRequestNode = XmlUtilities.GetXmlRootNode(xmlRequestDocument, Engine.Consts.STRXML_Request);
                string  strCommand     = XmlUtilities.GetXmlValue(xmlRequestNode, Engine.Consts.STRXML_Command, false);

                NonExecuteCommands nonExecuteCommand = (NonExecuteCommands)(-1);
                ExecuteCommands    executeCommand    = (ExecuteCommands)(-1);
                try
                {
                    //
                    // Try to convert to a non-execute command type that doesn't require powerdown to be suspended
                    //
                    nonExecuteCommand = (NonExecuteCommands)Enum.Parse(typeof(NonExecuteCommands), strCommand);
                    Logfile.Write(STRLOG_Command + nonExecuteCommand.ToString());
                }
                catch
                {
                    try
                    {
                        //
                        // Try to convert to an execute command type that does require powerdown to be suspended
                        //
                        executeCommand = (ExecuteCommands)Enum.Parse(typeof(ExecuteCommands), strCommand);
                        Logfile.Write(STRLOG_Command + executeCommand.ToString());

                        //
                        // Check that powerdown has been suspended before executing the command
                        //
                        if (this.labEquipmentEngine.IsPowerdownSuspended == false)
                        {
                            //
                            // Suspend the powerdown before executing the command
                            //
                            this.labEquipmentEngine.SuspendPowerdown();
                        }
                    }
                    catch
                    {
                        //
                        // Unknown command
                        //
                        success      = false;
                        errorMessage = STRERR_UnknownCommand + strCommand;
                    }
                }

                if (success == true && nonExecuteCommand != (NonExecuteCommands)(-1))
                {
                    //
                    // Process the non-execute command
                    //
                    switch (nonExecuteCommand)
                    {
                    case NonExecuteCommands.GetTimeToDoSomething:
                        // Remove this command in your implementation
                        break;
                    }
                }
                else if (success == true && executeCommand != (ExecuteCommands)(-1))
                {
                    //
                    // Only one execute command allowed at a time
                    //
                    lock (this.managerLock)
                    {
                        //
                        // Create an instance of the command info ready to fill in
                        //
                        commandInfo = new CommandInfo(executeCommand);

                        //
                        // Process the execute command
                        //
                        switch (executeCommand)
                        {
                        case ExecuteCommands.DoSomething:
                            // Remove this command in your implementation
                            break;
                        }

                        success      = resultInfo.success;
                        errorMessage = resultInfo.errorMessage;
                    }
                }

                //
                // Update success of command execution
                //
                XmlNode xmlResponseNode = XmlUtilities.GetXmlRootNode(xmlResponseDocument, Engine.Consts.STRXML_Response);
                XmlUtilities.SetXmlValue(xmlResponseNode, Engine.Consts.STRXML_RspSuccess, success.ToString(), false);
                if (success == false)
                {
                    //
                    // Create error response
                    //
                    xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspErrorMessage);
                    xmlElement.InnerText = errorMessage;
                    xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                }
                strXmlResponse = xmlResponseDocument.InnerXml;
            }
            catch (ArgumentException)
            {
                //
                // Unknown command so pass to base class to process
                //
                strXmlResponse = base.ExecuteXmlRequest(xmlRequest);
            }
            catch (Exception ex)
            {
                Logfile.Write(ex.Message);
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return(strXmlResponse);
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------------------------------------------//

        public override string ExecuteXmlRequest(string xmlRequest)
        {
            string strXmlResponse = string.Empty;

            const string STRLOG_MethodName = "ExecuteXmlRequest";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            EquipmentEngine equipmentEngine = (EquipmentEngine)this.labEquipmentEngine;

            try
            {
                bool        success      = true;
                string      errorMessage = string.Empty;
                CommandInfo commandInfo  = null;
                CommandInfo resultInfo   = null;

                //
                // Create the XML response
                //
                XmlDocument xmlResponseDocument = new XmlDocument();
                XmlElement  xmlElement          = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_Response);
                xmlResponseDocument.AppendChild(xmlElement);

                //
                // Add success of command execution and update later
                //
                xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspSuccess);
                xmlElement.InnerText = success.ToString();
                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);

                //
                // Parse XML request for the command
                //
                XmlDocument xmlRequestDocument = new XmlDocument();
                xmlRequestDocument.LoadXml(xmlRequest);
                XmlNode xmlRequestNode = XmlUtilities.GetXmlRootNode(xmlRequestDocument, Engine.Consts.STRXML_Request);
                string  strCommand     = XmlUtilities.GetXmlValue(xmlRequestNode, Engine.Consts.STRXML_Command, false);

                NonExecuteCommands nonExecuteCommand = (NonExecuteCommands)(-1);
                ExecuteCommands    executeCommand    = (ExecuteCommands)(-1);
                try
                {
                    //
                    // Try to convert to a non-execute command type that doesn't require powerdown to be suspended
                    //
                    nonExecuteCommand = (NonExecuteCommands)Enum.Parse(typeof(NonExecuteCommands), strCommand);
                    Logfile.Write(STRLOG_Command + nonExecuteCommand.ToString());
                }
                catch
                {
                    try
                    {
                        //
                        // Try to convert to an execute command type that does require powerdown to be suspended
                        //
                        executeCommand = (ExecuteCommands)Enum.Parse(typeof(ExecuteCommands), strCommand);
                        Logfile.Write(STRLOG_Command + executeCommand.ToString());

                        //
                        // Check that powerdown has been suspended before executing the command
                        //
                        if (this.labEquipmentEngine.IsPowerdownSuspended == false)
                        {
                            //
                            // Suspend the powerdown before executing the command
                            //
                            this.labEquipmentEngine.SuspendPowerdown();
                        }
                    }
                    catch
                    {
                        //
                        // Unknown command
                        //
                        success      = false;
                        errorMessage = STRERR_UnknownCommand + strCommand;
                    }
                }

                if (success == true && nonExecuteCommand != (NonExecuteCommands)(-1))
                {
                    //
                    // Process the non-execute command
                    //
                    switch (nonExecuteCommand)
                    {
                    case NonExecuteCommands.GetTubeHomeDistance:

                        //
                        // Get tube home distance
                        //
                        int tubeHomeDistance = equipmentEngine.GetTubeHomeDistance();

                        //
                        // Add tube home distance to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspTubeHomeDistance);
                        xmlElement.InnerText = tubeHomeDistance.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetTubeMoveTime:

                        //
                        // Get distance 'from' and 'to' from request
                        //
                        int distanceFrom = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqTubeDistanceFrom, 0);
                        int distanceTo   = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqTubeDistanceTo, 0);

                        //
                        // Get tube move time
                        //
                        double tubeMoveTime = equipmentEngine.GetTubeMoveTime(distanceFrom, distanceTo);

                        //
                        // Add tube move time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspTubeMoveTime);
                        xmlElement.InnerText = tubeMoveTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetSourceHomeLocation:

                        //
                        // Get source home location
                        //
                        char sourceHomeLocation = equipmentEngine.GetSourceHomeLocation();

                        //
                        // Add source home location to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSourceHomeLocation);
                        xmlElement.InnerText = sourceHomeLocation.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetSourceSelectTime:

                        //
                        // Get source location from request
                        //
                        char sourceLocation = XmlUtilities.GetCharValue(xmlRequestNode, Consts.STRXML_ReqSourceLocation, Char.MinValue);

                        //
                        // Get source select time
                        //
                        double sourceSelectTime = equipmentEngine.GetSourceSelectTime(sourceLocation);

                        //
                        // Add source select time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSourceSelectTime);
                        xmlElement.InnerText = sourceSelectTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetSourceReturnTime:

                        //
                        // Get source location from request
                        //
                        sourceLocation = XmlUtilities.GetCharValue(xmlRequestNode, Consts.STRXML_ReqSourceLocation, Char.MinValue);

                        //
                        // Get source return time
                        //
                        double sourceReturnTime = equipmentEngine.GetSourceReturnTime(sourceLocation);

                        //
                        // Add source return time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSourceReturnTime);
                        xmlElement.InnerText = sourceReturnTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetAbsorberHomeLocation:

                        //
                        // Get absorber home location
                        //
                        char absorberHomeLocation = equipmentEngine.GetAbsorberHomeLocation();

                        //
                        // Add absorber home location to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspAbsorberHomeLocation);
                        xmlElement.InnerText = absorberHomeLocation.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetAbsorberSelectTime:

                        //
                        // Get absorber location from request
                        //
                        char absorberLocation = XmlUtilities.GetCharValue(xmlRequestNode, Consts.STRXML_ReqAbsorberLocation, Char.MinValue);

                        //
                        // Get absorber select time
                        //
                        double absorberSelectTime = equipmentEngine.GetAbsorberSelectTime(absorberLocation);

                        //
                        // Add absorber select time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspAbsorberSelectTime);
                        xmlElement.InnerText = absorberSelectTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetAbsorberReturnTime:

                        //
                        // Get absorber location from request
                        //
                        absorberLocation = XmlUtilities.GetCharValue(xmlRequestNode, Consts.STRXML_ReqAbsorberLocation, Char.MinValue);

                        //
                        // Get absorber return time
                        //
                        double absorberReturnTime = equipmentEngine.GetAbsorberReturnTime(absorberLocation);

                        //
                        // Add absorber return time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspAbsorberReturnTime);
                        xmlElement.InnerText = absorberReturnTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetLcdWriteLineTime:
                        //
                        // Get LCD writeline time
                        //
                        double lcdWriteLineTime = equipmentEngine.GetLcdWriteLineTime();

                        //
                        // Add capture data time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspLcdWriteLineTime);
                        xmlElement.InnerText = lcdWriteLineTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetCaptureDataTime:
                        //
                        // Get duration from request
                        //
                        int duration = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqDuration, 0);

                        //
                        // Get capture data time
                        //
                        double captureDataTime = equipmentEngine.GetCaptureDataTime(duration);

                        //
                        // Add capture data time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspCaptureDataTime);
                        xmlElement.InnerText = captureDataTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;
                    }
                }
                else if (success == true && executeCommand != (ExecuteCommands)(-1))
                {
                    //
                    // Only one execute command allowed at a time
                    //
                    lock (this.managerLock)
                    {
                        //
                        // Create an instance of the command info ready to fill in
                        //
                        commandInfo = new CommandInfo(executeCommand);

                        //
                        // Process the execute command
                        //
                        switch (executeCommand)
                        {
                        case ExecuteCommands.SetTubeDistance:

                            //
                            // Get tube distance from request
                            //
                            int tubeDistance = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqTubeDistance, 0);

                            //
                            // Set tube distance
                            //
                            commandInfo.parameters = new object[] { tubeDistance };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.SetSourceLocation:

                            //
                            // Get source location from request
                            //
                            char sourceLocation = XmlUtilities.GetCharValue(xmlRequestNode, Consts.STRXML_ReqSourceLocation, Char.MinValue);

                            //
                            // Set source location
                            //
                            commandInfo.parameters = new object[] { sourceLocation };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.SetAbsorberLocation:

                            //
                            // Get absorber location from request
                            //
                            char absorberLocation = XmlUtilities.GetCharValue(xmlRequestNode, Consts.STRXML_ReqAbsorberLocation, Char.MinValue);

                            //
                            // Set absorber location
                            //
                            commandInfo.parameters = new object[] { absorberLocation };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.GetCaptureData:

                            //
                            // Get duration from request
                            //
                            int duration = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqDuration, 0);

                            //
                            // Get radiation count
                            //
                            int count = -1;
                            commandInfo.parameters = new object[] { duration };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            if (commandInfo.success == true)
                            {
                                count = (int)commandInfo.results[0];
                            }

                            //
                            // Add radiation count to response
                            //
                            xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspCount);
                            xmlElement.InnerText = count.ToString();
                            xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                            break;

                        case ExecuteCommands.WriteLcdLine:

                            //
                            // Get LCD line number and message from request
                            //
                            int    lcdLineNo  = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqLcdLineNo, 0);
                            string lcdMessage = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_ReqLcdMessage, false);

                            //
                            // Write message to LCD
                            //
                            commandInfo.parameters = new object[] { lcdLineNo, lcdMessage };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;
                        }

                        success      = resultInfo.success;
                        errorMessage = resultInfo.errorMessage;
                    }
                }

                //
                // Update success of command execution
                //
                XmlNode xmlResponseNode = XmlUtilities.GetXmlRootNode(xmlResponseDocument, Engine.Consts.STRXML_Response);
                XmlUtilities.SetXmlValue(xmlResponseNode, Engine.Consts.STRXML_RspSuccess, success.ToString(), false);
                if (success == false)
                {
                    //
                    // Create error response
                    //
                    xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspErrorMessage);
                    xmlElement.InnerText = errorMessage;
                    xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                }
                strXmlResponse = xmlResponseDocument.InnerXml;
            }
            catch (ArgumentException)
            {
                //
                // Unknown command so pass to base class to process
                //
                strXmlResponse = base.ExecuteXmlRequest(xmlRequest);
            }
            catch (Exception ex)
            {
                Logfile.Write(ex.Message);
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return(strXmlResponse);
        }
        //-------------------------------------------------------------------------------------------------//

        public override ExecuteCommandInfo ProcessCommand(ExecuteCommandInfo executeCommandInfo)
        {
            const string STRLOG_MethodName = "ProcessCommand";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            CommandInfo commandInfo = (CommandInfo)executeCommandInfo;

            bool   success      = true;
            string errorMessage = null;

            try
            {
                //
                // Process the execute command
                //
                ExecuteCommands executeCommand = (ExecuteCommands)commandInfo.command;

                switch (executeCommand)
                {
                case ExecuteCommands.SetTubeDistance:

                    //
                    // Set tube distance
                    //
                    int tubeDistance = (int)commandInfo.parameters[0];
                    if ((success = this.flexMotion.SetTubeDistance(tubeDistance)) == false)
                    {
                        errorMessage = this.flexMotion.GetLastError();
                    }
                    break;

                case ExecuteCommands.SetSourceLocation:

                    //
                    // Set source location
                    //
                    char sourceLocation = (char)commandInfo.parameters[0];
                    if ((success = this.flexMotion.SetSourceLocation(sourceLocation)) == false)
                    {
                        errorMessage = this.flexMotion.GetLastError();
                    }
                    break;

                case ExecuteCommands.SetAbsorberLocation:

                    //
                    // Set absorber location
                    //
                    char absorberLocation = (char)commandInfo.parameters[0];
                    if ((success = this.flexMotion.SetAbsorberLocation(absorberLocation)) == false)
                    {
                        errorMessage = this.flexMotion.GetLastError();
                    }
                    break;

                case ExecuteCommands.GetCaptureData:

                    //
                    // Get duration from parameters
                    //
                    int duration = (int)commandInfo.parameters[0];

                    //
                    // Get radiation count
                    //
                    int count = -1;
                    if (this.radiationCounterType == RadiationCounterTypes.ST360)
                    {
                        int[] counts = new int[1];
                        if (this.st360Counter.CaptureData(duration, counts) == true)
                        {
                            count = counts[0];
                        }
                    }
                    else if (this.radiationCounterType == RadiationCounterTypes.Physics)
                    {
                        count = this.physicsCounter.CaptureData(duration);
                    }

                    //
                    // Add radiation count to results
                    //
                    commandInfo.results = new object[] { count };
                    break;

                case ExecuteCommands.WriteLcdLine:

                    //
                    // Get LCD line number from request
                    //
                    int lcdLineNo = (int)commandInfo.parameters[0];

                    //
                    // Get LCD message from request and 'URL Decode' to preserve spaces
                    //
                    string lcdMessage = (string)commandInfo.parameters[1];
                    lcdMessage = HttpUtility.UrlDecode(lcdMessage);

                    //
                    // Write message to LCD
                    //
                    if ((success = this.serialLcd.WriteLine(lcdLineNo, lcdMessage)) == false)
                    {
                        errorMessage = this.serialLcd.GetLastError();
                    }
                    break;

                default:

                    //
                    // Unknown command
                    //
                    errorMessage = STRERR_UnknownCommand + executeCommand.ToString();
                    success      = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                success      = false;
                errorMessage = ex.Message;
            }

            //
            // Update success of command execution
            //
            executeCommandInfo.success = success;

            string logMessage = STRLOG_Success + success.ToString();

            if (success == false)
            {
                executeCommandInfo.errorMessage = errorMessage;
                logMessage += Logfile.STRLOG_Spacer + STRLOG_ErrorMessage + errorMessage;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(executeCommandInfo);
        }
        //-------------------------------------------------------------------------------------------------//

        public virtual string ExecuteXmlRequest(string xmlRequest)
        {
            string strXmlResponse = string.Empty;

            const string STRLOG_MethodName = "ExecuteXmlRequest";

            Logfile.WriteCalled(this.logLevel, STRLOG_ClassName, STRLOG_MethodName);

            try
            {
                bool               success            = true;
                string             errorMessage       = string.Empty;
                ExecuteCommandInfo executeCommandInfo = null;
                ExecuteCommandInfo executeResultInfo  = null;

                //
                // Create the XML response
                //
                XmlDocument xmlResponseDocument = new XmlDocument();
                XmlElement  xmlElement          = xmlResponseDocument.CreateElement(Consts.STRXML_Response);
                xmlResponseDocument.AppendChild(xmlElement);

                //
                // Add success of command execution and update later
                //
                xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSuccess);
                xmlElement.InnerText = success.ToString();
                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);

                //
                // Parse XML request for the command
                //
                XmlDocument xmlRequestDocument = new XmlDocument();
                xmlRequestDocument.LoadXml(xmlRequest);
                XmlNode xmlRequestNode = XmlUtilities.GetXmlRootNode(xmlRequestDocument, Consts.STRXML_Request);
                string  strCommand     = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_Command, false);

                NonExecuteCommands nonExecuteCommand = (NonExecuteCommands)(-1);
                ExecuteCommands    executeCommand    = (ExecuteCommands)(-1);
                try
                {
                    //
                    // Try to convert to a non-execute command type that doesn't require powerdown to be suspended
                    //
                    nonExecuteCommand = (NonExecuteCommands)Enum.Parse(typeof(NonExecuteCommands), strCommand);
                    Logfile.Write(STRLOG_Command + nonExecuteCommand.ToString());
                }
                catch
                {
                    try
                    {
                        //
                        // Try to convert to an execute command type that does require powerdown to be suspended
                        //
                        executeCommand = (ExecuteCommands)Enum.Parse(typeof(ExecuteCommands), strCommand);
                        Logfile.Write(STRLOG_Command + executeCommand.ToString());

                        //
                        // Check that powerdown has been suspended before executing the command
                        //
                        if (this.labEquipmentEngine.IsPowerdownSuspended == false)
                        {
                            //
                            // Unable to execute the command
                            //
                            success      = false;
                            errorMessage = STRERR_PowerdownMustBeSuspended + executeCommand.ToString();
                        }
                    }
                    catch
                    {
                        //
                        // Unknown command
                        //
                        success      = false;
                        errorMessage = STRERR_UnknownCommand + strCommand;
                    }
                }

                if (success == true && nonExecuteCommand != (NonExecuteCommands)(-1))
                {
                    //
                    // Process the non-execute command
                    //
                    switch (nonExecuteCommand)
                    {
                    case NonExecuteCommands.GetTime:

                        //
                        // Add time to response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement("Time");
                        xmlElement.InnerText = DateTime.Now.ToShortTimeString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;
                    }
                }
                else if (success == true && executeCommand != (ExecuteCommands)(-1))
                {
                    //
                    // Only one execute command allowed at a time
                    //
                    lock (this.managerLock)
                    {
                        //
                        // Create an instance of the command info ready to fill in
                        //
                        executeCommandInfo = new ExecuteCommandInfo(executeCommand);

                        //
                        // Process the execute command
                        //
                        switch (executeCommand)
                        {
                        case ExecuteCommands.SetTime:

                            //
                            // Pretend to change the time
                            //
                            executeCommandInfo.parameters = new object[] { DateTime.Now };
                            executeCommandInfo.timeout    = 20;
                            executeResultInfo             = this.labEquipmentEngine.ExecuteCommand(executeCommandInfo);
                            if (executeResultInfo.success == true)
                            {
                                DateTime dateTime = (DateTime)executeCommandInfo.results[0];
                            }
                            break;
                        }
                    }
                }

                //
                // Update success of command execution
                //
                XmlNode xmlResponseNode = XmlUtilities.GetXmlRootNode(xmlResponseDocument, Engine.Consts.STRXML_Response);
                XmlUtilities.SetXmlValue(xmlResponseNode, Engine.Consts.STRXML_RspSuccess, executeResultInfo.success.ToString(), false);
                if (success == false)
                {
                    //
                    // Create error response
                    //
                    xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspErrorMessage);
                    xmlElement.InnerText = executeResultInfo.errorMessage;
                    xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                }
                strXmlResponse = xmlResponseDocument.InnerXml;
            }
            catch (Exception ex)
            {
                Logfile.Write(ex.Message);
            }

            Logfile.WriteCompleted(this.logLevel, STRLOG_ClassName, STRLOG_MethodName);

            return(strXmlResponse);
        }
        //-------------------------------------------------------------------------------------------------//

        public override string ExecuteXmlRequest(string xmlRequest)
        {
            string strXmlResponse = string.Empty;

            const string STRLOG_MethodName = "ExecuteXmlRequest";

            Logfile.WriteCalled(this.logLevel, STRLOG_ClassName, STRLOG_MethodName);

            EquipmentEngine equipmentEngine = (EquipmentEngine)this.labEquipmentEngine;

            try
            {
                bool        success      = true;
                string      errorMessage = string.Empty;
                CommandInfo commandInfo  = null;
                CommandInfo resultInfo   = null;

                //
                // Create the XML response
                //
                XmlDocument xmlResponseDocument = new XmlDocument();
                XmlElement  xmlElement          = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_Response);
                xmlResponseDocument.AppendChild(xmlElement);

                //
                // Add success of command execution and update later
                //
                xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspSuccess);
                xmlElement.InnerText = success.ToString();
                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);

                //
                // Parse XML request for the command
                //
                XmlDocument xmlRequestDocument = new XmlDocument();
                xmlRequestDocument.LoadXml(xmlRequest);
                XmlNode xmlRequestNode = XmlUtilities.GetXmlRootNode(xmlRequestDocument, Engine.Consts.STRXML_Request);
                string  strCommand     = XmlUtilities.GetXmlValue(xmlRequestNode, Engine.Consts.STRXML_Command, false);

                NonExecuteCommands nonExecuteCommand = (NonExecuteCommands)(-1);
                ExecuteCommands    executeCommand    = (ExecuteCommands)(-1);
                try
                {
                    //
                    // Try to convert to a non-execute command type that doesn't require powerdown to be suspended
                    //
                    nonExecuteCommand = (NonExecuteCommands)Enum.Parse(typeof(NonExecuteCommands), strCommand);
                    Logfile.Write(this.logLevel, STRLOG_Command + nonExecuteCommand.ToString());
                }
                catch
                {
                    try
                    {
                        //
                        // Try to convert to an execute command type that does require powerdown to be suspended
                        //
                        executeCommand = (ExecuteCommands)Enum.Parse(typeof(ExecuteCommands), strCommand);
                        Logfile.Write(this.logLevel, STRLOG_Command + executeCommand.ToString());

                        //
                        // Check that powerdown has been suspended before executing the command
                        //
                        if (this.labEquipmentEngine.IsPowerdownSuspended == false)
                        {
                            //
                            // Suspend the powerdown before executing the command
                            //
                            this.labEquipmentEngine.SuspendPowerdown();
                        }
                    }
                    catch
                    {
                        //
                        // Unknown command
                        //
                        success      = false;
                        errorMessage = STRERR_UnknownCommand + strCommand;
                    }
                }

                if (success == true && nonExecuteCommand != (NonExecuteCommands)(-1))
                {
                    //
                    // Process the non-execute command
                    //
                    switch (nonExecuteCommand)
                    {
                    case NonExecuteCommands.GetResetACDriveTime:

                        //
                        // Get the time to reset the AC drive
                        //
                        int resetACDriveTime = equipmentEngine.GetResetACDriveTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspResetACDriveTime);
                        xmlElement.InnerText = resetACDriveTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetConfigureACDriveTime:

                        //
                        // Get the time to configure the AC drive
                        //
                        int configureACDriveTime = equipmentEngine.GetConfigureACDriveTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspConfigureACDriveTime);
                        xmlElement.InnerText = configureACDriveTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetStartACDriveTime:

                        //
                        // Get the time to start the AC drive
                        //
                        int startACDriveTime = equipmentEngine.GetStartACDriveTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspStartACDriveTime);
                        xmlElement.InnerText = startACDriveTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetStopACDriveTime:

                        //
                        // Get the time to stop the AC drive
                        //
                        int stopACDriveTime = equipmentEngine.GetStopACDriveTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspStopACDriveTime);
                        xmlElement.InnerText = stopACDriveTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetResetDCDriveMutTime:

                        //
                        // Get the time to reset the DC drive
                        //
                        int resetDCDriveMutTime = equipmentEngine.GetResetDCDriveMutTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspResetDCDriveMutTime);
                        xmlElement.InnerText = resetDCDriveMutTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetConfigureDCDriveMutTime:

                        //
                        // Get the time to configure the DC drive
                        //
                        int configureDCDriveMutTime = equipmentEngine.GetConfigureDCDriveMutTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspConfigureDCDriveMutTime);
                        xmlElement.InnerText = configureDCDriveMutTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetStartDCDriveMutTime:

                        //
                        // Get DC drive mode from request
                        //
                        string strDCDriveMutMode = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_ReqDCDriveMutMode, false);
                        RedLion.DCDriveMutModes dcDriveMutMode = (RedLion.DCDriveMutModes)Enum.Parse(typeof(RedLion.DCDriveMutModes), strDCDriveMutMode);

                        //
                        // Get the time to start the DC drive for the specified mode
                        //
                        int startDCDriveMutTime = equipmentEngine.GetStartDCDriveMutTime(dcDriveMutMode);

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspStartDCDriveMutTime);
                        xmlElement.InnerText = startDCDriveMutTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetStopDCDriveMutTime:

                        //
                        // Get the time to stop the DC drive
                        //
                        int stopDCDriveMutTime = equipmentEngine.GetStopDCDriveMutTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspStopDCDriveMutTime);
                        xmlElement.InnerText = stopDCDriveMutTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetSetSpeedACDriveTime:

                        //
                        // Get the time to set the speed of the AC drive
                        //
                        int setSpeedACDriveTime = equipmentEngine.GetSetSpeedACDriveTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSetSpeedACDriveTime);
                        xmlElement.InnerText = setSpeedACDriveTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetSetSpeedDCDriveMutTime:

                        //
                        // Get the time to set the speed of the DC drive
                        //
                        int setSpeedDCDriveMutTime = equipmentEngine.GetSetSpeedDCDriveMutTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSetSpeedDCDriveMutTime);
                        xmlElement.InnerText = setSpeedDCDriveMutTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetSetTorqueDCDriveMutTime:

                        //
                        // Get the time to set the torque of the DC drive
                        //
                        int setTorqueDCDriveMutTime = equipmentEngine.GetSetTorqueDCDriveMutTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSetTorqueDCDriveMutTime);
                        xmlElement.InnerText = setTorqueDCDriveMutTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetSetFieldDCDriveMutTime:

                        //
                        // Get the time to set the field of the DC drive
                        //
                        int setFieldDCDriveMutTime = equipmentEngine.GetSetFieldDCDriveMutTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSetFieldDCDriveMutTime);
                        xmlElement.InnerText = setFieldDCDriveMutTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetTakeMeasurementTime:

                        //
                        // Get the time to take a measurement
                        //
                        int takeMeasurementTime = equipmentEngine.GetTakeMeasurementTime();

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspTakeMeasurementTime);
                        xmlElement.InnerText = takeMeasurementTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetACDriveInfo:

                        //
                        // Get the info about the AC drive
                        //
                        RedLion.ACDriveInfo aCDriveInfo = equipmentEngine.GetACDriveInfo();

                        //
                        // Add the info to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspMinSpeed);
                        xmlElement.InnerText = aCDriveInfo.minSpeed.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspMaxSpeed);
                        xmlElement.InnerText = aCDriveInfo.maxSpeed.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetDCDriveMutInfo:

                        //
                        // Get the info about the AC drive
                        //
                        RedLion.DCDriveMutInfo dCDriveMutInfo = equipmentEngine.GetDCDriveMutInfo();

                        //
                        // Add the info to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspMinSpeed);
                        xmlElement.InnerText = dCDriveMutInfo.minSpeed.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspMaxSpeed);
                        xmlElement.InnerText = dCDriveMutInfo.maxSpeed.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspDefaultField);
                        xmlElement.InnerText = dCDriveMutInfo.defaultField.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspDefaultTorque);
                        xmlElement.InnerText = dCDriveMutInfo.defaultTorque.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;
                    }
                }
                else if (success == true && executeCommand != (ExecuteCommands)(-1))
                {
                    //
                    // Only one execute command allowed at a time
                    //
                    lock (this.managerLock)
                    {
                        //
                        // Create an instance of the command info ready to fill in
                        //
                        commandInfo = new CommandInfo(executeCommand);

                        //
                        // Process the execute command
                        //
                        switch (executeCommand)
                        {
                        case ExecuteCommands.CreateConnection:

                            //
                            // Create a connection to the RedLion controller
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.CloseConnection:

                            //
                            // Close the connection to the RedLion controller
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.ResetACDrive:

                            //
                            // Reset the AC drive controller
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.ConfigureACDrive:

                            //
                            // Get AC drive configuration from request
                            //
                            string strACDriveConfig = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_ReqACDriveConfig, false);
                            RedLion.ACDriveConfigs aCDriveConfig = (RedLion.ACDriveConfigs)Enum.Parse(typeof(RedLion.ACDriveConfigs), strACDriveConfig);

                            //
                            // Configure the AC drive with the specified configuration
                            //
                            commandInfo.parameters = new object[] { aCDriveConfig };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.StartACDrive:

                            //
                            // Start the AC drive
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.StopACDrive:

                            //
                            // Stop the AC drive
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.ResetDCDriveMut:

                            //
                            // Reset the DC drive
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.ConfigureDCDriveMut:

                            //
                            // Get DC drive configuration from request
                            //
                            string strDCDriveMutConfig = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_ReqDCDriveMutConfig, false);
                            RedLion.DCDriveMutConfigs dcDriveMutConfig = (RedLion.DCDriveMutConfigs)Enum.Parse(typeof(RedLion.DCDriveMutConfigs), strDCDriveMutConfig);

                            //
                            // Configure the AC drive with the specified configuration
                            //
                            commandInfo.parameters = new object[] { dcDriveMutConfig };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.StartDCDriveMut:

                            //
                            // Get DC drive mode from request
                            //
                            string strDCDriveMutMode = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_ReqDCDriveMutMode, false);
                            RedLion.DCDriveMutModes dcDriveMutMode = (RedLion.DCDriveMutModes)Enum.Parse(typeof(RedLion.DCDriveMutModes), strDCDriveMutMode);

                            //
                            // Start the DC drive
                            //
                            commandInfo.parameters = new object[] { dcDriveMutMode };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.StopDCDriveMut:

                            //
                            // Stop the DC drive
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.SetSpeedACDrive:

                            //
                            // Get speed from request
                            //
                            int speedACDrive = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqSpeedACDrive, 0);

                            //
                            // Set the speed of the AC drive
                            //
                            commandInfo.parameters = new object[] { speedACDrive };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.SetSpeedDCDriveMut:

                            //
                            // Get speed from request
                            //
                            int speedDCDriveMut = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqSpeedDCDriveMut, 0);

                            //
                            // Set the speed of the DC drive
                            //
                            commandInfo.parameters = new object[] { speedDCDriveMut };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.SetTorqueDCDriveMut:

                            //
                            // Get torque from request
                            //
                            int torqueDCDriveMut = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqTorqueDCDriveMut, 0);

                            //
                            // Set the torque of the DC drive
                            //
                            commandInfo.parameters = new object[] { torqueDCDriveMut };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.SetFieldDCDriveMut:

                            //
                            // Get torque from request
                            //
                            int fieldDCDriveMut = XmlUtilities.GetIntValue(xmlRequestNode, Consts.STRXML_ReqFieldDCDriveMut, 100);

                            //
                            // Set the field of the DC drive
                            //
                            commandInfo.parameters = new object[] { fieldDCDriveMut };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;

                        case ExecuteCommands.TakeMeasurement:

                            //
                            // Take a measurement
                            //
                            resultInfo = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            if (commandInfo.success == true)
                            {
                                //
                                // Get measurement values from the result
                                //
                                int   speed        = (int)commandInfo.results[0];
                                int   voltage      = (int)commandInfo.results[1];
                                float fieldCurrent = (float)commandInfo.results[2];
                                int   load         = (int)commandInfo.results[3];

                                //
                                // Add the measurement values to the response
                                //
                                xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspSpeed);
                                xmlElement.InnerText = speed.ToString();
                                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                                xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspVoltage);
                                xmlElement.InnerText = voltage.ToString();
                                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                                xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspFieldCurrent);
                                xmlElement.InnerText = fieldCurrent.ToString();
                                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                                xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspLoad);
                                xmlElement.InnerText = load.ToString();
                                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                            }
                            break;
                        }

                        success      = resultInfo.success;
                        errorMessage = resultInfo.errorMessage;
                    }
                }

                //
                // Update success of command execution
                //
                XmlNode xmlResponseNode = XmlUtilities.GetXmlRootNode(xmlResponseDocument, Engine.Consts.STRXML_Response);
                XmlUtilities.SetXmlValue(xmlResponseNode, Engine.Consts.STRXML_RspSuccess, success.ToString(), false);
                if (success == false)
                {
                    //
                    // Create error response
                    //
                    xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspErrorMessage);
                    xmlElement.InnerText = errorMessage;
                    xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                }
                strXmlResponse = xmlResponseDocument.InnerXml;
            }
            catch (ArgumentException)
            {
                //
                // Unknown command so pass to base class to process
                //
                strXmlResponse = base.ExecuteXmlRequest(xmlRequest);
            }
            catch (Exception ex)
            {
                Logfile.Write(ex.Message);
            }

            Logfile.WriteCompleted(this.logLevel, STRLOG_ClassName, STRLOG_MethodName);

            return(strXmlResponse);
        }
        //-------------------------------------------------------------------------------------------------//

        public override string ExecuteXmlRequest(string xmlRequest)
        {
            string strXmlResponse = string.Empty;

            const string STRLOG_MethodName = "ExecuteXmlRequest";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            EquipmentEngine equipmentEngine = (EquipmentEngine)this.labEquipmentEngine;

            try
            {
                bool        success      = true;
                string      errorMessage = string.Empty;
                CommandInfo commandInfo  = null;
                CommandInfo resultInfo   = null;

                //
                // Create the XML response
                //
                XmlDocument xmlResponseDocument = new XmlDocument();
                XmlElement  xmlElement          = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_Response);
                xmlResponseDocument.AppendChild(xmlElement);

                //
                // Add success of command execution and update later
                //
                xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspSuccess);
                xmlElement.InnerText = success.ToString();
                xmlResponseDocument.DocumentElement.AppendChild(xmlElement);

                //
                // Parse XML request for the command
                //
                XmlDocument xmlRequestDocument = new XmlDocument();
                xmlRequestDocument.LoadXml(xmlRequest);
                XmlNode xmlRequestNode = XmlUtilities.GetXmlRootNode(xmlRequestDocument, Engine.Consts.STRXML_Request);
                string  strCommand     = XmlUtilities.GetXmlValue(xmlRequestNode, Engine.Consts.STRXML_Command, false);

                NonExecuteCommands nonExecuteCommand = (NonExecuteCommands)(-1);
                ExecuteCommands    executeCommand    = (ExecuteCommands)(-1);
                try
                {
                    //
                    // Try to convert to a non-execute command type that doesn't require powerdown to be suspended
                    //
                    nonExecuteCommand = (NonExecuteCommands)Enum.Parse(typeof(NonExecuteCommands), strCommand);
                    Logfile.Write(STRLOG_Command + nonExecuteCommand.ToString());
                }
                catch
                {
                    try
                    {
                        //
                        // Try to convert to an execute command type that does require powerdown to be suspended
                        //
                        executeCommand = (ExecuteCommands)Enum.Parse(typeof(ExecuteCommands), strCommand);
                        Logfile.Write(STRLOG_Command + executeCommand.ToString());

                        //
                        // Check that powerdown has been suspended before executing the command
                        //
                        if (this.labEquipmentEngine.IsPowerdownSuspended == false)
                        {
                            //
                            // Suspend the powerdown before executing the command
                            //
                            this.labEquipmentEngine.SuspendPowerdown();
                        }
                    }
                    catch
                    {
                        //
                        // Unknown command
                        //
                        success      = false;
                        errorMessage = STRERR_UnknownCommand + strCommand;
                    }
                }

                if (success == true && nonExecuteCommand != (NonExecuteCommands)(-1))
                {
                    //
                    // Process the non-execute command
                    //
                    switch (nonExecuteCommand)
                    {
                    case NonExecuteCommands.GetExecutionTime:
                        //
                        // Get specification in XML format from request
                        //
                        string xmlSpecification = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_ReqSpecification, false);

                        //
                        // Get the time to execute the specified setup
                        //
                        int executionTime = equipmentEngine.GetExecutionTime(xmlSpecification);

                        //
                        // Add the time to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspExecutionTime);
                        xmlElement.InnerText = executionTime.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetExecutionStatus:
                        //
                        // Get the execution status
                        //
                        DriverMachine.ExecutionStatus executionStatus = equipmentEngine.GetExecutionStatus();

                        //
                        // Add the execution status to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspExecutionStatus);
                        xmlElement.InnerText = executionStatus.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);

                        //
                        // Get the execution time remaining
                        //
                        int executionTimeRemaining = equipmentEngine.GetExecutionTimeRemaining();

                        //
                        // Add the execution status to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspExecutionTimeRemaining);
                        xmlElement.InnerText = executionTimeRemaining.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetExecutionResultStatus:
                        //
                        // Get the execution result status
                        //
                        DriverMachine.ExecutionStatus executionResultStatus = equipmentEngine.GetExecutionResultStatus();

                        //
                        // Add the execution result status to the response
                        //
                        xmlElement           = xmlResponseDocument.CreateElement(Consts.STRXML_RspExecutionResultStatus);
                        xmlElement.InnerText = executionResultStatus.ToString();
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;

                    case NonExecuteCommands.GetExecutionResults:
                        //
                        // Get the execution results
                        //
                        string executionResults = equipmentEngine.GetExecutionResults();

                        //
                        // Add the execution status to the response
                        //
                        xmlElement          = xmlResponseDocument.CreateElement(Consts.STRXML_RspExecutionResults);
                        xmlElement.InnerXml = executionResults;
                        xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                        break;
                    }
                }
                else if (success == true && executeCommand != (ExecuteCommands)(-1))
                {
                    //
                    // Only one execute command allowed at a time
                    //
                    lock (this.managerLock)
                    {
                        //
                        // Create an instance of the command info ready to fill in
                        //
                        commandInfo = new CommandInfo(executeCommand);

                        //
                        // Process the execute command
                        //
                        switch (executeCommand)
                        {
                        case ExecuteCommands.StartExecution:
                            //
                            // Get specification in XML format from request
                            //
                            string xmlSpecification = XmlUtilities.GetXmlValue(xmlRequestNode, Consts.STRXML_ReqSpecification, false);

                            //
                            // Start execution with the given specification
                            //
                            commandInfo.parameters = new object[] { xmlSpecification };
                            resultInfo             = (CommandInfo)equipmentEngine.ExecuteCommand((ExecuteCommandInfo)commandInfo);
                            break;
                        }

                        success      = resultInfo.success;
                        errorMessage = resultInfo.errorMessage;
                    }
                }

                //
                // Update success of command execution
                //
                XmlNode xmlResponseNode = XmlUtilities.GetXmlRootNode(xmlResponseDocument, Engine.Consts.STRXML_Response);
                XmlUtilities.SetXmlValue(xmlResponseNode, Engine.Consts.STRXML_RspSuccess, success.ToString(), false);
                if (success == false)
                {
                    //
                    // Create error response
                    //
                    xmlElement           = xmlResponseDocument.CreateElement(Engine.Consts.STRXML_RspErrorMessage);
                    xmlElement.InnerText = errorMessage;
                    xmlResponseDocument.DocumentElement.AppendChild(xmlElement);
                }
                strXmlResponse = xmlResponseDocument.InnerXml;
            }
            catch (ArgumentException)
            {
                //
                // Unknown command so pass to base class to process
                //
                strXmlResponse = base.ExecuteXmlRequest(xmlRequest);
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return(strXmlResponse);
        }
Exemplo n.º 8
0
        //-------------------------------------------------------------------------------------------------//

        public override ExecuteCommandInfo ProcessCommand(ExecuteCommandInfo executeCommandInfo)
        {
            const string STRLOG_MethodName = "ProcessCommand";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            CommandInfo commandInfo = (CommandInfo)executeCommandInfo;

            bool   success      = false;
            string errorMessage = null;

            try
            {
                //
                // Process the execute command
                //
                ExecuteCommands executeCommand = (ExecuteCommands)commandInfo.command;

                switch (executeCommand)
                {
                case ExecuteCommands.StartExecution:
                    //
                    // Get the specification in XML format from the parameters and parse
                    //
                    string           xmlSpecification = (string)commandInfo.parameters[0];
                    Specification    specification    = new Specification(this.xmlNodeEquipmentConfig);
                    ValidationReport validationReport = specification.Parse(xmlSpecification);
                    if (validationReport.accepted == false)
                    {
                        errorMessage = validationReport.errorMessage;
                        break;
                    }

                    //
                    // Create an instance of the driver for the specified setup
                    // and then start the driver with the specification
                    //
                    if (specification.SetupId.Equals(Consts.STRXML_SetupId_OpenCircuitVaryField) == true)
                    {
                        this.driverMachine = new DriverMachine_OCVF(this.xmlNodeEquipmentConfig, specification);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_OpenCircuitVarySpeed) == true)
                    {
                        this.driverMachine = new DriverMachine_OCVS(this.xmlNodeEquipmentConfig, specification);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_ShortCircuitVaryField) == true)
                    {
                        this.driverMachine = new DriverMachine_SCVF(this.xmlNodeEquipmentConfig, specification);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_PreSynchronisation) == true)
                    {
                        this.driverMachine = new DriverMachine_PreSync(this.xmlNodeEquipmentConfig, specification);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_Synchronisation) == true)
                    {
                        this.driverMachine = new DriverMachine_Sync(this.xmlNodeEquipmentConfig, specification);
                    }
                    else
                    {
                        //
                        // Unknown SetupId
                        //
                        throw new Exception(STRERR_UnknownSetupId + specification.SetupId);
                    }

                    //
                    // Start execution of the specified setup
                    //
                    if ((success = this.driverMachine.Start()) == false)
                    {
                        errorMessage = this.driverMachine.LastError;
                    }
                    break;

                default:
                    //
                    // Unknown command
                    //
                    throw new Exception(STRERR_UnknownCommand + executeCommand.ToString());
                }
            }
            catch (Exception ex)
            {
                success      = false;
                errorMessage = ex.Message;
            }

            //
            // Update success of command execution
            //
            executeCommandInfo.success = success;

            string logMessage = STRLOG_Success + success.ToString();

            if (success == false)
            {
                executeCommandInfo.errorMessage = errorMessage;
                logMessage += Logfile.STRLOG_Spacer + STRLOG_ErrorMessage + errorMessage;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(executeCommandInfo);
        }
Exemplo n.º 9
0
        //-------------------------------------------------------------------------------------------------//

        public override ExecuteCommandInfo ProcessCommand(ExecuteCommandInfo executeCommandInfo)
        {
            const string STRLOG_MethodName = "ProcessCommand";

            Logfile.WriteCalled(this.logLevel, STRLOG_ClassName, STRLOG_MethodName);

            CommandInfo commandInfo = (CommandInfo)executeCommandInfo;

            bool   success      = true;
            string errorMessage = null;

            try
            {
                //
                // Process the execute command
                //
                ExecuteCommands executeCommand = (ExecuteCommands)commandInfo.command;

                switch (executeCommand)
                {
                case ExecuteCommands.CreateConnection:

                    //
                    // Create a connection to the RedLion controller
                    //
                    if ((success = this.redLion.CreateConnection()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.CloseConnection:

                    //
                    // Close the connection to the RedLion controller
                    //
                    if ((success = this.redLion.CloseConnection()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.ResetACDrive:

                    //
                    // Reset the AC drive
                    //
                    if ((success = this.redLion.ResetACDrive()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.ConfigureACDrive:

                    //
                    // Get AC drive configuration from parameters
                    //
                    RedLion.ACDriveConfigs acCDriveConfig = (RedLion.ACDriveConfigs)commandInfo.parameters[0];

                    //
                    // Configure the AC drive with the specified configuration
                    //
                    if ((success = this.redLion.ConfigureACDrive(acCDriveConfig)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.StartACDrive:

                    //
                    // Start the AC drive
                    //
                    if ((success = this.redLion.StartACDrive()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.StopACDrive:

                    //
                    // Stop the AC drive
                    //
                    if ((success = this.redLion.StopACDrive()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.ResetDCDriveMut:

                    //
                    // Reset the DC drive
                    //
                    if ((success = this.redLion.ResetDCDriveMut()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.ConfigureDCDriveMut:

                    //
                    // Get DC drive configuration from parameters
                    //
                    RedLion.DCDriveMutConfigs dcDriveMutConfig = (RedLion.DCDriveMutConfigs)commandInfo.parameters[0];

                    //
                    // Configure the AC drive with the specified configuration
                    //
                    if ((success = this.redLion.ConfigureDCDriveMut(dcDriveMutConfig)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.StartDCDriveMut:

                    //
                    // Get DC drive mode from parameters
                    //
                    RedLion.DCDriveMutModes dcDriveMutMode = (RedLion.DCDriveMutModes)commandInfo.parameters[0];

                    //
                    // Start the DC drive
                    //
                    if ((success = this.redLion.StartDCDriveMut(dcDriveMutMode)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.StopDCDriveMut:

                    //
                    // Stop the DC drive
                    //
                    if ((success = this.redLion.StopDCDriveMut()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.SetSpeedACDrive:

                    //
                    // Get speed from parameters
                    //
                    int speedACDrive = (int)commandInfo.parameters[0];

                    //
                    // Set the speed of the AC drive
                    //
                    if ((success = this.redLion.SetSpeedACDrive(speedACDrive)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.SetSpeedDCDriveMut:

                    //
                    // Get speed from parameters
                    //
                    int speedDCDriveMut = (int)commandInfo.parameters[0];

                    //
                    // Set the speed of the DC drive
                    //
                    if ((success = this.redLion.SetSpeedDCDriveMut(speedDCDriveMut)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.SetTorqueDCDriveMut:

                    //
                    // Get torque from parameters
                    //
                    int torqueDCDriveMut = (int)commandInfo.parameters[0];

                    //
                    // Set the torque of the DC drive
                    //
                    if ((success = this.redLion.SetTorqueDCDriveMut(torqueDCDriveMut)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.SetFieldDCDriveMut:

                    //
                    // Get torque from parameters
                    //
                    int fieldDCDriveMut = (int)commandInfo.parameters[0];

                    //
                    // Set the field of the DC drive
                    //
                    if ((success = this.redLion.SetFieldDCDriveMut(fieldDCDriveMut)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.TakeMeasurement:

                    //
                    // Take a measurement
                    //
                    RedLion.Measurements measurement = new RedLion.Measurements();
                    if ((success = this.redLion.TakeMeasurement(ref measurement)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    else
                    {
                        //
                        // Add the measurement values to results
                        //
                        commandInfo.results = new object[] {
                            measurement.speed,
                            measurement.voltage,
                            measurement.fieldCurrent,
                            measurement.load
                        };
                    }
                    break;

                default:

                    //
                    // Unknown command
                    //
                    errorMessage = STRERR_UnknownCommand + executeCommand.ToString();
                    success      = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                success      = false;
                errorMessage = ex.Message;
            }

            //
            // Update success of command execution
            //
            executeCommandInfo.success = success;

            string logMessage = STRLOG_Success + success.ToString();

            if (success == false)
            {
                executeCommandInfo.errorMessage = errorMessage;
                logMessage += Logfile.STRLOG_Spacer + STRLOG_ErrorMessage + errorMessage;
            }

            Logfile.WriteCompleted(this.logLevel, STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(executeCommandInfo);
        }
        //-------------------------------------------------------------------------------------------------//

        public override ExecuteCommandInfo ProcessCommand(ExecuteCommandInfo executeCommandInfo)
        {
            const string STRLOG_MethodName = "ProcessCommand";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            CommandInfo commandInfo = (CommandInfo)executeCommandInfo;

            bool   success      = true;
            string errorMessage = null;

            try
            {
                //
                // Process the execute command
                //
                ExecuteCommands executeCommand = (ExecuteCommands)commandInfo.command;

                switch (executeCommand)
                {
                case ExecuteCommands.CreateConnection:

                    //
                    // Create a connection to the RedLion controller
                    //
                    if ((success = this.redLion.CreateConnection()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.CloseConnection:

                    //
                    // Close the connection to the RedLion controller
                    //
                    if ((success = this.redLion.CloseConnection()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.ResetACDrive:

                    //
                    // Reset the AC drive controller
                    //
                    if ((success = this.redLion.ResetACDrive()) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.ConfigureACDrive:

                    //
                    // Get AC drive configuration from parameters
                    //
                    RedLion.ACDriveConfigs acDriveConfig = (RedLion.ACDriveConfigs)commandInfo.parameters[0];

                    //
                    // Configure the AC drive
                    //
                    if ((success = this.redLion.ConfigureACDrive(acDriveConfig)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.StartACDrive:

                    //
                    // Get AC drive mode from parameters
                    //
                    RedLion.ACDriveModes acDriveMode = (RedLion.ACDriveModes)commandInfo.parameters[0];

                    //
                    // Start the AC drive
                    //
                    if ((success = this.redLion.StartACDrive(acDriveMode)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.StopACDrive:

                    //
                    // Get AC drive mode from parameters
                    //
                    acDriveMode = (RedLion.ACDriveModes)commandInfo.parameters[0];

                    //
                    // Stop the AC drive
                    //
                    if ((success = this.redLion.StopACDrive(acDriveMode)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    break;

                case ExecuteCommands.TakeMeasurement:

                    //
                    // Take a measurement
                    //
                    RedLion.Measurements measurement = new RedLion.Measurements();
                    if ((success = this.redLion.TakeMeasurement(ref measurement)) == false)
                    {
                        errorMessage = this.redLion.GetLastError();
                    }
                    else
                    {
                        //
                        // Add the measurement values to results - ensure the order of the measurement values is the
                        // same as in EquipmentManager.cs
                        //
                        commandInfo.results = new object[] {
                            measurement.voltageMut,
                            measurement.currentMut,
                            measurement.powerFactorMut,
                            measurement.voltageVsd,
                            measurement.currentVsd,
                            measurement.powerFactorVsd,
                            measurement.speed,
                            measurement.torque
                        };
                    }
                    break;

                default:

                    //
                    // Unknown command
                    //
                    errorMessage = STRERR_UnknownCommand + executeCommand.ToString();
                    success      = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                success      = false;
                errorMessage = ex.Message;
            }

            //
            // Update success of command execution
            //
            executeCommandInfo.success = success;

            string logMessage = STRLOG_Success + success.ToString();

            if (success == false)
            {
                executeCommandInfo.errorMessage = errorMessage;
                logMessage += Logfile.STRLOG_Spacer + STRLOG_ErrorMessage + errorMessage;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(executeCommandInfo);
        }
        //-------------------------------------------------------------------------------------------------//

        public override ExecuteCommandInfo ProcessCommand(ExecuteCommandInfo executeCommandInfo)
        {
            const string STRLOG_MethodName = "ProcessCommand";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            CommandInfo commandInfo = (CommandInfo)executeCommandInfo;

            bool   success      = true;
            string errorMessage = null;

            try
            {
                //
                // Process the execute command
                //
                ExecuteCommands executeCommand = (ExecuteCommands)commandInfo.command;

                switch (executeCommand)
                {
                case ExecuteCommands.GetTimeOfDay:

                    //
                    // Get server URL from parameters
                    //
                    string serverUrl = (string)commandInfo.parameters[0];

                    //
                    // Get the time-of-day
                    //
                    DateTime dateTime = DateTime.MinValue;
                    if ((success = this.timeOfDay.GetTimeOfDay(serverUrl, ref dateTime)) == false)
                    {
                        errorMessage = this.timeOfDay.GetLastError();
                    }
                    else
                    {
                        //
                        // Add the measurement values to results
                        //
                        commandInfo.results = new object[] {
                            dateTime
                        };
                    }
                    break;

                default:

                    //
                    // Unknown command
                    //
                    errorMessage = STRERR_UnknownCommand + executeCommand.ToString();
                    success      = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                success      = false;
                errorMessage = ex.Message;
            }

            //
            // Update success of command execution
            //
            executeCommandInfo.success = success;

            string logMessage = STRLOG_Success + success.ToString();

            if (success == false)
            {
                executeCommandInfo.errorMessage = errorMessage;
                logMessage += Logfile.STRLOG_Spacer + STRLOG_ErrorMessage + errorMessage;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(executeCommandInfo);
        }