/// <summary> /// Set a digital output /// </summary> /// <param name="boolOutput"></param> /// <param name="value"></param> public override void Set(BoolOutput boolOutput, bool value) { ErrorCode errorCode = ErrorCode.Success; errorCode = instantDoCtrl.WriteBit(0, boolOutput.Channel, (byte)(value ? 0xff : 0x00)); boolOutput.Value = value; }
/// <summary> /// Set a digital output /// </summary> /// <param name="boolOutput"></param> /// <param name="value">Which direction to pulse</param> /// <param name="duration">Length of the Pulse</param> public virtual void SetPulse(BoolOutput boolOutput, bool value, Miliseconds duration) { // Simulation boolOutput.Value = value; U.SleepWithEvents(duration.ToInt); boolOutput.Value = !value; }
public virtual void FireTrigger() { BoolOutput boolOut = RefExternalTriggerOutput; if (boolOut != null) { boolOut.SetTrue(); } }
/// <summary> /// Set the boolean outputs /// </summary> /// <param name="boolOutput"></param> /// <param name="value"></param> public override void Set(BoolOutput boolOutput, bool value) { int portNum = boolOutput.Channel / 8; boolOutput.Value = value; SetOutputPortValue(boolOutput); CommandThreadSafe(eReadWrite.Write, portNum, _outputValues[portNum]); }
/// <summary> /// Set up the ID references for this object /// </summary> public override void InitializeIDReferences() { base.InitializeIDReferences(); _inputOpened = U.GetComponent(InputNickNameOpened) as BoolInput; _outputOpen = U.GetComponent(OutputNickNameOpen) as BoolOutput; _inputClosed = U.GetComponent(InputNickNameClosed) as BoolInput; _outputClose = U.GetComponent(OutputNickNameClose) as BoolOutput; _inputOpened.RegisterOnChanged(() => _inputOpened.Value, OnChangedOpenDirection); _inputClosed.RegisterOnChanged(() => _inputClosed.Value, OnChangedCloseDirection); }
///// <summary> ///// Set the boolean outputs ///// </summary> ///// <param name="boolOutput"></param> ///// <param name="value"></param> //public override void Set(BoolOutput boolOutput, bool value) //{ // int id = 5; // int bitAddress = boolOutput.Channel; // lock (_lockObject) // { // if (MbMaster != null) // { // MbMaster.WriteSingleCoils(id, bitAddress, value); // } // } //} /// <summary> /// Set the boolean outputs /// </summary> /// <param name="boolOutput"></param> /// <param name="value"></param> public override void Set(BoolOutput boolOutput, bool value) { int bitAddress = boolOutput.Channel; lock (_lockObject) { if (_mbClient != null) { _mbClient.WriteSingleCoil(bitAddress, value); } } }
/// <summary> /// Set the boolean outputs /// </summary> /// <param name="boolOutput"></param> /// <param name="value"></param> public override void Set(BoolOutput boolOutput, bool value) { int id = 5; int bitAddress = boolOutput.Channel; lock (_lockObject) { if (MbMaster != null) { MbMaster.WriteSingleCoils(id, bitAddress, value); } } }
/// <summary> /// Set the boolean outputs /// </summary> /// <param name="boolOutput"></param> /// <param name="value"></param> public override void Set(BoolOutput boolOutput, bool value) { int bitAddress = boolOutput.Channel; Tuple <int, bool> setOutTuple = new Tuple <int, bool>(bitAddress, value); lock (_lockSetOutputListBuffer) { _setOutputListBuffer.Add(setOutTuple); } //lock (_lockObject) //{ // if (_mbClient != null) // { // _mbClient.WriteSingleCoil( bitAddress, value); // } //} }
private void SetOutputPortValue(BoolOutput boolOutput) { int portNum = boolOutput.Channel / 8; int bitNo = boolOutput.Channel % 8; int bit = 1; for (int i = 0; i < bitNo; i++) { bit <<= 1; } if (boolOutput.Value) { _outputValues[portNum] &= (byte)~bit; // 0 is ON } else { _outputValues[portNum] |= (byte)bit; // 1 is OFF } }
/// <summary> /// Set a digital output /// </summary> /// <param name="boolOutput"></param> /// <param name="value"></param> public virtual void Set(BoolOutput boolOutput, bool value) { // Simulation boolOutput.Value = value; }
/// <summary> /// Set a digital output /// </summary> /// <param name="boolOutput"></param> /// <param name="value"></param> public override void Set(BoolOutput boolOutput, bool value) { VAR_TYPE varT = VAR_TYPE.BYTE_ARR; PI_VAR_UNION varUnion = new PI_VAR_UNION(); CompBase compAxis = boolOutput.GetParent <RealAxis>(); if (compAxis == null) { compAxis = boolOutput.GetParent <RealRotary>(); if (compAxis == null) { compAxis = boolOutput.GetParent <IOBoolChannel>(); } } if (listAxis.ContainsKey(compAxis)) { try { MMCSingleAxis singleAxis = listAxis[compAxis]; if (compAxis is RealRotary) { int val = value ? 1 : 0; //singleAxis.SetDigOutputs(boolOutput.Channel << 16, (byte)(value ? 0x1 : 0x0), 0x0); singleAxis.SendIntCmdViaSDO(string.Format("OB[{0}]={1}", boolOutput.Channel, val), 1000); } else if (compAxis is RealAxis) { uint val = outputVal[compAxis]; uint chanBit = (uint)(1 << (16 + boolOutput.Channel)); if (value) { val |= chanBit; } else { val &= ~chanBit; } singleAxis.SetDigOutputs32Bit(0, val); outputVal[compAxis] = val; } else { UInt16 index = (UInt16)boolOutput.Channel; if (value) { varUnion.s_byte = 0; } else { varUnion.s_byte = 1; } singleAxis.WritePIVar(index, varUnion, varT); } boolOutput.Value = value; //singleAxis.SetDigOutputs(chan, (byte)(value ? 1 : 0), (byte)1); } catch (Exception ex) { U.LogPopup(ex, "Trouble setting Digital Output ({0})", boolOutput.Name); } } }