cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Create and use "enum" type properties

amittal-3
14-Alexandrite

Create and use "enum" type properties

Hello,

I would like to have something like 'enum' (similar to ones in C/C++) in Thingworx. And then to create a 'property' of that 'enum' type, which can hold only one of the 'enum constants' defined for that 'enum', at a particular time.

Is that possible to achieve something like that?

My basic requirement is to create a 'stateDefination' variable, which supposedly would be the created 'enum' type property, and on running various services on the Thing, this variable would change its state.

Any suggestions or ideas are welcome.

I also found a similar post with same requirement, but since it was very old, I am looking if any new provisions are introduced in Thingworx to achieve this.

 

https://community.ptc.com/t5/ThingWorx-Developers/Best-Practice-for-using-an-enumerated-type/td-p/513007

 

I am looking for something similar to technique used for defining BaseTypes in Thingworx.

 

Thanks in advance

Regards

Aditya Mittal

4 REPLIES 4

Latest answer by Jason answer on the previous post it's the correct one

amittal-3
14-Alexandrite
(To:CarlesColl)

Hello Carles,

I understood what Jason might have done to achieve the required feature, maybe I can also try to mimic his solution. But I just had one concern, that my basic purpose of using this 'enum' was to make easy and fast assignments and comparisons. However, if I have many such comparisons in my service, they would actually be string comparisons and could be time consuming operation (as compared to int comparison).

I am also thinking, that maybe I can create my "ENUM THING" (since thing is also a kind of user defined data type/class) which will hold the properties (of type integer) with name of enum aliases, and their values as enum constants. Then I can use that "enum thing" across my services as it would be a unique global thing.

This is just a thought.

Regards

Aditya

Hello Aditya,

 

We already have a similar solution with what you are proposing, implemented with DataTables that contain String Values for ID Values and automatically shows up as DropDown widgets on properties which has "enum type" assigned. Everything relay on a ThingShape which takes care of enforcing "enum types" and showing the corresponding DropDown.

 

We call it Referential Integrity on traditional DataBases ;) and this is what we had implemented for ThingWorx Properties.

 

Best Regards,

Carles.

amittal-3
14-Alexandrite
(To:CarlesColl)

Hello Carles,

Thanks for the reply. Its fascinating to know about the already implemented solution using DataTables that you mentioned. I am now intrigued and curious to know more about the internals of Thingworx :-). Could you tell me any references or sources where I can read and understand more about it.

Also if I would like to see that particular DataTable in composer, where can I find it (I mean by what name is it implemented)

And finally I would also like to create the custom "property type", (property type of my custom enum, that I would want to create) is it possible to do so? If yes, then how would you suggest I can proceed?

Thanks a lot for bearing with my queries, and, your great support

Regards

Aditya

Announcements


Top Tags