/// <summary>
 /// Constructor of class DataStandardModbus : Initalizes values and connects
 /// the eventhandler from Connection to the interal update method
 /// </summary>
 /// <param name="Connection">Target connection</param>
 public ModbusDataLimitSwitch(INetConnection Connection)
 {
     _connection             = Connection;
     _connection.UpdateData += UpdateDataLimitSwitch;
     LimitStatus1            = false;
     LimitStatus2            = false;
     LimitStatus3            = false;
     LimitStatus4            = false;
     _limitSwitch1Source     = LimitSwitchSource.Gross;
     _limitSwitch1Mode       = LimitSwitchMode.AboveLevel;
     _limitSwitch1LevelAndLowerBandValue  = 0;
     _limitSwitch1HysteresisAndBandHeight = 0;
     _limitSwitch2Source = LimitSwitchSource.Gross;
     _limitSwitch2Mode   = LimitSwitchMode.AboveLevel;
     _limitSwitch2LevelAndLowerBandValue  = 0;
     _limitSwitch2HysteresisAndBandHeight = 0;
     _limitSwitch3Source = LimitSwitchSource.Gross;
     _limitSwitch3Mode   = LimitSwitchMode.AboveLevel;
     _limitSwitch3LevelAndLowerBandValue  = 0;
     _limitSwitch3HysteresisAndBandHeight = 0;
     _limitSwitch4Source = LimitSwitchSource.Gross;
     _limitSwitch4Mode   = LimitSwitchMode.AboveLevel;
     _limitSwitch4LevelAndLowerBandValue  = 0;
     _limitSwitch4HysteresisAndBandHeight = 0;
 }
        /// <summary>
        /// Updates and converts the values from buffer
        /// </summary>
        /// <param name="sender">Connection class</param>
        /// <param name="e">EventArgs, Event argument</param>
        public void UpdateDataLimitSwitch(object sender, EventArgs e)
        {
            try
            {
                LimitStatus1 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));
                LimitStatus2 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));
                LimitStatus3 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));
                LimitStatus4 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus));

                ApplicationMode _applicationMode = (ApplicationMode)Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.IMDApplicationMode));
                if (_applicationMode == ApplicationMode.Standard)
                {
                    _limitSwitch1Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch1Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch1LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch1HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch2Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch2Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch2LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch2HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch3Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch3Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch3LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch3HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch4Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode));
                    _limitSwitch4Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource));
                    _limitSwitch4LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch4HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis));
                }
            }
            catch (KeyNotFoundException)
            {
                Console.WriteLine("KeyNotFoundException in class DataStandardModbus, update method");
            }
        }
예제 #3
0
 /// <summary>
 /// Constructor of class DataStandardJet : Initalizes values and connects
 /// the eventhandler from Connection to the interal update method
 /// </summary>
 public DataStandardJet(INetConnection Connection)
 {
     _connection             = Connection;
     _connection.UpdateData += UpdateStandardData;
     WeightMemory            = new WeightMemory();
     Input1              = false;
     Input2              = false;
     Input3              = false;
     Input4              = false;
     _output1            = false;
     _output2            = false;
     _output3            = false;
     _output4            = false;
     LimitStatus1        = false;
     LimitStatus2        = false;
     LimitStatus3        = false;
     LimitStatus4        = false;
     _limitSwitch1Source = 0;
     _limitSwitch1Mode   = 0;
     _limitSwitch1LevelAndLowerBandValue  = 0;
     _limitSwitch1HysteresisAndBandHeight = 0;
     _limitSwitch2Source = 0;
     _limitSwitch2Mode   = 0;
     _limitSwitch2LevelAndLowerBandValue  = 0;
     _limitSwitch2HysteresisAndBandHeight = 0;
     _limitSwitch3Source = 0;
     _limitSwitch3Mode   = 0;
     _limitSwitch3LevelAndLowerBandValue  = 0;
     _limitSwitch3HysteresisAndBandHeight = 0;
     _limitSwitch4Source = 0;
     _limitSwitch4Mode   = 0;
     _limitSwitch4LevelAndLowerBandValue  = 0;
     _limitSwitch4HysteresisAndBandHeight = 0;
 }
예제 #4
0
        /// <summary>
        /// Convert limt switch mode from int to enum
        /// </summary>
        /// <param name="mode">Limit switch mode from wtx device</param>
        /// <returns></returns>
        private LimitSwitchMode StringToLimitSwitchMode(string mode)
        {
            LimitSwitchMode result = LimitSwitchMode.AboveLevel;

            switch (mode)
            {
            case "0": result = LimitSwitchMode.AboveLevel; break;

            case "2": result = LimitSwitchMode.BelowLevel; break;

            case "3": result = LimitSwitchMode.InsideBand; break;

            case "4": result = LimitSwitchMode.OutsideBand; break;
            }
            return(result);
        }
예제 #5
0
        /// <summary>
        /// Convert limt switch mode from enum to int
        /// </summary>
        /// <param name="mode">Limit switch mode</param>
        /// <returns></returns>
        private int LimitSwitchModeToInt(LimitSwitchMode mode)
        {
            int result = 0;

            switch (mode)
            {
            case LimitSwitchMode.AboveLevel: result = 0; break;

            case LimitSwitchMode.BelowLevel: result = 1; break;

            case LimitSwitchMode.InsideBand: result = 2; break;

            case LimitSwitchMode.OutsideBand: result = 3; break;
            }
            return(result);
        }
예제 #6
0
        /// <summary>
        /// Updates & converts the values from buffer (Dictionary<string,string>)
        /// </summary>
        /// <param name="sender">Connection class</param>
        /// <param name="e">EventArgs, Event argument</param>
        public void UpdateStandardData(object sender, EventArgs e)
        {
            try
            {
                Input1       = StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS1DigitalInput1));
                Input2       = StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS2DigitalInput2));
                Input3       = StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS3DigitalInput3));
                Input4       = StringToBool(_connection.ReadFromBuffer(JetBusCommands.IS4DigitalInput4));
                _output1     = StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS1DigitalOutput1));
                _output2     = StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS2DigitalOutput2));
                _output3     = StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS3DigitalOutput3));
                _output4     = StringToBool(_connection.ReadFromBuffer(JetBusCommands.OS4DigitalOutput4));
                LimitStatus1 = StringToBool(_connection.ReadFromBuffer(JetBusCommands.LVSLimitValue1Status));
                LimitStatus2 = StringToBool(_connection.ReadFromBuffer(JetBusCommands.LVSLimitValue2Status));
                LimitStatus3 = StringToBool(_connection.ReadFromBuffer(JetBusCommands.LVSLimitValue3Status));
                LimitStatus4 = StringToBool(_connection.ReadFromBuffer(JetBusCommands.LVSLimitValue4Status));

                WeightMemory = ExtractWeightMemory();

                ApplicationMode _applicationMode = (ApplicationMode)Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.IMDApplicationMode));
                if (_applicationMode == ApplicationMode.Standard)
                {
                    _limitSwitch1Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchMode));
                    _limitSwitch1Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchSource));
                    _limitSwitch1LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch1HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch2Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchMode));
                    _limitSwitch2Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchSource));
                    _limitSwitch2LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch2HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch3Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchMode));
                    _limitSwitch3Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchSource));
                    _limitSwitch3LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch3HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchHysteresis));
                    _limitSwitch4Mode   = StringToLimitSwitchMode(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchMode));
                    _limitSwitch4Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchSource));
                    _limitSwitch4LevelAndLowerBandValue  = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchLevel));
                    _limitSwitch4HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.LIV1LimitSwitchHysteresis));
                }
            }
            catch (KeyNotFoundException)
            {
                Console.WriteLine("KeyNotFoundException in class DataStandardJet, update method");
            }
        }