//デバイスの初期化 private void caioInitDevice() { if (aioDeviceInit == true) { aio.Exit(devId); } int aioInitState = aio.Init(comboBox1.SelectedItem.ToString(), out devId); if (devId == -1) { statusMsg(1, "デバイスが接続されていません"); return; } else { if (aioInitState != 0) { statusMsg(aioInitState, null); return; } else { int aioResetState = 0; aioResetState = aio.ResetDevice(devId); if (aioResetState != 0) { statusMsg(aioResetState, null); return; } caioGetChannel(); statusMsg(0, "デバイスの初期化に成功しました"); aioDeviceInit = true; } } }
public void IsFindingDevices() { Caio aio = new Caio(); List <DEVICEID> devices = new List <DEVICEID>(); string device_name = "Aio00"; long ret = 1; DEVICEID id1 = 0; string full_device_name; for (int i = 0; i < 10; i++) { full_device_name = device_name + i; ret = aio.Init(full_device_name, out id1); if (ret == 0) { devices.Add(id1); } } aio = null; Assert.IsTrue(devices.Count == 2); }
private bool AioInit(string deviceName, out short aioId, out string returnCode) { // Initialization handling int Ret = aio.Init(deviceName, out aioId); string ErrorString; aio.GetErrorString(Ret, out ErrorString); returnCode = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString; Console.WriteLine(returnCode); if (Ret != 0) { return(false); } return(true); }
public int DiscoverDevices(string device_root) //add devices { //TODO: rather than looking at error code is there a proactive way to find devices? DEVICEID id = 0; string full_device_name; devices.Clear(); devicenames.Clear(); for (int i = 0; i < 10; i++) { full_device_name = device_root + i; long ret = aio.Init(full_device_name, out id); if (ret == 0) { devices.Add(id); devicenames[id] = full_device_name; data[id] = new List <int>(); } } return(devices.Count()); }
public AIO121602() { ThicknessOffsets = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 }; System.Timers.Timer _timeout = new System.Timers.Timer(5000); bool isTimeout = false, isInitEnd = false; for (int i = 0; i < _avrs.Length; i++) { _avrs[i] = new MoveAverage(4); } _timeout.Elapsed += ((object sender, System.Timers.ElapsedEventArgs e) => { _timeout.Stop(); isTimeout = true; }); _timeout.Start(); Task.Run(() => { LastErrorNo = _aio.Init(ITEM_NAME, out _aioId); isInitEnd = true; }); while (!isTimeout && !isInitEnd) { Thread.Sleep(100); } _timeout.Stop(); if (isTimeout) { LastErrorNo = -1; return; } LastErrorNo = _aio.ResetDevice(_aioId); if (LastErrorNo != 0) { return; } LastErrorNo = _aio.SetAiStopTrigger(_aioId, 4); if (LastErrorNo != 0) { return; } LastErrorNo = _aio.SetAiChannels(_aioId, 14); if (LastErrorNo != 0) { return; } LastErrorNo = _aio.SetAiRangeAll(_aioId, (short)CaioConst.PM5); if (LastErrorNo != 0) { return; } LastErrorNo = _aio.SetAiTransferMode(_aioId, 0); // デバイスバッファモード if (LastErrorNo != 0) { return; } LastErrorNo = _aio.SetAiMemoryType(_aioId, 0); // MemoryFIFOモード if (LastErrorNo != 0) { return; } LastErrorNo = _aio.SetAiClockType(_aioId, 0); if (LastErrorNo != 0) { return; } LastErrorNo = _aio.SetAiSamplingClock(_aioId, 3000); // 1msサンプリング // LastErrorNo = _aio.SetAiSamplingClock( _aioId, 50000 ); // 1msサンプリング if (LastErrorNo != 0) { return; } ThicknessOneSheetQue = new Queue <ThicknessData[][]>(); _aio.StartAi(_aioId); _interval = new System.Timers.Timer(); _interval.Interval = 100; _interval.Elapsed += _interval_Elapsed; _interval.Start(); }