Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Cache a DB2 Dynamic Query in ADO.net Pin
OriginalGriff4-Oct-18 6:32
mveOriginalGriff4-Oct-18 6:32 
GeneralRe: How to Cache a DB2 Dynamic Query in ADO.net Pin
Mycroft Holmes4-Oct-18 12:48
professionalMycroft Holmes4-Oct-18 12:48 
Questiondisplay value of a key in dictionary to text box and edit value and save out to file Pin
elfenliedtopfan53-Oct-18 14:02
elfenliedtopfan53-Oct-18 14:02 
AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
Maciej Los3-Oct-18 20:28
mveMaciej Los3-Oct-18 20:28 
AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
OriginalGriff3-Oct-18 20:35
mveOriginalGriff3-Oct-18 20:35 
AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
dan!sh 3-Oct-18 20:36
professional dan!sh 3-Oct-18 20:36 
AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
BillWoodruff14-Oct-18 15:21
professionalBillWoodruff14-Oct-18 15:21 
QuestionOPC client server Pin
Roberto64_Ge3-Oct-18 2:28
Roberto64_Ge3-Oct-18 2:28 
Hi
I'm trying to implement an OPC client to connect to the FactoryTalk Gateway opc server from Rockwell.
I get an example and I am trying to use it but with some problems.

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RsLinx_OPC_Client
{
    public partial class Form1 : Form
    {
        #region Variables for OPC client

        private Opc.URL url;
        private Opc.Da.Server server;
        private OpcCom.Factory fact = new OpcCom.Factory();
        private Opc.Da.Subscription groupRead;
        private Opc.Da.Subscription groupWrite;
        private Opc.Da.SubscriptionState groupState;
        private Opc.Da.SubscriptionState groupStateWrite;
        private Opc.Da.Item[] items = new Opc.Da.Item[3];
        
        #endregion

        //initialization of the sample object that contains opc values
        MyOPCObject myOpcObject = new MyOPCObject();

        public Form1()
        {
            InitializeComponent();
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            //string nomenodo;
            //Opc.ConnectData myopc_connectdata = new Opc.ConnectData(new System.Net.NetworkCredential());
            // 1st: Create a server object and connect to the RSLinx OPC Server
            // url = new Opc.URL("opcda://localhost/RSLinx OPC Server");
            // url = new Opc.URL("FactoryTalk Gateway");
            url = new Opc.URL("opcda://localhost/FactoryTalk Gateway");
            //nomenodo = "PCA079";
            // url = new Opc.URL("opc.tcp://PCA079:4990/FactoryTalkLinxGateway_RS");
            // url = new Opc.URL("RSLinx OPC Server");
            server = new Opc.Da.Server(fact, null);

            //2nd: Connect to the created server
            server.Connect(url, new Opc.ConnectData(new System.Net.NetworkCredential()));
            //try
            //{
            //    server.Connect(url, myopc_connectdata);
            //}
            //catch (Exception exy)
            //{
            //    MessageBox.Show(exy.Message);

            //}
            //3rd Create a group if items            
            groupState = new Opc.Da.SubscriptionState();
            groupState.Name = "Group";
            groupState.UpdateRate = 1000;// this isthe time between every reads from OPC server
            groupState.Active = true;//this must be true if you the group has to read value
            groupRead = (Opc.Da.Subscription)server.CreateSubscription(groupState);
            groupRead.DataChanged += new Opc.Da.DataChangedEventHandler(group_DataChanged);//callback when the data are readed
            
            // add items to the group    (in Rockwell names are identified like [Name of PLC in the server]Block of word:number of word,number of consecutive readed words)        
            items[0] = new Opc.Da.Item();
            items[0].ItemName = "[UNTITLED_1]N7:0,L2";//this reads 2 word (short - 16 bit)
            items[1] = new Opc.Da.Item();
            items[1].ItemName = "[UNTITLED_1]N11:0,L10";//this reads an array of 10 words (short[])
            items[2] = new Opc.Da.Item();
            items[2].ItemName = "[UNTITLED_1]B3:0,L2";//this read a 2 word array (but in the plc the are used as bits so you have to mask them)    
            items = groupRead.AddItems(items);

            // Create a write group            
            groupStateWrite = new Opc.Da.SubscriptionState();
            groupStateWrite.Name = "Group Write";
            groupStateWrite.Active = false;//not needed to read if you want to write only
            groupWrite = (Opc.Da.Subscription)server.CreateSubscription(groupStateWrite);
        }


EXception is thrown in the
server.Connect(url, new Opc.ConnectData(new System.Net.NetworkCredential()));


The exception in italian tells that

Quote:
Eccezione non gestita di tipo 'System.IO.FileNotFoundException' in OpcNetApi.dll

Ulteriori informazioni: Impossibile caricare il file o l'assembly 'OpcRcw.Dx, Version=1.0.1.21, Culture=neutral, PublicKeyToken=9a40e993cbface53' o una delle relative dipendenze. Impossibile trovare il file specificato.


Which means that it is impossible to load file or assembly 'OpcRcw.Dx, Version=1.0.1.21, Culture=neutral, PublicKeyToken=9a40e993cbface53' or relevant dependecies

Can somebody help?
Regards
AnswerRe: OPC client server Pin
Richard MacCutchan3-Oct-18 3:11
mveRichard MacCutchan3-Oct-18 3:11 
GeneralRe: OPC client server Pin
Roberto64_Ge3-Oct-18 4:10
Roberto64_Ge3-Oct-18 4:10 
GeneralRe: OPC client server Pin
Richard MacCutchan3-Oct-18 4:52
mveRichard MacCutchan3-Oct-18 4:52 
GeneralRe: OPC client server Pin
Roberto64_Ge3-Oct-18 9:51
Roberto64_Ge3-Oct-18 9:51 
GeneralRe: OPC client server Pin
Richard MacCutchan3-Oct-18 22:02
mveRichard MacCutchan3-Oct-18 22:02 
GeneralRe: OPC client server Pin
Dave Kreskowiak3-Oct-18 5:00
mveDave Kreskowiak3-Oct-18 5:00 
GeneralRe: OPC client server Pin
Roberto64_Ge3-Oct-18 10:10
Roberto64_Ge3-Oct-18 10:10 
GeneralRe: OPC client server Pin
Roberto64_Ge4-Oct-18 3:28
Roberto64_Ge4-Oct-18 3:28 
GeneralRe: OPC client server Pin
OriginalGriff4-Oct-18 3:46
mveOriginalGriff4-Oct-18 3:46 
GeneralRe: OPC client server Pin
Dave Kreskowiak4-Oct-18 4:29
mveDave Kreskowiak4-Oct-18 4:29 
GeneralRe: OPC client server Pin
Roberto64_Ge4-Oct-18 20:33
Roberto64_Ge4-Oct-18 20:33 
GeneralRe: OPC client server Pin
Dave Kreskowiak5-Oct-18 2:16
mveDave Kreskowiak5-Oct-18 2:16 
GeneralRe: OPC client server Pin
Roberto64_Ge8-Oct-18 2:16
Roberto64_Ge8-Oct-18 2:16 
GeneralRe: OPC client server Pin
Dave Kreskowiak8-Oct-18 4:10
mveDave Kreskowiak8-Oct-18 4:10 
GeneralRe: OPC client server Pin
Roberto64_Ge8-Oct-18 4:45
Roberto64_Ge8-Oct-18 4:45 
GeneralRe: OPC client server Pin
Dave Kreskowiak8-Oct-18 8:21
mveDave Kreskowiak8-Oct-18 8:21 
QuestionActive touchscreen detection Pin
sarmadi2-Oct-18 19:43
sarmadi2-Oct-18 19:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.