예제 #1
0
        /**Read Gate parmameters from Gate.xml, then, set parameters to board*/
        public static int load(uint ascanNum, uint ascanPort, string filePath)
        {
            //gate quatity
            int      cnt        = 0;
            int      error_code = 0;
            GateType gateType;
            PGate    param;
            string   fileName = filePath + @"\Gate.xml";
            PGateXml gateXml  = SystemConfig.DeserializeFromXml <PGateXml>(fileName);

            if (gateXml == null)
            {
                return(error_code = -1);
            }

            cnt = gateXml.Gates.Count;

            for (int i = 0; i < cnt; i++)
            {
                param    = gateXml.Gates[i].Param;
                gateType = (GateType)i;

                error_code = setGate(ascanNum, ascanPort, gateType, param);
                if (error_code != 0)
                {
                    return(error_code);
                }
            }
            return(error_code);
        }
예제 #2
0
파일: SaveGate.cs 프로젝트: zjyu1/ASCAN
        /**Read parameter from board,then,save to Gate.xml*/
        public static int save(uint ascanNum, uint ascanPort, string filePath)
        {
            int      error_code = 0;
            string   fileName   = filePath + @"\Gate.xml";
            GateType gateType;
            PGateXml gateXml = new PGateXml();

            gateXml.Gates = new List <PGateItem>();
            PGateItem gateItem = new PGateItem();
            PGate     gate     = new PGate();

            for (int i = 0; i < 4; i++)
            {
                gateType   = (GateType)i;
                error_code = getGate(ascanNum, ascanPort, gateType, ref gate);
                if (error_code != 0)
                {
                    return(error_code);
                }

                gateItem.name  = "Gate" + gateType.ToString();
                gateItem.Param = gate;

                gateXml.Gates.Add(gateItem);
            }
            SystemConfig.SerializeToXml(fileName, gateXml);

            return(error_code);
        }