Beispiel #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);
        }
        //-------------------------------------------------------------------------------------------------//

        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);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }