Skip to main content
16-Pearl
January 30, 2018
Solved

Add KEPServer Tags by Service, Invalid Property Value Sent

  • January 30, 2018
  • 2 replies
  • 8883 views

First formalities:

I'm using Thingworx 7.1 with the KEPServerEX extension to connect to a KEPServer instance.  Sorry this is a long post, but giving as much info as possible!

 

I've created a mashup to browse the groups and tags available on a KEPServerEX instance using the given 'BrowseItems' and 'BrowseGroups' services available with the 'RemoteKEPServerEXThing' Thing Template.  I've bound 'All Data' from their returns to 2 grid widgets, 1 for BrowseGroups and 1 for BrowseItems.  I created a helper Thing to assist with navigation on the mashup and whatever other services I need to write.  I know that this functionality is working.

I want to add functionality that allows you to multiselect tags from the BrowseItems grid and use the AddItems service to attach them to my KEPServer Thing in Thingworx.

Figure: Left grid displays the results of 'BrowseGroups', Right grid displays the results of 'BrowseItems'.

 

For some reason, I'm not able to directly use Connections in mashup builder to connect data from 'SelectedRow(s)' from BrowseItems to the 'Parameters' for AddItems.

 

So I've tried writing a service on the helper Thing to accomplish this.  My problem is that although running the service seems to execute as it's supposed to, the Application log is flooded with Errors that say:

An Invalid Property Value Was Sent To [KEPServerEXthing Property: [null]

 

โ€‹where KEPServerEXthing is the Thing that the AddItems service is executed on.  If I go into "Manage Bindings" in Properties on the KEP Thing and add the tags as Properties, it won't let me save the KEP Thing and gives this error:

Then if I go into Manage Bindings again (without cancelling the Thing edit) multiple "undefined" rows show up.

It seems like maybe there's some sort of ghost entities messing with things.  This is the second time I've tried getting this to work; I just took a different approach, but it's the same problem I had at first.

Here's the code:

 

INPUTS:

KEPThingName - Type: THINGNAME (This is the server to add tags to)

TagRows - Type: INFOTABLE (This should be the Selected Row(s) from BrowseItems), Datashape: KEPItems (I believe this is the datashape for the results of BrowseItems)

 

//Create Info Table for new tags

var params = {

infoTableName : "InfoTable",

dataShapeName : "KEPAddItems"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(KEPAddItems)

var addTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

 

//Iterate input rows of tags to create entry for each.  Entries will be put into Info Table for AddItems().

for(x in TagRows.rows){

    // KEPAddItems entry object

    var newEntry = new Object();

    newEntry.ReadOnly = TagRows.ReadOnly; // BOOLEAN

    newEntry.ScanRateMS = undefined; // INTEGER

    newEntry.Description = TagRows.Description; // STRING

    newEntry.BaseType = TagRows.BaseType; // STRING

    newEntry.SourceType = TagRows.SourceType; // STRING

    newEntry.Persistent = false; // BOOLEAN

    newEntry.Logged = false; // BOOLEAN

    newEntry.Source = TagRows.Source; // STRING

    newEntry.Name = TagRows.Name; // STRING

//Add entry to new tags Info Table

    addTable.AddRow(newEntry);

}

var addParams = {

items: addTable /* INFOTABLE */

};

// result: INFOTABLE dataShape: KEPAddItemResult

var result = Things[KEPThingName].AddItems(addParams);

        

 

 

I'm not sure if it has something to do with the fact that I'm creating an info table?  Is there a way to destroy it or is garbage collection supposed to take care of it?

 

This is an odd issue that I want to solve.  Any ideas?

Thanks

Best answer by Ascherer17

Thingworx 7.1 and KEPServerEX 6.2.

It turns out it had something to do with using $ symbols in the Name or Source field.  Although Thingworx and KEPServer both allow using $ in Property names or Channel, Device, Tag names, the $ seems to be a delimiter in KEPServer's interfacing with Thingworx.  

Once we changed all the $'s in our tags, they rebound correctly upon a restart.  

 

It was odd that error checking didn't seem to be performed in AddItems to let you know that restricted characters were given as input. 

2 replies

1-Visitor
January 31, 2018

Hi Ascherer


Have you enabled Legacy mode on your KEPServer? Please read page 62.


https://www.kepware.com/en-us/products/kepserverex/documents/kepserverex-manual/

16-Pearl
January 31, 2018

Yes.  We get data through KEPServer properly.

I think I figured out what was going on.  In order to give the tag a more in-depth name on Thingworx, I was using the 'Source' field as the 'Name'.  The Source entries contained periods (.) which Thingworx doesn't seem to allow in Property names.  So I may have changed line 21 above and forgot before I posted.  It was probably:

newEntry.Name = TagRows.Source;

5-Regular Member
January 31, 2018

Greetings aschererโ€‹,

Thank you for sharing this update with us. Please also note the version of ThingWorx and KEPServerEX you are using is older, and many improvements have been implemented since those versions.

For more information, see these Community posts:

Re: Get tags from Kepware -> add them to a thing in Thingworx

ThingWorx / KEPServerEX version compatibility chart

Best regards,

Steven M