static public tcFunctionResult tcGetAxisFeedback(int index, ref Axis_PlcToHmi RESULT) { if (!tcClient.IsConnected) { return(tcFunctionResult.TC_NOT_CONNECTED); } if (Axis_MaxAxes <= 0) { return(tcFunctionResult.TC_NO_AXIS); } if (index < 0 || index > Axis_MaxAxes - 1) { return(tcFunctionResult.TC_AXIS_OUTOFBOUND); } AdsStream _DataStream = new AdsStream(tcAxFeedback[index].size); AdsBinaryReader _DataReader = new AdsBinaryReader(_DataStream); try { tcClient.Read(tcAxFeedback[index].handle, _DataStream); RESULT.actualPosition = _DataReader.ReadDouble(); RESULT.actualVelocity = _DataReader.ReadDouble(); RESULT.setPosition = _DataReader.ReadDouble(); RESULT.setVelocity = _DataReader.ReadDouble(); RESULT.controlleroverride = _DataReader.ReadDouble(); RESULT.ErrorID = _DataReader.ReadUInt32(); RESULT.hasError = _DataReader.ReadBoolean(); RESULT.isDisabled = _DataReader.ReadBoolean(); RESULT.isFwDisabled = _DataReader.ReadBoolean(); RESULT.isBwDisabled = _DataReader.ReadBoolean(); RESULT.isCalibrated = _DataReader.ReadBoolean(); RESULT.hasJob = _DataReader.ReadBoolean(); RESULT.isNotMoving = _DataReader.ReadBoolean(); RESULT.isPositiveDirection = _DataReader.ReadBoolean(); RESULT.isNegativeDirection = _DataReader.ReadBoolean(); RESULT.isInTarget = _DataReader.ReadBoolean(); RESULT.isInRange = _DataReader.ReadBoolean(); } catch (Exception ex) { LogMessage(string.Format("{0}\t: {1}", "Error", "Failed to read PlcToHmi" + ex.Message)); _DataReader.Close(); return(tcFunctionResult.TC_FAIL_TO_READ_AXIS_FEEDBACK); } _DataReader.Close(); return(tcFunctionResult.TC_SUCCESS); }
static public Axis_PlcToHmi tcGetAxsPlcToHmi(int index) { if (!tcClient.IsConnected) { return(null); } if (Axis_MaxAxes <= 0) { return(null); } if (index < 0 || index > Axis_MaxAxes - 1) { return(null); } AdsStream _DataStream = new AdsStream(tcAxFeedback[index].size); AdsBinaryReader _DataReader = new AdsBinaryReader(_DataStream); try { Axis_PlcToHmi _buffer = new Axis_PlcToHmi(); tcClient.Read(tcAxFeedback[index].handle, _DataStream); _buffer.actualPosition = _DataReader.ReadDouble(); _buffer.actualVelocity = _DataReader.ReadDouble(); _buffer.setPosition = _DataReader.ReadDouble(); _buffer.setVelocity = _DataReader.ReadDouble(); _buffer.controlleroverride = _DataReader.ReadDouble(); _buffer.ErrorID = _DataReader.ReadUInt32(); _buffer.hasError = _DataReader.ReadBoolean(); _buffer.isDisabled = _DataReader.ReadBoolean(); _buffer.isFwDisabled = _DataReader.ReadBoolean(); _buffer.isBwDisabled = _DataReader.ReadBoolean(); _buffer.isCalibrated = _DataReader.ReadBoolean(); _buffer.hasJob = _DataReader.ReadBoolean(); _buffer.isNotMoving = _DataReader.ReadBoolean(); _buffer.isPositiveDirection = _DataReader.ReadBoolean(); _buffer.isNegativeDirection = _DataReader.ReadBoolean(); _buffer.isInTarget = _DataReader.ReadBoolean(); _buffer.isInRange = _DataReader.ReadBoolean(); return(_buffer); } catch (Exception ex) { LogMessage(string.Format("{0}\t: {1}", "Error", "Failed to read PlcToHmi" + ex.Message)); _DataReader.Close(); return(null); } }