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

X out of Y code help

SK_9989757
5-Regular Member

X out of Y code help

Need X out of Y coding model to raise custom alarm in Thing Worx. The values should be continuously recorded and need to raise a custom alarm if X out of the Y values breach the given limit. Example: X:3 & Y:5 and Values:[4,5,5,4,2], lets consider the limit to be 4 and type is greater or equal. So we can see that 4 values here are out of safe range, so need to raise a custom alarm. Ideally its little more complex than this, to consider all the parameters and condition. 

 

Has anyone ever developed something like this? if so please share your modelling technique.

1 ACCEPTED SOLUTION

Accepted Solutions

@SK_9989757 ,

 

I haven't seen anything OOTB that PTC has created for that specific purpose (the X out of Y alerts).

 

As to your second question, if you're just connecting to a database on GCP that supports JDBC connections, you can likely connect to it using the Database ThingTemplate.   You would need a connection string and a user/password to enter in the configuration for your database thing.

 

-Nick   

View solution in original post

3 REPLIES 3

@SK_9989757 ,

 

There are several ways to accomplish this.  A couple options:

 

1. On every data change of that property (which is an event that you have access to), you can query its history from a value stream and check if your conditions are met

 

2. You can "cache" recent values of that property/properties into a JSON property so you don't have to query the value stream so often, do your logic on it, and then "pop" the old values out of that property.

 

I'm sure there are a few other methods I'm missing, but I'm partial to number 2 if it's possible so I don't have to use the query services so often.

 

-Nick

SK_9989757
5-Regular Member
(To:nmilleson)

I have created a model using the second approach already and its working as per the requirement. But wanted to know if PTC has helped any team build this model, implement it on Thing Templates or Shapes on required projects, wanted to check the approach, which can be applied as universal solution. 

Also wanted to check if connecting TWx to GCP is possible through any extension? Maybe to query data from big table as an example. 

@SK_9989757 ,

 

I haven't seen anything OOTB that PTC has created for that specific purpose (the X out of Y alerts).

 

As to your second question, if you're just connecting to a database on GCP that supports JDBC connections, you can likely connect to it using the Database ThingTemplate.   You would need a connection string and a user/password to enter in the configuration for your database thing.

 

-Nick   

Announcements