/// <summary> /// 刷新Adam-6017模块的模拟量输入与数字量输出的状态 /// </summary> public static AdamModule6017 Get_Value_6017(AdamModule6017 Adam) { if (Adam.ComR != null && Adam.IsComR != false) { int[] iData; bool[] bData; Adam = Get_Range(Adam); if (Adam.ComR.Modbus().ReadInputRegs(1, Adam.AI.Length, out iData)) { for (int i = 0; i < Adam.AI.Length; i++) { Adam.AI[i] = AnalogInput.GetScaledValue(Adam6000Type.Adam6017, Adam.Range[i], iData[i]); } } if (Adam.ComT.Modbus().ReadCoilStatus(17, Adam.DO.Length, out bData)) { for (int i = 0; i < Adam.DO.Length; i++) { Adam.DO[i] = Convert.ToInt32(bData[i]); } } } return(Adam); }
/// <summary> /// 获取Adam-6017模块电流/电压输入范围 /// </summary> /// <param name="Adam">已连接的Adam模块</param> /// <returns>返回输入范围</returns> public static AdamModule6017 Get_Range(AdamModule6017 Adam) { if (Adam.ComR != null) { for (int i = 0; i < 8; i++) { Adam.Range[i] = GetChannelRange(Adam.ComR, i); } } return(Adam); }
/// <summary> /// 获取当前使用单位,电压或电流单位 /// </summary> public static string GetSymbol(AdamModule6017 Adam, int Channel) { return(AnalogInput.GetUnitName(Adam6000Type.Adam6017, Adam.Range[Channel])); }
/// <summary> /// 获取浮动格式 /// </summary> public static string RefreshValue(AdamModule6017 Adam, int Channel) { string szFormat = AnalogInput.GetFloatFormat(Adam6000Type.Adam6017, Adam.Range[Channel]); return(Adam.AI[Channel].ToString(szFormat)); }