//泓格 I7565DNM 設定模組IO public uint I7565DNM_SETIO(string ioNo, uint value) { try { clearError(); int boardNo; int io; if (ioNo.Length == 3) { boardNo = int.Parse(ioNo.Substring(0, 1)); io = int.Parse(ioNo.Substring(1)); } else { boardNo = int.Parse(ioNo.Substring(0, 2)); io = int.Parse(ioNo.Substring(2)); } io = io + 1;//IO定義表從0開始 if (deviceNetCtrlMap.Count < boardNo) { //logger.Error("boardNo:" + boardNo + "< deviceNetCtrlMap.Count:" + deviceNetCtrlMap.Count); setError("20001"); return(20001); } DeviceNetCtrl dnm = deviceNetCtrlMap[boardNo.ToString()];//boardNo: 0~63 //舊抓法 //UInt16 IOLen = 0; //byte cPort = Byte.Parse(portNo);//covert port id to byte //byte DesMACID = dnm.getDesMACID();//get macid // //Step 1 先取得目前IO //UInt32 Ret = I7565DNM_DotNET.I7565DNM.I7565DNM_ReadInputData(cPort, DesMACID, dnm.ConType(), ref IOLen, dnm.IODATA); byte cPort = Byte.Parse(portNo);//covert port id to byte ////Step 1 先更新目前IO //UInt32 Ret = dnm.Refresh(cPort);//應該不用更新 //Step 2 變更IO data UInt32 Ret = dnm.SetIO(cPort, io, value); if (Ret != 0) { setError(Ret.ToString()); } return(Ret); } catch (Exception e) { logger.Error(e.StackTrace); setError("DNM90002"); return(90002); } }