OPC write value issue-IBH opc server

Forum Home Forums Communicating with Devices OPC OPC write value issue-IBH opc server

Viewing 15 posts - 76 through 90 (of 98 total)
  • Author
    Posts
  • #4584
    mariodavid
    Participant

    Hi,
    thank you, I managed to debug but I wanna see the method inside. Said that the simbols are not charged.

    https://imgur.com/a/mU22iFe

    I just realize than “public override IdentifiedResult[] Write(ItemValue[] items)” belong to a class,
    which is derived from another class That contain “public virtual IdentifiedResult[] Write(ItemValue[] items)”.
    So, the next method

    public IdentifiedResult[] Write(ItemValue[] items)
    {
    if (this.m_server == null)
    throw new NotConnectedException();
    return ((IServer) this.m_server).Write(items);
    }

    calls “public virtual IdentifiedResult[] Write(ItemValue[] items)” but why does not call override method too?
    Is necesary to create a new class like you said?
    I have another doubt. “((IOPCSyncIO) this.m_group).Write” only happens if (arrayList1.Count > 0)?

    public override IdentifiedResult[] Write(ItemValue[] items)
    {
    if (items == null)
    throw new ArgumentNullException(nameof (items));
    if (items.Length == 0)
    return new IdentifiedResult[0];
    lock (this)
    {
    if (this.m_server == null)
    throw new NotConnectedException();
    Item[] items1 = new Item[items.Length];
    for (int index = 0; index < items.Length; ++index)
    items1[index] = new Item((ItemIdentifier) items[index]);
    IdentifiedResult[] items2 = this.AddItems(items1);
    try
    {
    ArrayList arrayList1 = new ArrayList(items.Length);
    ArrayList arrayList2 = new ArrayList(items.Length);
    for (int index = 0; index < items.Length; ++index)
    {
    if (!items2[index].ResultID.Failed())
    {
    if (items[index].QualitySpecified || items[index].TimestampSpecified)
    {
    items2[index].ResultID = ResultID.Da.E_NO_WRITEQT;
    items2[index].DiagnosticInfo = (string) null;
    }
    else
    {
    arrayList1.Add((object) items2[index]);
    arrayList2.Add((object) items[index]);
    }
    }
    }
    if (arrayList1.Count > 0)
    {
    int[] phServer = new int[arrayList1.Count];
    object[] pItemValues = new object[arrayList1.Count];
    for (int index = 0; index < phServer.Length; ++index)
    {
    phServer[index] = (int) ((ItemIdentifier) arrayList1[index]).ServerHandle;
    pItemValues[index] = OpcCom.Interop.GetVARIANT(((ItemValue) arrayList2[index]).Value);
    }
    IntPtr ppErrors = IntPtr.Zero;
    try
    {
    ((IOPCSyncIO) this.m_group).Write(arrayList1.Count, phServer, pItemValues, out ppErrors);
    }
    catch (Exception ex)
    {
    throw OpcCom.Interop.CreateException(“IOPCSyncIO.Write”, ex);
    }
    int[] int32s = OpcCom.Interop.GetInt32s(ref ppErrors, arrayList1.Count, true);
    for (int index = 0; index < arrayList1.Count; ++index)
    {
    IdentifiedResult identifiedResult = (IdentifiedResult) arrayList1[index];
    identifiedResult.ResultID = OpcCom.Interop.GetResultID(int32s[index]);
    identifiedResult.DiagnosticInfo = (string) null;
    if (int32s[index] == -1073479674)
    items2[index].ResultID = new ResultID(ResultID.Da.E_READONLY, -1073479674L);
    }
    }
    }
    finally
    {
    this.RemoveItems(items2);
    }
    return items2;
    }
    }

    #4585
    mariodavid
    Participant

    https://imgur.com/a/frs1iEY

    public override IdentifiedResult[] Write(ItemValue[] items) in OpcCom.Da20.Server

    public virtual IdentifiedResult[] Write(ItemValue[] items) in OpcCom.Da.Server

    I really do not understand how to call override write method.

    #4586
    Mikhail
    Moderator

    Hi,

    I wanna see the method inside. Said that the simbols are not charged.

    Because this method belongs to another DLL. If you need to debug this method, attach open the source code of the appropriate DLL.

    #4587
    Mikhail
    Moderator

    I really do not understand how to call override write method.

    You should create an instance of your own class instead of the parent class.

    #4591
    mariodavid
    Participant

    Hi,

    I tried to create a class, declaring a field to call override method. Also changing KpOpclogic. Compiled without error.

    https://imgur.com/a/czTSOLI

    But, when I run communicator, shows a error. “An object of type Op.Da.Server can not be converted to the type Scada.Comm.KP.Class2”

    https://imgur.com/a/wVA1ThC

    #4592
    mariodavid
    Participant

    I also tried to create a project with OpcNetApi but when i compiled shows 2 errors.

    With OpcNetApi.com, compiled wiht no error, attach to the process but can not set break points because the symbols can not be charged.

    #4595
    Mikhail
    Moderator

    These errors are very specific. To find answers I should do all this stuff by myself. I hope you can find out how to solve it.

    I recommend to catch the exception and write to log complete stack trace. Something like that:

    catch (Exception ex)
    {
      WriteToLog(ex.ToString());
    }
    #4597
    mariodavid
    Participant

    Hi,

    I have another idea, but i need to know how to open a project of OpcNetApi and OpcNetApi.Com.dll in VS 2017. Can you tell me how do you use those dll to debug in VS? Please. Do you have the folder like KpOpcSource that i can use?

    #4601
    Mikhail
    Moderator

    I have no source code of OpcNetApi. Does a decompier, that you use, can create a VS project that can be build for debug?

    #4602
    mariodavid
    Participant

    Yes, I open projects with dotpeek but whe i compiled, give some errors.

    I also tried to call override method using a field like this

    private OpcCom.Da20.Server campo;

    compiled without errors. I run the communicator, trying to send a command give this error:

    “Error sending command: Object reference not set to an instance of an object”.

    Can you give some template o examples to create a instance in KpOpclogic class?

    #4603
    mariodavid
    Participant

    I am trying this:

    private OpcCom.Da20.Server campo = new OpcCom.Da20.Server();

    but give me this error: CS7036 C# There is no argument given that corresponds to the required formal parameter ‘url’ of ‘Server.Server(URL, object)´

    #4608
    Mikhail
    Moderator

    Can you give some template o examples to create a instance in KpOpclogic class?

    Could you clarify what example do you need?

    #4670
    mariodavid
    Participant

    Hi

    I am tryng to call override method using this.

    URL url = null;
    object server = null;
    OpcCom.Da20.Server campo = new OpcCom.Da20.Server(url, server);
    campo.Write(new Opc.Da.ItemValue[] { itemVal });

    Compiled witout error. When I run communicator, appers this error: error sending command: url can not be null.

    I can not change url to another value. So, Can not I use this method definitly?
    Where else can I do with url?

    #4671
    mariodavid
    Participant

    In the original KpOpcLogic, you use:
    daServer.write(new Opc.Da.ItemValue[] { itemVal });

    Going to write method declaration:

    public class Server : Opc.Server, IServer, Opc.IServer, IDisposable

    .
    .
    .
    public IdentifiedResult[] Write(ItemValue[] items)
    {
    if (this.m_server == null)
    throw new NotConnectedException();
    return ((IServer) this.m_server).Write(items);
    }

    So, “m_server.write” calls write method of IServer. but IServer is a interface. Why does not call a implementation of IServer instead?

    #4675
    Mikhail
    Moderator

    Why you don’t pass valid URL to new OpcCom.Da20.Server(url, server)?
    This URL is needed to specify the server you connect.

    Why does not call a implementation of IServer instead?

    Interface is just a declaration. The runtime executes the method of an object that was actually created.

Viewing 15 posts - 76 through 90 (of 98 total)
  • You must be logged in to reply to this topic.