/// <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"); } }
/// <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; }
/// <summary> /// Convert limt switch source from string to enum /// </summary> /// <param name="mode">Limit switch source from wtx device</param> /// <returns></returns> private LimitSwitchSource StringToLimitSwitchSource(string mode) { LimitSwitchSource result = LimitSwitchSource.Gross; switch (mode) { case "0": result = LimitSwitchSource.Gross; break; case "1": result = LimitSwitchSource.Net; break; } return(result); }
/// <summary> /// Convert limt switch source from enum to int /// </summary> /// <param name="source">Limit switch source</param> /// <returns></returns> private int LimitSwitchSouceToInt(LimitSwitchSource source) { int result = 0; switch (source) { case LimitSwitchSource.Gross: result = 0; break; case LimitSwitchSource.Net: result = 1; break; } return(result); }
public TalonSRXConfiguration() { primaryPID = new TalonSRXPIDSetConfiguration(); auxilaryPID = new TalonSRXPIDSetConfiguration(); forwardLimitSwitchSource = LimitSwitchSource.FeedbackConnector; reverseLimitSwitchSource = LimitSwitchSource.FeedbackConnector; sum_0 = FeedbackDevice.QuadEncoder; sum_1 = FeedbackDevice.QuadEncoder; diff_0 = FeedbackDevice.QuadEncoder; diff_1 = FeedbackDevice.QuadEncoder; peakCurrentLimit = 1; peakCurrentDuration = 1; continuousCurrentLimit = 1; }
public static string ToString(LimitSwitchSource value) { switch (value) { case LimitSwitchSource.FeedbackConnector: return("LimitSwitchSource.FeedbackConnector"); case LimitSwitchSource.RemoteTalonSRX: return("LimitSwitchSource.RemoteTalonSRX"); case LimitSwitchSource.RemoteCANifier: return("LimitSwitchSource.RemoteCANifier"); case LimitSwitchSource.Deactivated: return("LimitSwitchSource.Deactivated"); default: return("InvalidValue"); } }
/// <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"); } }
/** * Configures a limit switch for a local/remote source. * * For example, a CAN motor controller may need to monitor the Limit-R pin * of another Talon, CANifier, or local Gadgeteer feedback connector. * * If the sensor is remote, a device ID of zero is assumed. If that's not * desired, use the four parameter version of this function. * * @param type * Limit switch source. @see #LimitSwitchSource User can choose * between the feedback connector, remote Talon SRX, CANifier, or * deactivate the feature. * @param normalOpenOrClose * Setting for normally open, normally closed, or disabled. This * setting matches the web-based configuration drop down. * @param timeoutMs * Timeout value in ms. If nonzero, function will wait for config * success and report an error if it times out. If zero, no * blocking or checking is performed. * @return Error Code generated by function. 0 indicates no error. */ public ErrorCode ConfigReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int timeoutMs = 0) { return(_ll.ConfigReverseLimitSwitchSource(type, normalOpenOrClose, 0x00000000, timeoutMs)); }