Exemplo n.º 1
0
 private void Main_Load(object sender, EventArgs e)
 {
     try
     {
         //增加CLR搜索的路径
         CLRPrivatePathInit();
         #region 读取配置文件
         var opcConfig = ConfigurationManagerExtend.SectionsCast <OpcAddressConfiguration>("Address").FirstOrDefault().Value;
         var tagConfig = ConfigurationManagerExtend.SectionsCast <TagConfiguration>("Tag").FirstOrDefault().Value;
         groupTriggerUpdateRate = tagConfig.TriggerUpdateRate;
         groupDataUpdateRate    = tagConfig.DataUpdateRate;
         tagsQueueNum           = tagConfig.TagsQueueNum;
         reconnectEnable        = opcConfig.ReconnectEnable;
         reConnectInterval      = opcConfig.ReconnectInterval;
         #endregion
         #region OpcClient初始化
         client = OpcFinder(opcConfig.OpcTypeName);
         client.Init(opcConfig);
         //断开服务通知
         client.OpcStatusChangeHandle += this.OpcServerDisConnected;
         ConnectOpc(client);
         #endregion
         #region  连接远程服务器
         ServicesInit();
         ConnectServer();
         #endregion
     }
     catch (Exception ex)
     {
         //消息通知
         LogHelper.Info("通讯服务器校验结果:" + ex.ToString());
         AddMsgToList("通讯服务器校验结果:" + ex.ToString());
         return;
     }
 }
Exemplo n.º 2
0
        private void Main_Load(object sender, EventArgs e)
        {
            try
            {
                #region 读取配置文件
                var opcConfig = ConfigurationManagerExtend.SectionsCast <OpcAddressConfiguration>("Address").FirstOrDefault().Value;
                var tagConfig = ConfigurationManagerExtend.SectionsCast <TagConfiguration>("Tag").FirstOrDefault().Value;
                groupTriggerUpdateRate = tagConfig.TriggerUpdateRate;
                groupDataUpdateRate    = tagConfig.DataUpdateRate;
                reconnectEnable        = opcConfig.ReconnectEnable;
                reConnectInterval      = opcConfig.ReconnectInterval;
                #endregion
                #region OpcClient初始化
                if (opcConfig.OpcProtocolByEnum == OpcProtocol.DA)
                {
                    client = new DaOpc();
                }
                else if (opcConfig.OpcProtocolByEnum == OpcProtocol.UA)
                {
                    client = new UaOpc();
                }

                client.Init(opcConfig);
                //断开服务通知
                client.OpcStatusChangeHandle += this.OpcServerDisConnected;
                ConnectOpc(client);
                #endregion
            }
            catch (Exception ex)
            {
                //记日志
                return;
            }
        }
Exemplo n.º 3
0
        private void Setting_Load(object sender, EventArgs e)
        {
            //读取基础配置文件
            ConfigInit();
            //增加CLR搜索的路径
            CLRPrivatePathInit();
            //加载xml
            XElement doc = XElement.Load(TagConfig.Path);//将加载完成的XML文件显示在TreeView控件中

            RecursionTreeControl(doc, treeTags.Nodes);
            treeTags.ExpandAll();//展开TreeView控件中的所有项

            #region OpcClient初始化
            client = OpcFinder(opcConfig.OpcTypeName);
            client.Init(opcConfig);

            //opc.tcp://127.0.0.1:49328
            //client.OpcStatusChangeHandle = this.OpcServerDisConnected;
            if (client.Connect().Result == false)
            {
                iniSetting();
                //退出
                System.Environment.Exit(0);
            }
            else
            {
                client.CreateGroup("GroupTrigger").ValueChangedHandle = TagValueChanged;
                client.CreateGroup("GroupData");
            }
            #endregion
            tsslServerState.Text      = client.ServerStateDesc;
            tsslServerStartTime.Text  = "时间" + client.ServerStartTime;
            tsslversion.Text          = "版本号:" + client.ServerVersion;
            cmbInterval.SelectedIndex = 2;

            dataGridTags.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        }