Example #1
0
        //一行中获取地址和区域 /根据一行的数据 返回固定的 plc单元格参数 这个函数 是返回绝对地址的
        private bool  getAddrAndArea(DataRow row, ref int mAddr, ref int mArea, ref string DSmode)
        {
            DSmode = row["mode"].ToString().Trim();

            string area     = "";///地址区域
            string valueStr = row["addr"].ToString().Trim();
            int    count    = 0;

            ConstantMethod.getAddrAndAreaByStr(valueStr, ref mAddr, ref area, DeviceId);

            //地址超了 无效 暂且定XDM 最大69999
            if ((mAddr < 0) || (mAddr > Constant.DTTCPMAXAddr))
            {
                return(false);
            }
            if (!int.TryParse(row["count"].ToString().Trim(), out count))
            {
                return(false);
            }
            if (DeviceId == Constant.xzjDeivceId)
            {
                mArea = XJPLCPackCmdAndDataUnpack.AreaGetFromStr(area);
                mAddr = XJPLCPackCmdAndDataUnpack.RelAbsGet(mAddr, mArea, DeviceId);
            }
            else
            {
                mArea = DTTcpCmdPackAndDataUnpack.GetIntAreaFromStr(area);

                mAddr = DTTcpCmdPackAndDataUnpack.GetAbsAddrFromStr(mAddr, area);
            }

            return(true);
        }
Example #2
0
        public DTTcpPlcInfo(int addr, string areaIn, string Mode)
        {
            this.relativeaddr = addr;

            this.StrArea = areaIn;

            absAddr   = DTTcpCmdPackAndDataUnpack.GetAbsAddrFromStr(relativeaddr, StrArea);
            intArea   = DTTcpCmdPackAndDataUnpack.GetIntAreaFromStr(StrArea);
            ValueMode = Mode;
        }
Example #3
0
        public DTTcpPlcInfo(int addr, string areaIn, string Mode, int plcId)
        {
            this.relativeaddr = addr;

            this.StrArea = areaIn;
            //区分 dvp15mc 和 As PLC
            if (plcId == Constant.xzjDeivceId)
            {
                intArea = XJPLCPackCmdAndDataUnpack.AreaGetFromStr(areaIn);
                absAddr = XJPLCPackCmdAndDataUnpack.RelAbsGet(addr, intArea, 0);
            }
            else
            {
                absAddr = DTTcpCmdPackAndDataUnpack.GetAbsAddrFromStr(relativeaddr, StrArea);
                intArea = DTTcpCmdPackAndDataUnpack.GetIntAreaFromStr(StrArea);
            }

            ValueMode = Mode;
        }