12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using Automation.BDaq;
- namespace athosRT.Devices
- {
- public class DOCard
- {
- private int _portCount;
- private byte[] _buff = (byte[]) null;
- private R_TRIG _trigError = new R_TRIG();
- private InstantDoCtrl _ctrl = (InstantDoCtrl) null;
- public string Name { get; set; }
- public DOCard(string name, int deviceID)
- {
- this.Name = name;
- this._ctrl = new InstantDoCtrl();
- this._ctrl.SelectedDevice = new DeviceInformation(deviceID);
- }
- public bool Open()
- {
- if (!this._ctrl.Initialized)
- {
- LOG.Write("Open DO card failed.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Devices\\AdvantecIoCard.cs", member: nameof (Open), line: 285);
- return false;
- }
- this._portCount = this._ctrl.PortCount;
- this._buff = new byte[this._portCount * 8];
- return true;
- }
- public bool Read() => true;
- public bool Write(byte[] buffer)
- {
- if (!this._ctrl.Initialized)
- return false;
- for (int index = 0; index < this._portCount * 8 && index < buffer.Length; ++index)
- this._buff[index] = buffer[index];
- ErrorCode errorCode = this._ctrl.Write(0, this._portCount, this._buff);
- this._trigError.CLK = errorCode != 0;
- if (this._trigError.Q)
- LOG.Write("Write DO failed.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Devices\\AdvantecIoCard.cs", member: nameof (Write), line: 317);
- return errorCode == 0;
- }
- public bool Reset() => true;
- public bool Close() => true;
- }
- }
|