Esempio n. 1
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        /// <param name="server">The server instance.</param>
        /// <param name="itemCollection">The <see cref="System.EventArgs"/> Collection of items to display.</param>
        public void Show(UAClientHelperAPI server, ListViewItem[] itemCollection)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            // Set server,
            m_Server = server;

            // Add the items to the listview.
            foreach (ListViewItem item in itemCollection)
            {
                this.listView.Items.Add(item);
            }

            // Fit the width of the columns to header size.
            this.listView.Columns[0].Width = -2;
            this.listView.Columns[1].Width = -2;
            this.listView.Columns[2].Width = -2;

            // Write the values.
            UpdateCurrentValues();

            // Display the control,
            Show();
            // and bring it to front.
            BringToFront();
        }
Esempio n. 2
0
 public OpcUaClient()
 {
     uAClient = new UAClientHelperAPI();
     uAClient.CertificateValidationNotification = CertificateValidation;  //验证证书
     uAClient.ItemChangedNotification           = ItemChanged;            //订阅数据改变
     uAClient.KeepAliveNotification             = KeepAlive;              //保持连接
 }
Esempio n. 3
0
 public Class_Siemens(string ip, int port, int ns)
 {
     try
     {
         discoveryUrl = null;
         Ns           = ns;
         if (string.IsNullOrEmpty(ip))
         {
             discoveryUrl = new Uri("opc.tcp://localhost:4840");
             // Create client API server object
             m_Server = new UAClientHelperAPI();
             // Attach to certificate event
             m_Server.CertificateValidationNotification += new CertificateValidationEventHandler(m_Server_CertificateEvent);
         }
         else
         {
             // Create client API server object
             m_Server = new UAClientHelperAPI();
             // Attach to certificate event
             m_Server.CertificateValidationNotification += new CertificateValidationEventHandler(m_Server_CertificateEvent);
             //string sUrl = string.Format("opc.tcp://{0}:{1}", ip, port.ToString());
             string sUrl = string.Format("opc.tcp://{0}:{1}", ip, port.ToString());
             discoveryUrl = new Uri(sUrl);
         }
     }
     catch
     {
     }
 }
Esempio n. 4
0
        public MainForm()
        {
            InitializeComponent();

            m_Server = new UAClientHelperAPI();
            m_Server.CertificateValidationNotification += new CertificateValidationEventHandler(m_Server_CertificateEvent);
        }
Esempio n. 5
0
        //    public AddLogDelegate AddLogCallback;
        #endregion

        #region Construction
        public ConnectForm(UAClientHelperAPI helperAPI)
        {
            InitializeComponent();

            //Assign OPC UA objects
            myHelperApi = helperAPI;
            mySession   = myHelperApi.Session;
            AuthenticationGB.Visible = false;

            //Register mandatory events (cert and keep alive)
            myHelperApi.KeepAliveNotification             += new KeepAliveEventHandler(Notification_KeepAlive);
            myHelperApi.CertificateValidationNotification += new CertificateValidationEventHandler(Notification_ServerCertificate);

            //Prepare UI style
            if (mySession != null && mySession.Connected)
            {
                ConnectionStatusLabel.Text      = "Connected";
                ConnectionStatusLabel.ForeColor = Color.Green;
                DisconnectB.Enabled             = true;
                ConnectB.Enabled = false;
            }

            //Create XML file for saved endpoints
            CreateXmlFile();

            //Retrieve endpoints if available
            RetrieveEndpointsAndPopulateLV();
        }
Esempio n. 6
0
 public RF600(string url, string name = "One")
 {
     // Экземпляр API от Siemens
     myHelperApi = new UAClientHelperAPI();
     // Присваивание полям значений
     this.url  = url;
     this.name = name;
 }
Esempio n. 7
0
        //private BrowseControl browseControl;
        //private AttributeListControl attributeListControl;
        //private MonitoredItemsControl monitoredItemsControl;
        public Form1()
        {
            InitializeComponent(); m_Server = new UAClientHelperAPI();
            Session sess = m_Server.Session;

            m_Server.KeepAliveNotification = new KeepAliveEventHandler(Notification_KeepAlive);

            m_Server.CertificateValidationNotification += new CertificateValidationEventHandler(m_Server_CertificateEvent);
        }
Esempio n. 8
0
 public UARfidMethodIdentifiers(UAClientHelperAPI helperApi)
 {
     myHelperApi  = helperApi;
     methodIdList = new List <List <MethodIds> >();
     methodIdList.Add(new List <MethodIds>());
     methodIdList.Add(new List <MethodIds>());
     methodIdList.Add(new List <MethodIds>());
     methodIdList.Add(new List <MethodIds>());
     GetIDsAtConstruction();
 }
Esempio n. 9
0
        public Form1()
        {
            InitializeComponent();

            myHelperApi = new UAClientHelperAPI();
            //Create new overridden ListViews
            EventDataLV = new ListViewNF();
            //   DrowEventDataListView();
            SubscriptionListView = new ListViewNF();
            //   DrowSubscriptionListView();
        }
Esempio n. 10
0
 public formDefineOPCUA()
 {
     InitializeComponent();
     myClientHelperAPI = new UAClientHelperAPI();
     //myRegisteredNodeIdStrings = new List<String>();
     BGW_OPCUA = new BackgroundWorker
     {
         WorkerReportsProgress      = true,
         WorkerSupportsCancellation = true
     };
     BGW_OPCUA.DoWork             += BGW_OPCUA_DoWork;
     BGW_OPCUA.RunWorkerCompleted += BGW_OPCUA_RunWorkerCompleted;
 }
Esempio n. 11
0
 /// <summary>
 /// Form Construction
 /// </summary>
 #region Construction
 public UAClientForm()
 {
     InitializeComponent();
     myClientHelperAPI         = new UAClientHelperAPI();
     myRegisteredNodeIdStrings = new List <String>();
     browsePage.Enabled        = true;
     monitoringPage.Enabled    = true;
     for (var i = 0; i < numberOfPoints; i++)
     {
         chartValues.Add(0);                                  //initialize chart with zeroes
     }
     this.updateChart(0.ToString());
 }
Esempio n. 12
0
 public RF600(string url, string name = "One")
 {
     // Регистрация ключей реестра
     rfidKey   = Registry.CurrentUser.CreateSubKey("Software\\RFID", true);
     argsKey   = rfidKey.CreateSubKey("List\\" + name + "\\args", true);
     resultKey = rfidKey.CreateSubKey("List\\" + name + "\\result", true);
     // Экземпляр API от Siemens
     myHelperApi = new UAClientHelperAPI();
     // Присваивание полям значений
     this.url  = url;
     this.name = name;
     // Создание ключей для предотвращения NullPointerException
     argsKey.SetValue("newValue", "");
 }
        public void init()
        {
            try
            {
/*
 *              log.Debug
 *              log.Info
 *              log.Error
 *              log.Fatal
 */

                myClientHelperAPI = new UAClientHelperAPI();
                EndpointDescription mySelectedEndpoint = null;
                log.Info("Start OPC connection...");
                //mySelectedEndpoint = CreateEndpointDescription(endpointUrl, secPolicy, MessageSecurityMode.None);
                mySelectedEndpoint = getEndpointDescription(endpointUrl);
                if (opcSession == null && mySelectedEndpoint != null)
                {
                    myClientHelperAPI.KeepAliveNotification += new Opc.Ua.Client.KeepAliveEventHandler(plcKeepAliveEventHandler);
                    //myClientHelperAPI.CertificateValidationNotification += new CertificateValidationEventHandler(Notification_ServerCertificate);

                    //Call connect
                    myClientHelperAPI.Connect(mySelectedEndpoint, opcuser.Length > 0, opcuser, opcpwd);
                    //myClientHelperAPI.Connect(mySelectedEndpoint.EndpointUrl, mySelectedEndpoint.SecurityPolicyUri, MessageSecurityMode.None, false, null, null);
                    opcSession = myClientHelperAPI.Session;
                    log.Info("OPC connect successfull");


                    //load jobs from database
                    loadJobsFromDb();

                    //Új szál indítása
                    this.plcMaxQSize = int.Parse(ConfigurationManager.AppSettings["plc_max_q_size"]);
                    this.sleepMillis = int.Parse(ConfigurationManager.AppSettings["thread_sleepmillis"]);
                    this.isRunning   = true;
                    this.mainThread  = new Thread(this.Ciklus);
                    this.mainThread.Start();
                }
            }
            catch (Exception exp)
            {
                log.Info("OPC not connected" + exp);
            }
        }
        public void init(String endpointUrl, String opcuser, String opcpwd)
        {
            log.Debug("PLCHandler.init() begin");
            myClientHelperAPI = new UAClientHelperAPI();
            EndpointDescription mySelectedEndpoint = null;

            //mySelectedEndpoint = CreateEndpointDescription(endpointUrl, secPolicy, MessageSecurityMode.None);
            mySelectedEndpoint = getEndpointDescription(endpointUrl);
            if (opcSession == null && mySelectedEndpoint != null)
            {
                myClientHelperAPI.KeepAliveNotification += new Opc.Ua.Client.KeepAliveEventHandler(plcKeepAliveEventHandler);
                //myClientHelperAPI.CertificateValidationNotification += new CertificateValidationEventHandler(Notification_ServerCertificate);

                //Call connect
                myClientHelperAPI.Connect(mySelectedEndpoint, opcuser.Length > 0, opcuser, opcpwd);
                //myClientHelperAPI.Connect(mySelectedEndpoint.EndpointUrl, mySelectedEndpoint.SecurityPolicyUri, MessageSecurityMode.None, false, null, null);
                opcSession = myClientHelperAPI.Session;

                log.Debug("PLCHandler.init() end");
            }
        }
Esempio n. 15
0
        public static void OPC()
        {
            m_Server = new UAClientHelperAPI();
            m_Server.CertificateValidationNotification += new CertificateValidationEventHandler(m_Server_CertificateEvent);

            try
            {
                m_Server.Connect("opc.tcp://192.168.90.39:4840", "none", MessageSecurityMode.SignAndEncrypt, true, "OpcUaClient", "12345678");
            }
            catch
            {
                Console.WriteLine("Wrong connections data, check opc address and credentials");
                return;
            }



            List <string> nodesToRead = new List <string>();

            nodesToRead.Add("ns=0;i=" + Variables.Server_NamespaceArray.ToString());
        }
Esempio n. 16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     (this.Master as Masterpage).MyButtonClicked += new EventHandler(Disconnect_MyButtonClicked);
     if (!IsPostBack)
     {
         if (mySession != null && mySession.Connected == true)
         {
             if (Session["endpoint"] != null && Session["endpoint"].ToString() != "")
             {
                 var enp  = Session["endpoint"] as EndpointDescription;
                 var enps = Session["endpointlist"] as List <string>;
                 SerName.Text    = enp.Server.ApplicationName.ToString();
                 SerUri.Text     = enp.Server.ApplicationUri.ToString();
                 Serc.Text       = enp.SecurityPolicyUri.ToString();
                 Status.Text     = "Connected";
                 Sinced.Text     = Session["sinced"].ToString();
                 ConnectBtn.Text = "Disconnect from server";
                 foreach (string item in enps)
                 {
                     endpointListView.Items.Add(item);
                 }
                 discoveryTextBox.Text = Session["Urltext"].ToString();
             }
             else
             {
                 return;
             }
         }
         else
         {
             a = new int();
             ControlDisable();
             myClientHelperAPI         = new UAClientHelperAPI();
             myRegisteredNodeIdStrings = new List <String>();
             itemCount = 0;
         }
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Initializes the controls of this form. Registers for an particular event.
        /// </summary>
        public MainForm()
        {
            // Initialize controls.
            InitializeComponent();

            // Register for the SelectionChanged event of BrowseControl in order to update
            // the ListView of AttributeListControl.
            browseControl.SelectionChanged += new BrowseControl.SelectionChangedEventHandler(browserControl_SelectionChanged);

            // Register for the update statuslabel event of AttriuteListControl in order to update
            // the status label.
            attributeListControl.UpdateStatusLabel +=
                new AttributeListControl.UpdateStatusLabelEventHandler(UserControl_UpdateStatusLabel);

            // Register for the update statuslabel event of MonitoredItemsControl in order to update
            // the status label.
            monitoredItemsControl.UpdateStatusLabel +=
                new MonitoredItemsControl.UpdateStatusLabelEventHandler(UserControl_UpdateStatusLabel);

            // Create client API server object
            m_Server = new UAClientHelperAPI();
            // Attach to certificate event
            m_Server.CertificateValidationNotification += new CertificateValidationEventHandler(m_Server_CertificateEvent);
        }