Beispiel #1
0
        private returncode getDevice(/*DD_Key_t wrkingKey, aCdevice* pAbstractDev, CDictionary dictionary, LitStringTable* litStrings,*/ bool isInTokenizer = false) // recurse down the entire hierarchy
        {
            returncode rc = returncode.eOk;

            devDesc = new DDlDevDescription(hcfg.ddRoot);
            rc      = devDesc.Initialize(strInputFileName, locLan, dict);

            /*
             * char erInputFileName[MAX_FILE_NAME_PATH];
             *
             * if (false == bRetVal)// can't be null... && NULL != chInputFileName)
             * {
             *  char tmpFileName[MAX_FILE_NAME_PATH];
             *  unsigned filelen = strlen(chInputFileName) - 4;
             *  strncpy(erInputFileName, chInputFileName, filelen + 5);/* stevev-for better reporting /
             *  strncpy(tmpFileName, chInputFileName, filelen);
             *  tmpFileName[filelen] = '\0';
             *  if (tmpFileName)
             *  {
             *      strcat(tmpFileName, ".fms");
             *      tmpFileName[filelen + 4] = '\0';
             *      strcpy(chInputFileName, tmpFileName);
             *      chInputFileName[filelen + 4] = '\0';
             *      bRetVal = devDesc.Initialize(chInputFileName, "|en|", dictionary);
             *  }
             * }
             */

            if (rc != returncode.eOk)
            {
                return(rc);
            }

            int iDevItemListSize = devDesc.ItemsList.Count;

            devDesc.LoadDeviceDescription(isInTokenizer);
            return(rc);
        }
Beispiel #2
0
        private returncode identifyDDfile()
        {
            returncode rc = returncode.eErr;

            makeDirTree();

            DevTypStruct find = new DevTypStruct();

            scanDirTree(ref find);

            strInputFileName = hcfg.ddRoot + "\\" + strManufacturer + "\\" + strDeviceType + "\\"
                               + string.Format("{0:D2}", find.devrev) + string.Format("{0:D2}", find.ddrev) + "." + find.ext;

            Common.chInputFileName = strInputFileName;
            BinaryReader br;

            // 读取文件
            try
            {
                br = new BinaryReader(new FileStream(strInputFileName, FileMode.Open));
            }
            catch (IOException e11)
            {
                Console.WriteLine(e11.Message + "\n Cannot open file.");
                return(returncode.eFileErr);
            }

            DDlDevDescription.DDOD_HEADER header = new DDlDevDescription.DDOD_HEADER();
            header.byManufacturer = new byte[3];

            DDlDevDescription.ReadHeader(br, ref header);

            int mfg = header.byManufacturer[0] << 16 |
                      header.byManufacturer[1] << 8 |
                      header.byManufacturer[2];

            header.device_type = (ushort)(((header.device_type & 0x00ff) << 8) |
                                          ((header.device_type & 0xff00) >> 8));

            eFFVersionMajor = header.tok_rev_major;
            eFFVersionMinor = header.tok_rev_minor;
            if (eFFVersionMajor < 5)// FDI version number
            {
                if (eFFVersionMajor == 3)
                {
                    eFFVersionMajor += 7;// translate to hart version
                }
                if (eFFVersionMajor == 4)
                {
                    eFFVersionMajor += 6;// translate to hart version	// fdi4 => hcf10 [4/3/2014 timj]
                }
            }

            if ((eFFVersionMajor != find.bffver) ||
                (mfg != hartDev.ddbDeviceID.wManufacturer) ||
                (header.device_type != hartDev.ddbDeviceID.wDeviceType) ||
                (header.device_revision != find.devrev) ||
                (header.dd_revision != find.ddrev))
            {// header info does not match filename
             // error message -
                //MessageBox.Show("Error: DD File header information does not match file name.");
                br.Close();
                return(returncode.eFileErr);
            }
            br.Close();

            //////VerificationLevel//??????

            if (DevDDList.Count > 0)
            {
                rc = returncode.eOk;
            }

            return(rc);
        }