Exemple #1
0
        //-------------------------------------------------------------------------------------------------//

        public int GetExecutionTime(string xmlSpecification)
        {
            int executionTime = -1;

            try
            {
                //
                // Parse the XML specification string
                //
                Specification    specification    = new Specification(this.xmlNodeEquipmentConfig);
                ValidationReport validationReport = specification.Parse(xmlSpecification);
                if (validationReport.accepted == true)
                {
                    executionTime = (int)validationReport.estRuntime;
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
            }

            return(executionTime);
        }
        //-------------------------------------------------------------------------------------------------//
        public int GetExecutionTime(string xmlSpecification)
        {
            int executionTime = -1;

            try
            {
                //
                // Parse the XML specification string
                //
                Specification specification = new Specification(this.xmlNodeEquipmentConfig);
                ValidationReport validationReport = specification.Parse(xmlSpecification);
                if (validationReport.accepted == true)
                {
                    executionTime = (int)validationReport.estRuntime;
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
            }

            return executionTime;
        }
        //-------------------------------------------------------------------------------------------------//
        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;
        }
Exemple #4
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);
        }