Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

JScript version of OPC-DA Write multiple values, specify requested data types

More
05 Aug 2025 17:36 #14353 by support
Thank you, this is good to know.
Maybe the VBScript worked because it already ran under 32 bits, although I do not know why,.

Regards

Please Log in or Create an account to join the conversation.

More
05 Aug 2025 17:00 #14352 by Kyle.Oshima@caltrol.com
Good news, now have QuickOPC JScript ASP example script working thru IIS.

Changing IIS Application Pool to enable 32-bit applications as recommended (see screenshot below) webpage now runs without error.

Thanks.
   
  • Please Log in or Create an account to join the conversation.

    More
    03 Aug 2025 14:06 #14351 by support
    Hello.

    I have no explanation as to why would the equivalent VBScript find the OPC server and and JScript will not, neither do I know how to "switch" the behavior for JScript to be as VBScript.

    However, I still recommend to at least try running the IIS worker process (AppPool) in with 32 bits. From the error message, it runs as 64 bits. There is a setting in IIS for that; let me know if you need help with it.

    Best regards
     

    Please Log in or Create an account to join the conversation.

    More
    30 Jul 2025 22:00 #14346 by Kyle.Oshima@caltrol.com
    Have server-side JScript based on additional code details provided (note Request.Form() calls provide dynamic params from client-side ASP form thru AJAX POST) -- see code below

      var easyclient = new ActiveXObject( "OpcLabs.EasyOpc.DataAccess.EasyDAClient" );
      var dictionary = new ActiveXObject( "Scripting.Dictionary" );

      var i = 0;
      while ( Request.Form( "param" + ( ++i ).toString() ).Count ) {
        var davalarg = new ActiveXObject( "OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemValueArguments" );
        var vartypes = new ActiveXObject( "OpcLabs.BaseLib.ComInterop.VarType" );

        davalarg.ServerDescriptor.ServerClass = Request.Form( "opcda" );
        davalarg.ItemDescriptor.ItemId = Request.Form( "DAitem" + i.toString() );

        switch ( Request.Form( "datatype" + i.toString() )( 1 ) ) {
          case "float":
            davalarg.Value = parseFloat( Request.Form( "param" + i.toString() ));
            vartypes.NumericalValue = 4;  // VarTypes.R4
            davalarg.ItemDescriptor.RequestedDataType = vartypes;
            break;
          case "bool":
          case "int8":
          case "int16":
          case "int32":
            davalarg.Value = parseInt( Request.Form( "param" + i.toString() ));
            vartypes.NumericalValue = 3;  // VarTypes.I4
            davalarg.ItemDescriptor.RequestedDataType = vartypes;
            break;
          case "discrete":
          case "uint8":
          case "uint16":
          case "uint32":
          case "enum":
            davalarg.Value = parseInt( Request.Form( "param" + i.toString() )) >>> 0;
            vartypes.NumericalValue = 19; // VarTypes.UI4
            davalarg.ItemDescriptor.RequestedDataType = vartypes;
            break;
          default:
        }
        dictionary.Add( ( i-1 ), davalarg );
      }
      var operresult = easyclient.WriteMultipleItemValues( dictionary.Items() ).toArray();

      for ( --i; i != 0; i-- ) {
        if ( !operresult[ i-1 ].Succeeded ) {
          Response.Write( "ERROR : " + operresult[ i-1 ].Exception.GetBaseException().Message );
          break;
        }
      }


    However, WriteMultipleItemValues method result returns same error -- see error below

    ERROR : Class not registered + This error may be caused by damaged or missing OPC Server registration on the specified computer. It can also be due to a problem with OPC proxies/stubs, which can be resolved by installing OPC Core Components (from OPC Foundation). + The machine name was ''. The server class used was '{c3b72ab1-6b33-11d0-9007-0020afb6cf9f}'. + Execution details: HasNativeClient=False, HasNetApiClient=True, ProcessBitness=64. + The client method called (or event/callback invoked) was 'WriteMultipleItemValues[10]'.

    Regarding your earlier questions...
    re: Regarding the VBScript problem, are you connecting to the same OPC server as before, or a different one?... when you state "as before" if you mean target OPC UA server from post #14329  then although is same physical machine target DCS separately licenses and services its OPC UA and OPC DA servers; if however you mean target OPC DA server from post #13020  then that is different named instance (per vendor not supported for third party connection) of same OPC DA server.
    re: 3) Just as a note, from the CLSID of the server, it appears that is the Delta V OPC Server... correct the intended target OPC DA CLSID is named instance of DeltaV OPC DA server supported for third party connection

    re: 2) ...You should be able to run VBScript in 32-bits by setting the bitness of the IIS worker process... QuickOPC COM examples has ASP example written in VBScript that appears to work connecting to this same target OPC DA server -- is there some setting needed to allow ASP script to run as "language=javascript" vs "language=vbscript"?

    Please Log in or Create an account to join the conversation.

    More
    30 Jul 2025 12:01 - 30 Jul 2025 12:01 #14345 by support
     
    Hello,

    here is the JScript example for writing multiple item values and specifying the data type.

     
    // Shows how to write into multiple OPC items using a single method call, specifying their requested data types.
    //
    // Find all latest examples here: opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
    // Missing some example? Ask us for it on our Online Forums, www.opclabs.com/forum/index ! You do not have to own
    // a commercial license in order to use Online Forums, and we reply to every post.
     
    var varTypes_I2 = 2;
    var varTypes_R4 = 4;
     
    // Instantiate the client object.
    var Client = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient");
     
    WScript.Echo("Writing multiple item values...");
     
    // Prepare the arguments
     
    var requestedDataType1 = new ActiveXObject("OpcLabs.BaseLib.ComInterop.VarType");
    requestedDataType1.NumericalValue = varTypes_I2;
    var WriteValueArguments1 = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemValueArguments");
    WriteValueArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2";
    WriteValueArguments1.ItemDescriptor.ItemId = "Simulation.Register_I2";
    WriteValueArguments1.ItemDescriptor.RequestedDataType = requestedDataType1; // the requested data type
    WriteValueArguments1.Value = 12345;
     
    var requestedDataType2 = new ActiveXObject("OpcLabs.BaseLib.ComInterop.VarType");
    requestedDataType2.NumericalValue = varTypes_R4;
    var WriteValueArguments2 = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemValueArguments");
    WriteValueArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2";
    WriteValueArguments2.ItemDescriptor.ItemId = "Simulation.Register_R4";
    WriteValueArguments2.ItemDescriptor.RequestedDataType = requestedDataType2; // the requested data type
    WriteValueArguments2.Value = 234.56;
     
    var dictionary = new ActiveXObject("Scripting.Dictionary");
    dictionary.Add(0, WriteValueArguments1);
    dictionary.Add(1, WriteValueArguments2);
    var items = dictionary.Items();
     
    // Perform the write operations.
    var results = Client.WriteMultipleItemValues(items);
     
    // Display results.
    var jsArray = results.toArray();
    for (i = 0; i < jsArray.length; i++) {
        var WriteResult = jsArray
        if (WriteResult.Succeeded)
            WScript.Echo("Result " + i + ": Success");
        else
            WScript.Echo("Result " + i + " *** Failure: " + WriteResult.Exception.GetBaseException().Message);
    }
     


    Best regards

     
    Last edit: 30 Jul 2025 12:01 by support.

    Please Log in or Create an account to join the conversation.

    More
    28 Jul 2025 10:07 #14340 by support
    Hello.

    Regarding the VBScript problem, are you connecting to the same OPC server as before, or a different one? And, are you doing some extra settings in the VBScript, or is it just a "plain" script (maybe you post it here too)? I am not aware of any changes between the two QuickOPC version that could affect this. There are some suspicious circumstances, though:

    1) The error message contains "HaseNativeClient=False". This means that an alternative implementation of OPC low-level code has been chose, and I do not know why - that's why I am asking about the particulars of the script, and any extra settings.

    2) The error message contains "ProcessBitness=64". This is not always a problem, but sometimes it, due to the way the OPC server are registered. 32-bit processes usually work better. You should be able to run VBScript in 32-bits by setting the bitness of the IIS worker process. I think we did this before too.

    3) Just as a note, from the CLSID of the server, it appears that is the Delta V OPC Server. This one is especially problematic with regard to its registration, and in some cases we had to give up trying...

    I will have a look at your other request (JScript version of the script) separately later, please give me some time.

    Best regards
     

    Please Log in or Create an account to join the conversation.

    More
    25 Jul 2025 22:15 #14339 by Kyle.Oshima@caltrol.com
    Have evaluation install of QuickOPC for development of custom application OPC interface with DCS platform -- initially installed as OPC Studio 2024.1, later recently uninstalled (per website instructions) and reinstalled as latest OPC Studio 2025.1

    Have recently successfully proven suitable QuickOPC OPC UA solution for our needs, and in process of proving comparable OPC Classic conversion solution; however, am now unexpectedly encountering following error with OPC DA (see screenshot below)  Please advise what steps needed to resolve OPC DA variant -- OPC UA variant appears to work fine, and OPCLabs' EasyOPC-DA (COM) Demo Application works fine.  Also with prior 2024.1 version, do not recall having to tweak anything outside of standard install, was able to connect to same DCS OPC DA server with OPCLabs' VBScript examples without such error.

    Also am looking for JScript version of Examples - OPC Data Access - Write multiple values, specify requested data types available in online documentation similar to separate inquiry for OPC UA -- see attached .zip file containing .js file as well as rudimentary .asp file to run JScript in web browser based on additional code details provided ( #14332 )
       
     

    File Attachment:

    File Name: test-quick...7-25.zip
    File Size:1 KB
  • Please Log in or Create an account to join the conversation.

    Moderators: supportvaclav.zaloudek
    Time to create page: 0.162 seconds