1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using Automation.BDaq;
- namespace athosRT.Devices
- {
- public class DICard
- {
- private int _portCount;
- private byte[] _buff = (byte[]) null;
- private InstantDiCtrl _ctrl = (InstantDiCtrl) null;
- private int _deviceNumber = -1;
- private R_TRIG _trigError = new R_TRIG();
- public string Name { get; set; }
- public byte[] DI => this._buff;
- public DICard(string name, int deviceID)
- {
- this.Name = name;
- this._deviceNumber = deviceID;
- this._ctrl = new InstantDiCtrl();
- this._ctrl.SelectedDevice = new DeviceInformation(deviceID);
- }
- public bool Open()
- {
- if (!this._ctrl.Initialized)
- {
- LOG.Write(string.Format("{0} : {1} initialize failed", (object) this.Name, (object) this._deviceNumber), file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Devices\\AdvantecIoCard.cs", member: nameof (Open), line: 196);
- return false;
- }
- this._portCount = this._ctrl.PortCount;
- this._buff = new byte[this._portCount * 8];
- return true;
- }
- public bool Read()
- {
- if (!this._ctrl.Initialized)
- return false;
- for (int port = 0; port < this._portCount; ++port)
- {
- for (int bit = 0; bit < 8; ++bit)
- {
- byte data;
- ErrorCode errorCode = this._ctrl.ReadBit(port, bit, out data);
- this._buff[port * 8 + bit] = data;
- this._trigError.CLK = errorCode != 0;
- if (this._trigError.Q)
- {
- LOG.Write(string.Format("{0} : {1} read error: {2}", (object) this.Name, (object) this._deviceNumber, (object) errorCode), file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Devices\\AdvantecIoCard.cs", member: nameof (Read), line: 225);
- break;
- }
- }
- }
- return !this._trigError.M;
- }
- public bool Write(byte[] buffer) => true;
- public bool Reset() => true;
- public bool Close() => true;
- }
- }
|