示例#1
0
        public bool GetRgvSwitch(int rgvIndex, ref DataTable dtMainplc, ref DataTable dtRgvplc, ref string reStr)
        {
            try
            {
                IPlcRW plcMainPlc = null;
                IPlcRW plcRgv     = null;
                dtMainplc = new DataTable();
                dtMainplc.Columns.Add("索引");
                dtMainplc.Columns.Add("地址");
                dtMainplc.Columns.Add("内容");
                dtRgvplc = new DataTable();
                dtRgvplc.Columns.Add("索引");
                dtRgvplc.Columns.Add("地址");
                dtRgvplc.Columns.Add("内容");
                if (rgvIndex == 1)
                {
                    plcMainPlc = plcRWs[2];
                    plcRgv     = plcRWs[4];
                }
                else if (rgvIndex == 2)
                {
                    plcMainPlc = plcRWs[2];
                    plcRgv     = plcRWs[4];
                }
                else
                {
                    reStr = "RGV序号参数错误";
                    return(false);
                }
                string  stAddr1  = "D2000";
                string  stAddr2  = "D2500";
                int     blockNum = 10;
                short[] val1     = new short[blockNum];
                if (plcMainPlc.ReadMultiDB(stAddr2, blockNum, ref val1))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        string addr = "D" + (int.Parse(stAddr1.Substring(1)) + i).ToString().PadLeft(4, '0');
                        dtMainplc.Rows.Add(i + 1, addr, val1[i]);
                    }
                }

                short[] val2 = new short[blockNum];
                if (plcRgv.ReadMultiDB(stAddr1, blockNum, ref val2))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        string addr = "D" + (int.Parse(stAddr2.Substring(1)) + i).ToString().PadLeft(4, '0');
                        dtRgvplc.Rows.Add(i + 1, addr, val2[i]);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                reStr = "获取RGV中转数据发生异常" + ex.ToString();
                return(false);
            }
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string jxDB        = ConfigurationManager.AppSettings["JXDataBase"];
            string jxDBUserPwd = ConfigurationManager.AppSettings["JXDataBaseUserPwd"];

            jxDBUserPwd = EncAndDec.Decode(jxDBUserPwd, "zwx", "xwz");
            if (string.IsNullOrEmpty(jxDBUserPwd))
            {
                MessageBox.Show("数据库连接信息错误");
                return;
            }
            PubConstant.ConnectionString = jxDB + jxDBUserPwd;

            this.comboBoxPlcObjList.SelectedIndex = 0;


            //  this.tabPage1.Enabled = false;
            devBll                   = new DeviceBll();
            ctlTaskBll               = new ControlTaskBll();
            ctlTaskIFBll             = new ControlInterfaceBll();
            palletBll                = new OCVPalletBll();
            batteryBll               = new OCVBatteryBll();
            manTaskBll               = new ManageTaskBll();
            makeCardBll              = new MakeCardRecordBll();
            plcRwObj                 = new PLCRW();
            plcRwObj.eventLinkLost  += PlcLostConnectHandler;
            plcRwObj2                = new PLCRWNet();
            plcRwObj2.eventLinkLost += PlcLostConnectHandler;
            if (this.comboBoxPlcObjList.Text == "PLC控件")
            {
                plcRwIF = plcRwObj;
            }
            else if (this.comboBoxPlcObjList.Text == "重新实现MC协议")
            {
                plcRwIF = plcRwObj2;
            }

            plcFx485 = new PlcRW485BD();
            plcFx485.StationNumber = 1;
            HFReaderIF readerIF = new HFReaderIF();

            rfidRW          = new SgrfidRW(1);
            rfidRW.ReaderIF = readerIF;
            this.comboBoxComports.Items.Clear();

            string[] ports = System.IO.Ports.SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                this.comboBoxComports.Items.Add(port);
                this.comboBoxFXComs.Items.Add(port);
            }
            if (ports != null && ports.Count() > 0)
            {
                this.comboBoxComports.Text = ports[0];
                this.comboBoxFXComs.Text   = ports[0];
            }
            makeCardCount = makeCardBll.GetRecordCount(" ");
            this.labelMakeCardCount.Text = "计数:" + makeCardCount.ToString();
        }
示例#3
0
        public CCDNGHandler(IPlcRW plcRw2, string rfid, ILogRecorder logRec)
        {
            this.PlcRw2      = plcRw2;
            this.logRecorder = logRec;
            this.gzbRfid     = rfid;

            addrPosCfg[1] = "D8730"; //A通道1位置
            addrPosCfg[2] = "D8731"; //A通道2位置
        }
示例#4
0
        public ECAMSTransPort(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll, ControlInterfaceBll ctlInterfaceBll, ControlTaskBll ctlTaskBll, LogBll logBll)
            : base(devModel, plcRW, devBll, ctlInterfaceBll, ctlTaskBll, logBll)
        {
            switch (devModel.DeviceID)
            {
            case "2002":
            {
                devName = "A1库入库口";
                break;
            }

            case "2003":
            {
                devName = "A1库分容出口";
                break;
            }

            case "2004":
            {
                devName = "A1库分容入口";
                break;
            }

            case "2005":
            {
                devName = "A1库出口";
                break;
            }

            case "2006":
            {
                devName = "B1库入口";
                break;
            }

            case "2007":
            {
                devName = "B1库二次检测出口";
                break;
            }

            case "2008":
            {
                devName = "B1库的空筐入口";
                break;
            }

            case "2009":
            {
                devName = "B1库的出口";
                break;
            }

            default:
                break;
            }
        }
示例#5
0
 private void comboBoxPlcObjList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.comboBoxPlcObjList.Text == "PLC控件")
     {
         plcRwIF = plcRwObj;
     }
     else if (this.comboBoxPlcObjList.Text == "重新实现MC协议")
     {
         plcRwIF = plcRwObj2;
     }
 }
示例#6
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="devModel"></param>
        /// <param name="plcRW"></param>
        /// <param name="ctlInterfaceBll"></param>
        /// <param name="ctlTaskBll"></param>
        public DevBase(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll)
        {
            this.devModel = devModel;
            this.plcRW    = plcRW;
            this.devBll   = devBll;


            plcDataDb1     = new byte[devModel.BytesLenDB1];
            plcDataDb2     = new byte[devModel.BytesLenDB2];
            plcDataDb1Last = new byte[devModel.BytesLenDB1];
            plcDataDb2Last = new byte[devModel.BytesLenDB2];
            DebugSimModel  = true; //模拟调试用
        }
示例#7
0
        public ScrewNGHandler(IPlcRW plcRw, IPlcRW plcRw2, int channelIndex, ILogRecorder logRec)
        {
            this.PlcRw            = plcRw;
            this.PlcRw2           = plcRw2;
            this.logRecorder      = logRec;
            this.currChannelIndex = channelIndex;
            addrPosCfg["1-1"]     = "D8730"; //A通道1位置
            addrPosCfg["1-2"]     = "D8731"; //A通道2位置
            addrPosCfg["2-1"]     = "D8732"; //B通道1位置
            addrPosCfg["2-2"]     = "D8733"; //B通道2位置

            addrChannelCfg[1] = "D8000";     //A通道
            addrChannelCfg[2] = "D8001";     //B通道
        }
示例#8
0
 private void BusinessLoop()//List<CtlNodeBaseModel> myNodeList
 {
     try
     {
         IPlcRW           plc1  = GetPlcByID(1);
         IPlcRW           plc2  = GetPlcByID(2);
         IPlcRW           plc3  = GetPlcByID(3);
         CtlNodeBaseModel node1 = FindNode("OPA004");
         plc1.WriteMultiDB(node1.Db1StartAddr, node1.Db1BlockNum, node1.Db1ValsToSnd);
         CtlNodeBaseModel node2 = FindNode("OPB001");
         plc2.WriteMultiDB(node2.Db1StartAddr, node2.Db1BlockNum, node2.Db1ValsToSnd);
         //CtlNodeBaseModel node3 = FindNode("OPC003");
         //plc3.WriteMultiDB(node3.Db1StartAddr, node3.Db1BlockNum, node3.Db1ValsToSnd);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
示例#9
0
        private void buttonConnectPlc_Click(object sender, EventArgs e)
        {
            string PlcIP   = this.textBoxPlcIP.Text;   //ConfigurationManager.AppSettings["plcIP"];
            string PlcPort = this.textBoxPlcPort.Text; // ConfigurationManager.AppSettings["plcPort"];
            string plcAddr = PlcIP + ":" + PlcPort;
            string reStr   = "";

            //  plcRwObj2.ConnStr = plcAddr;
            // (plcRwIF as PLCRWNet).ConnStr = plcAddr;
            plcRwObj2.ConnStr = plcAddr;
            switch (cbxPlcCata.Text)
            {
            case "FX5U":
            {
                plcRwObj2.PlcCata = EnumPlcCata.FX5U;
                break;
            }

            case "Q系列":
            {
                plcRwObj2.PlcCata = EnumPlcCata.Qn;
                break;
            }

            case "Fx3uNET模块":
            {
                plcRwObj2.PlcCata = EnumPlcCata.FX3UENET;
                break;
            }

            default:
                break;
            }
            plcRwIF = plcRwObj2;
            if (plcRwIF.ConnectPLC(ref reStr))
            {
                this.buttonClosePlc.Enabled = true;
                this.buttonReadPlc.Enabled  = true;
                this.buttonWritePlc.Enabled = true;
            }
            AddLog(reStr);
        }
示例#10
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="devModel"></param>
 /// <param name="plcRW"></param>
 /// <param name="ctlInterfaceBll"></param>
 /// <param name="ctlTaskBll"></param>
 public ECAMSDevBase(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll, ControlInterfaceBll ctlInterfaceBll, ControlTaskBll ctlTaskBll, LogBll logBll)
 {
     this.devModel        = devModel;
     this.plcRW           = plcRW;
     this.devBll          = devBll;
     this.ctlInterfaceBll = ctlInterfaceBll;
     this.ctlTaskBll      = ctlTaskBll;
     this.logBll          = logBll;
     this.rfidRecordBll   = new RfidRdRecordBll();
     this.palletTraceBll  = new PalletHistoryRecordBll();
     //plcDataDb1 = new byte[devModel.BytesLenDB1];
     //plcDataDb2 = new byte[devModel.BytesLenDB2];
     //plcDataDb1Last = new byte[devModel.BytesLenDB1];
     //plcDataDb2Last = new byte[devModel.BytesLenDB2];
     this.dicCommuDataDB1 = new Dictionary <int, DevCommDatatype>();
     this.dicCommuDataDB2 = new Dictionary <int, DevCommDatatype>();
     dicDataDB1Last       = new Dictionary <int, object>();
     dicDataDB2Last       = new Dictionary <int, object>();
     dicDB1Read           = new Dictionary <int, object>();
     //DebugMode = true; //模拟调试用
 }
示例#11
0
        public bool ConnPlc(string ip, int port, EnumPlcCata plcCata, EnumNetProto proto)
        {
            try
            {
                if (SimMode)
                {
                    plcRW = new PlcRWSim();
                }
                else
                {
                    PLCRwMCPro plcRwMC = new PLCRwMCPro(plcCata, 20, 20);
                    plcRW = plcRwMC;

                    plcRwMC.PlcCata = plcCata;

                    plcRwMC.ConnStr = ip + ":" + port.ToString();
                }
                stacker.PlcRW = plcRW;
                string reStr = "";
                if (plcRW.ConnectPLC(ref reStr))
                {
                    Console.WriteLine("PLC连接成功!");
                    return(true);
                }
                else
                {
                    Console.WriteLine("PLC连接失败!");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(false);
            }
        }
示例#12
0
        //public bool DelNode(string nodeName,ref string reStr)
        //{
        //    return false;
        //}

        #endregion
        #region 内部接口
        protected override void TaskloopProc()
        {
            while (!exitRunning)
            {
                Thread.Sleep(loopInterval);
                if (pauseFlag)
                {
                    continue;
                }

                // logRecorder.AddDebugLog("线程:" + threadID,"线程:" + threadID+"循环开始:");

                IPlcRW plcRW = null;
                if (!SysCfgModel.PlcCommSynMode)
                {
                    plcRW = nodeList[0].PlcRW;

                    if (!SysCfgModel.SimMode)
                    {
                        if (lastPlcStat == plcRW.PlcStatCounter)
                        {
                            continue;
                        }
                    }
                }
                for (int nodeIndex = 0; nodeIndex < nodeList.Count(); nodeIndex++)
                {
                    DateTime         commSt = System.DateTime.Now;
                    CtlNodeBaseModel node   = nodeList[nodeIndex];
                    try
                    {
                        string reStr = "";

                        //if (!node.ReadDB1())
                        //{
                        //    continue;
                        //}
                        // DateTime commSt = System.DateTime.Now;
                        if (!node.ReadDB2(ref reStr))
                        {
                            continue;
                        }
                        if (!node.ExeBusiness(ref reStr))
                        {
                            continue;
                        }

                        // commSt = System.DateTime.Now;
                        if (!node.NodeCmdCommit(true, ref reStr))
                        {
                            continue;
                        }

                        DateTime commEd = System.DateTime.Now;
                        TimeSpan ts     = commEd - commSt;
                        //   string dispCommInfo = string.Format("PLC控制周期:{0}毫秒", (int)ts.TotalMilliseconds);
                        if (ts.TotalMilliseconds > 500)
                        {
                            // node.LogRecorder.AddDebugLog(node.NodeName, dispCommInfo);
                            node.CurrentStat.StatDescribe = string.Format("周期:{0}毫秒", (int)ts.TotalMilliseconds);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(node.NodeName + ex.ToString());
                        node.ThrowErrorStat(ex.ToString(), EnumNodeStatus.设备故障);
                    }
                }
                //if (!SysCfgModel.PlcCommSynMode)
                //{
                //    lastPlcStat = plcRW.PlcStatCounter;
                //}

                //if (threadID == 1)
                //{
                //    Console.WriteLine("线程:" + threadID + "循环结束");
                //}
            }
        }
示例#13
0
 public XYZGriper(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll)
     : base(devModel, plcRW, devBll)
 {
 }
示例#14
0
        //public TestWarehouseOutBusiness WarehouseOutTest
        //{
        //    get
        //    {
        //        return warehouseOutTest;
        //    }
        //    private set { }
        //}
        public bool InitTestManager(ref string resultStr)
        {
            devDicList = new Dictionary <string, DevBase>();
            devBll     = new DeviceBll();
            plcRW      = new PlcRWSim();
            //1 创建设备对象
            IList <DeviceModel> devList = devBll.GetModelList(" ");

            foreach (DeviceModel devME in devList)
            {
                if (devME == null)
                {
                    continue;
                }
                DevBase ecamsDev = null;
                if (devME.DeviceType == EnumDevType.堆垛机.ToString())
                {
                    ecamsDev = new Stacker(devME, plcRW, devBll);
                }
                else if (devME.DeviceType == EnumDevType.站台.ToString())
                {
                    if (devME.BytesLenDB1 <= 0 || devME.BytesLenDB2 <= 0)
                    {
                        continue;
                    }
                    ecamsDev = new TransPort(devME, plcRW, devBll);
                }
                else if (devME.DeviceType == EnumDevType.机械手.ToString())
                {
                    ecamsDev = new XYZGriper(devME, plcRW, devBll);
                }
                else
                {
                    ecamsDev = null;
                    continue;
                }
                if (!ecamsDev.Init())
                {
                    resultStr = ecamsDev.DevModel.DeviceType + " " + ecamsDev.DevModel.DeviceID + " " + "初始化失败";
                    return(false);
                }
                devDicList[devME.DeviceID] = ecamsDev;
            }

            //2 创建业务模拟对象
            warehouseInOutTest = new TestWarehouseInOutBusiness();
            // warehouseOutTest = new TestWarehouseOutBusiness();
            warehouseInOutTest.Stacker1001   = devDicList["1001"] as Stacker;
            warehouseInOutTest.Stacker1002   = devDicList["1002"] as Stacker;
            warehouseInOutTest.TransPort2002 = devDicList["2002"] as TransPort;
            warehouseInOutTest.TransPort2004 = devDicList["2004"] as TransPort;
            warehouseInOutTest.TransPort2006 = devDicList["2006"] as TransPort;
            warehouseInOutTest.TransPort2008 = devDicList["2008"] as TransPort;
            warehouseInOutTest.TransPort2009 = devDicList["2009"] as TransPort;
            //warehouseInOutTest.TransPort2003 = devDicList["2003"] as TransPort;
            //warehouseInOutTest.TransPort2005 = devDicList["2005"] as TransPort;
            //warehouseInOutTest.TransPort2007 = devDicList["2007"] as TransPort;
            //warehouseInOutTest.TransPort2009 = devDicList["2009"] as TransPort;

            fillPalletTest             = new TestBusinessFillPallet();
            fillPalletTest.Grisper5001 = devDicList["5001"] as XYZGriper;

            grispTest1         = new TestBusinessGrisp();
            grispTest1.Grisper = devDicList["5002"] as XYZGriper;
            grispTest2         = new TestBusinessGrisp();
            grispTest2.Grisper = devDicList["5003"] as XYZGriper;

            //3
            sysWorkingThread = new Thread(new ThreadStart(SysWorkingProc));
            sysWorkingThread.IsBackground = true;
            sysWorkingThread.Name         = "业务测试主线程";

            return(true);
        }
示例#15
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Console.SetOut(new TextBoxWriter(this.richTextBoxLog));
            plcForm2.MdiParent = this;
            this.panelPlc2.Controls.Clear();
            this.panelPlc2.Controls.Add(plcForm2);
            plcForm2.Dock = DockStyle.Fill;
            plcForm2.Show();

            rfidWQForm.MdiParent = this;
            this.panelWqrfid.Controls.Clear();
            this.panelWqrfid.Controls.Add(rfidWQForm);
            rfidWQForm.Dock = DockStyle.Fill;
            rfidWQForm.Show();

            rfidSgUrb3Form.MdiParent = this;
            this.panelSgUrb3.Controls.Clear();
            this.panelSgUrb3.Controls.Add(rfidSgUrb3Form);
            rfidSgUrb3Form.Dock = DockStyle.Fill;
            rfidSgUrb3Form.Show();


            // 隐藏不用 的tabpage
            //this.tabControl1.TabPages.Remove(this.tabPage1);
            // this.tabControl1.TabPages.Remove(this.tabPage3);
            this.tabControl1.TabPages.Remove(this.tabPage5);
            // this.comboBoxPlcObjList.SelectedIndex = 0;
            //  this.tabPage1.Enabled = false;
            this.comboBoxDatabitSel.Items.AddRange(new string[] { "32位整数", "64位整数" });
            this.comboBoxDatabitSel.SelectedIndex = 0;

            #region PLC相关
            this.cbxPlcCata.Items.AddRange(new string[] { "FX5U", "Q系列", "Fx3uNET模块" });
            this.cbxPlcCata.SelectedIndex = 0;
            plcRwObj2 = new PLCRwMCPro(EnumPlcCata.FX5U, 1000, 1000);
            plcRwObj2.eventLinkLost += PlcLostConnectHandler;
            plcRwIF = plcRwObj2;

            plcFx485 = new PlcRW485BD();
            plcFx485.StationNumber = 1;
            #endregion


            HFReaderIF readerIF = new HFReaderIF();
            rfidRW          = new SgrfidRW(1);
            rfidRW.ReaderIF = readerIF;
            this.comboBoxComports.Items.Clear();

            barcodeReader = new BarcodeRWHonevor(1);

            string[] ports = System.IO.Ports.SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                this.comboBoxComports.Items.Add(port);
                this.comboBoxFXComs.Items.Add(port);
                this.comboBoxBarcode.Items.Add(port);
                this.comboBoxAirdetect.Items.Add(port);
            }
            if (ports != null && ports.Count() > 0)
            {
                this.comboBoxComports.Text = ports[0];
                this.comboBoxFXComs.Text   = ports[0];
            }
            rfidWorkingThread = new Thread(new ThreadStart(SysWorkingProc));
            rfidWorkingThread.IsBackground = true;

            this.printer = new PrinterRW(1, "", 8000);
            string dbConn = string.Format("Data Source ={0}\\SQLEXPRESS;Initial Catalog=FangTAIZaojuA;User ID=sa;Password=123456;", this.textBoxPrinterIP.Text);

            this.printerDB = new PrinterRWdb(dbConn);

            //MES 测试初始化
            this.textBoxMESwsAddr.Text = "http://192.168.100.90:8188/soap/EventService?wsdl";
            this.comboBoxInterfaces.Items.AddRange(new string[] { "assembleDown", "assembleRepair" });
            this.comboBoxInterfaces.SelectedIndex = 0;
            this.comboBoxDTs.Items.AddRange(new string[] { "FT_MES_STEP_INFO", "FT_MES_STEP_INFO_DETAIL" });
            this.comboBoxDTs.SelectedIndex = 0;
            this.textBoxMesParams.Text     = "1002002100086L451607280194,L45";
            this.richTextBoxMesDBConn.Text = @"Data Source=(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.94)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PRQMESDB)
    )
  )
;User Id=prqminda1;Password=prqminda1;Connection Timeout=5;";
//            this.richTextBoxMesDBConn.Text =  @"Data Source=(DESCRIPTION =
//    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.94)(PORT = 1521))
//    (CONNECT_DATA =
//      (SERVER = DEDICATED)
//      (SERVICE_NAME = PRQMESDB)
//    )
//  )
//;User Id=prqminda1;Password=prqminda1;"; //这个也可以放到Web.Config中。

            //气密
            airDetecter = new AirDetectFL295CRW(1, "");
        }
示例#16
0
 private void comboBoxPlcObjList_SelectedIndexChanged(object sender, EventArgs e)
 {
     plcRwIF = plcRwObj2;
 }
示例#17
0
        public bool ConfigInit(ref string reStr)
        {
            nodeList      = new List <CtlNodeBaseModel>();
            threadList    = new List <ThreadBaseModel>();
            rfidList      = new List <IrfidRW>();
            barcodeRWList = new List <IBarcodeRW>();
            airDetectList = new List <IAirlossDetectDev>();
            printerList   = new List <IPrinterInfoDev>();
            plcRWList     = new List <IPlcRW>();
            IPlcRW          plcRW      = null;
            IPrinterInfoDev prienterRW = null;

            try
            {
                if (!PLProcessModel.SysCfgModel.LoadCfg(ref reStr))
                {
                    return(false);
                }
                string xmlCfgFile = System.AppDomain.CurrentDomain.BaseDirectory + @"data/DevConfigFTzj.xml";
                if (!File.Exists(xmlCfgFile))
                {
                    reStr = "系统配置文件:" + xmlCfgFile + " 不存在!";
                    return(false);
                }
                XElement root      = XElement.Load(xmlCfgFile);
                XElement runModeXE = root.Element("sysSet").Element("RunMode");
                string   simStr    = runModeXE.Attribute("sim").Value.ToString().ToUpper();
                if (simStr == "TRUE")
                {
                    NodeFactory.SimMode = true;
                    SysCfgModel.SimMode = true;
                }
                else
                {
                    NodeFactory.SimMode = false;
                    SysCfgModel.SimMode = false;
                }
                if (runModeXE.Attribute("mesTestMode") != null)
                {
                    if (runModeXE.Attribute("mesTestMode").Value.ToString().ToUpper() == "TRUE")
                    {
                        SysCfgModel.MesTestMode = true;
                    }
                    else
                    {
                        SysCfgModel.MesTestMode = false;
                    }
                }
                //1 解析结点信息
                XElement CtlnodeRoot = root.Element("CtlNodes");
                if (!ParseCtlnodes(CtlnodeRoot, ref reStr))
                {
                    return(false);
                }
                //2 解析通信设备信息
                if (NodeFactory.SimMode)
                {
                    plcRW = new PlcRWSim();
                    plcRWList.Add(plcRW);
                    prienterRW = new PrinterRWSim(1);
                    printerList.Add(prienterRW);
                    for (int i = 0; i < 13; i++)
                    {
                        int     rfidID = 0;// i + 1;
                        IrfidRW rfidRW = new rfidRWSim();
                        rfidRW.ReaderID = (byte)rfidID;
                        rfidList.Add(rfidRW);
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        int        barcodeID  = i + 1;
                        IBarcodeRW barscanner = new BarcodeRWSim(barcodeID);
                        barcodeRWList.Add(barscanner);
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        int airDetectID = i + 1;
                        IAirlossDetectDev airDetecter = new AirDetectRWSim(airDetectID);
                        airDetectList.Add(airDetecter);
                    }
                }
                else
                {
                    XElement commDevXERoot = root.Element("CommDevCfg");
                    if (!ParseCommDevCfg(commDevXERoot, ref reStr))
                    {
                        return(false);
                    }
                    plcRW = plcRWList[0];
                }

                //3 给节点分配设备读写接口对象

                for (int i = 0; i < nodeList.Count(); i++)
                {
                    CtlNodeBaseModel node = nodeList[i];
                    node.PlcRW   = plcRW;
                    node.SimMode = NodeFactory.SimMode;
                }
                for (int i = 0; i < nodeList.Count() - 1; i++)
                {
                    CtlNodeBaseModel node = nodeList[i];
                    node.RfidRW = rfidList[i];
                }
                prienterRW             = PrinterRWList[0];
                nodeList[0].BarcodeRW  = barcodeRWList[0];
                nodeList[12].BarcodeRW = barcodeRWList[1];
                nodeList[13].BarcodeRW = barcodeRWList[2];
                (nodeList[1] as NodeAirlossCheck).AirDetectRW = airDetectList[0];
                (nodeList[2] as NodeAirlossCheck).AirDetectRW = airDetectList[1];
                (nodeList[3] as NodeAirlossCheck).AirDetectRW = airDetectList[2];
                (nodeList[11] as NodeFaceCheck).PrienterRW    = prienterRW;



                //4 线程-结点分配
                XElement ThreadnodeRoot = root.Element("ThreadAlloc");
                if (!ParseTheadNodes(ThreadnodeRoot, ref reStr))
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                reStr = "加载系统配置文件出现异常:" + ex.ToString();
                return(false);
            }


            return(true);
        }
示例#18
0
 public TransPort(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll)
     : base(devModel, plcRW, devBll)
 {
 }