Accessing state Information from State Definition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Accessing state Information from State Definition
Hello,
Is there a way to get/access the state information from state definition, in a Thing's service? I would like to get how many states are present in a particular State Definition, and what are their values?
Thanks in Advance
Aditya Mittal
Solved! Go to Solution.
- Labels:
-
Coding
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
There isn't an snippet to do that, but you may use the technique I've pointed out to recover style information:
var data = StateDefinitions["State_Test"].GetDifferencesAsJSON({otherEntity: "StatusState"}); var result =data.rows[data.rows.length-1].difference.rows[0].oldValue.value;
This returns a String which it's exactly what you want.
Enjoy :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Are you wondering about the Thingworx State Definitions?
You should be able to get that info from /<server>:<port>/Thingworx/StateDefinitions/NameOfYourStateDefinition
Not sure if there is an actual service native to a state definition that can give you that.
I'm a little thrown off since you mention the word Thing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
Thanks for your reply. I was actually referring to Thing only. What I needed was if there is a way to get the details of State Information from State Definition (just repeating what I wrote above :-)).
Suppose I have a State Definition named "State_Test", so I meant if there is some service like
StateDefinition["State_Test"].GetStateInformation(); //just an example (maybe returns Infotable)
I mean just like we access the property or information about any other entity in Thingworx. I could not find any standard service or any other way to access the metadata (like aspects in case of Thing Entities) of State Definition.
Although there is one service, which gives some information about state Definition Entities, but not entirely what I need
StateDefinition["State_Test"].GetMetadata(); //returns Infotable
I want to have state Information which includes fields like
"stateDefinitions" : [ { "defaultStyleDefinition" : "", "defaultValue" : "0", "description" : "", "displayString" : "", "name" : "" }]
So if there is a way to get this info, please let me know.
Thanks
Aditya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
There isn't an snippet to do that, but you may use the technique I've pointed out to recover style information:
var data = StateDefinitions["State_Test"].GetDifferencesAsJSON({otherEntity: "StatusState"}); var result =data.rows[data.rows.length-1].difference.rows[0].oldValue.value;
This returns a String which it's exactly what you want.
Enjoy :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks once again...:-)