Ejemplo n.º 1
0
        public List <string> getDevDetails(HARTDevice dev)
        {
            List <string> devInfo   = new List <string>();
            CDDLBase      pItemBase = null;

            if (dev.getItembyID(DEVICE_DISTRIBUTOR, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar devdis = pItemBase as CDDLVar;
                    devdis.getDispValue().SetValue((int)dev.ddbDeviceID.wManufacturer, valueType_t.isIntConst);
                    m_strDistributor = devdis.GetDispString();
                }
            }

            if (dev.getItembyID(DEVICE_DEVICE_TYPE, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar devtype = pItemBase as CDDLVar;
                    m_strType = devtype.GetDispString();
                }
            }

            m_strDDRevision = dev.parentform.strDDRevision;
            m_strRevision   = dev.parentform.strDeviceRevision;
            devInfo.Add(m_strDistributor);
            devInfo.Add(m_strType);
            devInfo.Add(m_strDDRevision);
            devInfo.Add(m_strRevision);
            return(devInfo);
            //strDDfile = dev.;
        }
Ejemplo n.º 2
0
        public mainpage()
        {
            strDeviceRevision = "";
            strDDRevision     = "";
            strManufacturer   = "";
            strDeviceType     = "";

            pVarList      = new CVarList();
            pVarListWrite = new CVarList();

            hartDev = new HARTDevice(this);

            hcfg.ddRoot = "c:\\hcf\\ddl\\library\\";//by default
        }
Ejemplo n.º 3
0
        public void getDevCommStatus(HARTDevice dev)
        {
            CDDLBase pItemBase = null;

            if (dev.getItembyID(DeviceDetails.DEVICE_COMM_STATUS, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar comstatus = pItemBase as CDDLVar;
                    nCommStatusValue = comstatus.getDispValue().GetInt();
                }
            }

            if (dev.getItembyID(DeviceDetails.DEVICE_COMM48_STATUS, ref pItemBase))
            {
                if (pItemBase.eType == nitype.nVar)
                {
                    CDDLVar devstatus = pItemBase as CDDLVar;
                    nDevStatusValue = devstatus.getDispValue().GetInt();
                }
            }
        }
Ejemplo n.º 4
0
 public HartTestFuncs(HARTDevice hdev)
 {
     hartDev = hdev;
     initFuncs();
 }
Ejemplo n.º 5
0
 public HartTestFuncs(StreamWriter sw)
 {
     hartDev = new HARTDevice(null);
     initFuncs();
     logSw = sw;
 }
Ejemplo n.º 6
0
 public HartTestFuncs()
 {
     hartDev = new HARTDevice(null);
     initFuncs();
     logSw = null;
 }
Ejemplo n.º 7
0
        public rtNewDev newDevice(/*Identity_s ident*/ StreamWriter sw)
        {
            rtNewDev rt = rtNewDev.eSuc;

            logSw = sw;
            DevDDList.Clear();

            hartDev = new HARTDevice(this);

            returncode rc;

            if (!hcfg.bOffline)
            {
                strManufacturer = "";
                rc = GetIdentity(0, sw);//获得设备信息
                if (rc != returncode.eOk)
                {
                    switch (rc)
                    {
                    case returncode.eSerErr:
                        //MessageBox.Show("串口错误");
                        rt = rtNewDev.eCommSerErr;
                        break;

                    default:
                        //MessageBox.Show("未知错误");
                        rt = rtNewDev.eOther;
                        break;
                    }
                    return(rt);
                }

                //Thread th = new Thread(RecvData);
                //th.Start();

                returncode creply = RecvData(sw);

                if (creply == returncode.eOk)
                {
                    //string msgRcv = buildStringTypeInfo(rcvlen, rcvbuf);

                    //dispMsgRcv(msgRcv);

                    if (rcvlen != 0)
                    {
                        Rcv_00(rcvbuf, rcvlen, sw);
                        rcvlen = 0;
                    }
                }

                else if (creply == returncode.eTimeOutErr)
                {
                    //MessageBox.Show(Resource.NoRsp, Resource.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(rtNewDev.eCommTimeout);
                }

                else if (creply == returncode.eCloseErr)
                {
                    //MessageBox.Show(Resource.NonePort, Resource.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(rtNewDev.eCommSerErr);
                }
                //this.Text = await testString();
            }
            else
            {
                //"C:\hcf\ddl\Library\00601e\e188"
                //strManufacturer = "000026";//"00601e";//
                //strDeviceType = "0006";//"e188";//
                //strManufacturer = "00601e";
                //strDeviceType = "e188";
                //strDeviceRevision = "3";//"1";
                //strDDRevision = "7";// "1";
                if (strManufacturer != null && strManufacturer != "")
                {
                    if (strManufacturer.Contains("0x"))
                    {
                        strManufacturer = strManufacturer.Remove(0, 2);
                    }
                    hartDev.ddbDeviceID.wManufacturer = Convert.ToUInt16(strManufacturer, 16);// 0x26;//0x00601e;//
                    if (strDeviceType.Contains("0x"))
                    {
                        strDeviceType = strDeviceType.Remove(0, 2);
                    }
                    hartDev.ddbDeviceID.wDeviceType = Convert.ToUInt16(strDeviceType, 16);// 0x6;//0xe188;//
                }
            }

            rc = identifyDDfile();

            if (rc == returncode.eOk)
            {
                dict = new HartDictionary(locLan);
                if (eFFVersionMajor < 8)
                {                            // then we have to load extra stuff
                    buildDicitonary();       // uses chDbdir to open and fill
                }
                if (eFFVersionMajor <= 0x08) // temporary, delete this line for fm8 v 8.3 [2/25/2014 timj]
                {                            //   fill all of the items & attributes of the abstract device, also dict & strings
                    getDevice();
                }
            }
            else if (rc == returncode.eFileErr)
            {
                return(rtNewDev.eDDFailed);
            }
            else
            {
                return(rtNewDev.eNoDD);
            }
            return(rt);
        }