public int GetAllDIs(out bool[] isONs) { isONs = new bool[DICount]; //lock (asynLocker) { if (!IsOpen) { return((int)ErrorDef.NotOpen); } uint diVals = 0; ushort ports = (ushort)((DICount + 31) / 32); for (ushort i = 0; i < ports; i++) { if (0 != DASK.DI_ReadPort(_devHandle, i, out diVals)) { return((int)ErrorDef.InvokeFailed); } for (int j = 0; j < 32; j++) { if (i * 32 + j == DICount) { break; } isONs[i * 32 + j] = (diVals & (1 << j)) != 0; } } //DASK.DO_ReadLine() } return((int)ErrorDef.Success); }
private void CycleReadIO() { // 阻塞等触发 while (_cycleCycleReadIOFlag) { uint dInput = 0; int ret = DASK.DI_ReadPort((ushort)_config.DevIndex, 0, out dInput); if (dInput != 0) { if (groupDIVal[0] != -1 && CycleTrigList.Count > 0) { CycleCmpDI(0, (int)dInput); } groupDIVal[0] = (int)dInput; } uint dOut = 0; ret = DASK.DO_ReadPort((ushort)_config.DevIndex, 0, out dOut); if (dOut != 0) { groupDOVal[0] = (int)dOut; } Thread.Sleep(5); } }
/// <summary> /// 读端口数据 /// </summary> /// <param name="boardNo"></param> /// <param name="portNo"></param> /// <returns></returns> public uint ReadPort(int boardNo, int portNo = 0) { var device = _devices[boardNo]; uint value; var ret = DASK.DI_ReadPort((ushort)device, (ushort)portNo, out value); if (ret != DASK.NoError) { switch (ret) { case DASK.ErrorInvalidCardNumber: throw new DaskException(string.Format("The CardNumber argument {0} is out of range (larger than 31).", boardNo)); case DASK.ErrorCardNotRegistered: throw new DaskException(string.Format("No card registered as {0} CardNumber.", boardNo)); case DASK.ErrorFuncNotSupport: throw new DaskException(string.Format("The {0} function called is not supported by this type of card.", "DI_ReadPort")); default: throw new DaskException("Unknown error."); } } return(value); }
public int ReadSingleDInput(int boardId, int group, int idx, out int iVal) { uint diValue0 = 0; var ret = 0; iVal = -1; ret = DASK.DI_ReadPort((ushort)_config.DevIndex, 0, out diValue0); iVal = (int)(diValue0 >> idx) & 1; return(ret); }
public int ReadMultiDInputFromAPI(int boarId, int group, ref int val) { try { uint diValue0; DASK.DI_ReadPort((ushort)boarId, 0, out diValue0); val = (int)diValue0; } catch { } return(0); }
private static void Monitor() { // DASK 读取 uint m_Read = 0; // DASK 写入 uint m_Write = 0; while (true) { Thread.Sleep(1); DASK.DI_ReadPort(m_Number, 0, out m_Read); CheckSignal(ref m_Read, ref m_Write); } }
public static uint Read() { short ret; uint int_value; ret = DASK.DI_ReadPort((ushort)m_dev, 0, out int_value); if (ret < 0) { // MessageBox.Show("D2K_DI_ReadPort error!"); throw new ArgumentOutOfRangeException("NOT"); return(0); } return(int_value); }
/* Read Port */ public static void ReadPort(byte port, out uint value, out short code, out string message) { code = DASK.DI_ReadPort((ushort)m_device, port, out value); if (code < 0) { message = "อ่านพอร์ต DIO7432 ผิดพลาด"; logText = "Read Port [" + port.ToString() + " = " + value.ToString() + "]: " + message; log.AppendText(logText); System.Diagnostics.Debug.WriteLine(logText); } else { message = ""; logText = "Read Port [" + port.ToString() + " = " + value.ToString() + "]: OK"; log.AppendText(logText); System.Diagnostics.Debug.WriteLine(logText); } }
public static int ReadIOCard7432InputBit(ushort cardID, int cardInputBit)//读扩展IO卡输入点 { if (CAMiClsVariable.strIOCard == "7432") { uint diValue = 0; bool inputBitStatus; int result; DASK.DI_ReadPort((ushort)CAMiClsVariable.cardRegId, 0, out diValue); inputBitStatus = (diValue & (1 << cardInputBit)) != 0; result = inputBitStatus ? 1 : 0; return(result); } else //APE IO卡 { uint diValue = 0; bool inputBitStatus; int result; DAQ_I32.DAQ_Mul_GDI_Get(DAQ_I32.DAQ_TYPE.DAQ_D3232, (int)cardID, ref diValue); inputBitStatus = (diValue & (1 << cardInputBit)) != 0; result = inputBitStatus ? 1 : 0;//返回当前点位电平状态,0或1 return(result); } }