public int GetDO(int index, out bool isON) { if (index < 0 || index >= DOCount) { throw new Exception(string.Format("GetDO(index = {0}, isON) index is out of range:0~{1}", index, DOCount - 1)); } isON = false; if (!IsOpen) { return((int)ErrorDef.NotOpen); } //lock (asynLocker) { ushort doVal = 0; if (0 != DASK.DO_ReadLine(_devHandle, (ushort)(index / 32), (ushort)(index % 32), out doVal)) { return((int)ErrorDef.InvokeFailed); } isON = doVal != 0; } return((int)ErrorDef.Success); }
public bool GetOutBit(int iBit) { bool ret = false; ushort int_value = 0; try { lock (lockObj) { DASK.DO_ReadLine(usCardNo, 0, (ushort)iBit, out int_value); ret = int_value == 0 ? false : true; } } catch (Exception) { return(false); } return(ret); }
public bool Read(IoPoint ioPoint) { var device = _devices[ioPoint.BoardNo]; ushort value = 0; var ret = 0; if ((ioPoint.IoMode & IoModes.Responser) == 0) { ret = DASK.DI_ReadLine((ushort)device, 0, (ushort)ioPoint.PortNo, out value); } else { ret = DASK.DO_ReadLine((ushort)device, 0, (ushort)ioPoint.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).", device)); case DASK.ErrorCardNotRegistered: throw new DaskException(string.Format("No card registered as {0} CardNumber.", device)); case DASK.ErrorFuncNotSupport: throw new DaskException(string.Format("The {0} function called is not supported by this type of card.", "DO_WriteLine")); case DASK.ErrorInvalidIoChannel: throw new DaskException(string.Format("The specified Channel or Port argument {0} is out of range.", ioPoint.PortNo)); default: throw new DaskException("Unknown error."); } } return(value > 0); }