Exemplo n.º 1
0
        public UAIniSetting()
        {
            InitializeComponent();
            //设置默认选择项
            opcConfig = ConfigurationManagerExtend.SectionsCast <OpcAddressConfiguration>("Address").FirstOrDefault().Value;
            tagConfig = ConfigurationManagerExtend.SectionsCast <TagConfiguration>("Tag").FirstOrDefault().Value;


            this.cmbOpcProtocol.Items.AddRange(new object[] { OpcProtocol.DA, OpcProtocol.UA });
            this.cmbUseSecurity.Items.AddRange(new object[] { true, false });
            this.cmbReconnectEnable.Items.AddRange(new object[] { true, false });

            this.cmbOpcProtocol.SelectedIndexChanged += new System.EventHandler(this.cmbOpcProtocol_SelectedIndexChanged);
            this.cmbUseSecurity.SelectedIndexChanged += new System.EventHandler(this.cmbUseSecurity_SelectedIndexChanged);

            this.cmbOpcProtocol.SelectedItem = opcConfig.OpcProtocolByEnum;
            this.txtIP.Text = opcConfig.DaAddress.Ip;
            this.cmbServerName.Items.Add(opcConfig.DaAddress.ServerName);
            this.cmbServerName.SelectedIndex = 0;
            this.txtUri.Text                       = opcConfig.UaAddress.Uri;
            this.txtUserName.Text                  = opcConfig.UaAddress.UserName;
            this.txtPassword.Text                  = opcConfig.UaAddress.Password;
            this.cmbUseSecurity.SelectedItem       = opcConfig.UaAddress.UseSecurity;
            this.cmbReconnectEnable.SelectedItem   = opcConfig.ReconnectEnable;
            this.cmbReconnectInterval.SelectedItem = opcConfig.ReconnectInterval.ToString();
            this.cmbTagsQueueNum.SelectedItem      = tagConfig.TagsQueueNum.ToString();
            LayoutInit();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 读取配置文件
 /// </summary>
 private void ConfigInit()
 {
     opcConfig = ConfigurationManagerExtend.SectionsCast <OpcAddressConfiguration>("Address").FirstOrDefault().Value;
     if (opcConfig.OpcProtocolByEnum == OpcProtocol.Else)
     {
         UAIniSetting iniS = new UAIniSetting();
         if (iniS.ShowDialog() == DialogResult.OK)
         {
             opcConfig = ConfigurationManagerExtend.SectionsCast <OpcAddressConfiguration>("Address").FirstOrDefault().Value;
         }
         else
         {
             this.Close();
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 初始化设置
 /// 1、初始化OPCServer
 /// 2、遍历OPCServer列表
 /// </summary>
 /// <param name="ip"></param>
 public void Init(OpcAddressConfiguration address)
 {
     this.Address = address;
     //获取本地计算机上的OPCServerName
     try
     {
         KepServer.ServerShutDown += new DIOPCServerEvent_ServerShutDownEventHandler(KepServer_DisConnected);
         KepServer.OPCGroups.DefaultGroupIsActive   = true;
         KepServer.OPCGroups.DefaultGroupDeadband   = 0;
         KepServer.OPCGroups.DefaultGroupUpdateRate = 250;
     }
     catch (Exception err)
     {
         throw new Exception("枚举本地OPC服务器出错," + err.Message);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 地址转换
 /// </summary>
 /// <param name="address"></param>
 /// <returns></returns>
 private string AddressResolve(OpcAddressConfiguration address)
 {
     return(address.UaAddress.Uri);
 }
Exemplo n.º 5
0
 public void Init(OpcAddressConfiguration address)
 {
     this.Address           = address;
     this.reconnectEnable   = address.ReconnectEnable;
     this.reconnectInterval = address.ReconnectInterval * 1000;
 }