Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
I have a thing template with ten things attached on it.
On thing template level I have a subscription which states any minute things property has to change randomly in a range of values (which are defined by an external thing).
It happens that anytime I quit thingworx this flow stops as well and when I re-open it all things properties are set to 0.
If I want to start it again I must "save" each thing one by one and within a minute they will change again values.
How can I avoid them to stop OR how can I start them all together by mashup?
(I hope information I gave to you are enough, If you need any more detail, write to me)
If you want that properties are persisted on the database, you should select the option "Persistent"=true with the composer.
They are; my problem is that my subscription doesn't seem to work; I'll explain myself better:
In thing template I have a subscription which depend on another thing (StartThing is the name and it has only one property which is a boolean called start).
My subscription says that, if start is true my minimum and maximum values of the intervals are set, otherwise they are 0.
Everyday, when I open thingworx, I have all my properties set to 0 (also the intervals extremes) and, if I change value to start, my subscription is supposed to work but it doesn't until I don't edit and save the things one by one.
(I think my explanation is quite confusing; hope you understand)
Hi Fabio,
I think I totally don't get it sorry
But, if the state of your StartThing it's true at Tomcat start, then it may not launch a Change event to true, until you change the property back to false, and then back to true. Events are launched on change. Maybe this?
Correct, events are launched on change. The problem is that, untill I don't save again the single thing manually, it won't change its values even if I switch start property all the time I want.
I'll try to be more schematic on my explanation; that's what I have:
ThingTemplate
Thing to start my device
Thing to set my interval
On DS-Template there are the following Subscription:
if(Things["StartThing"].Start==true){
me.max_1=Things["SetIntervalThing"].TiltMax;
me.min_1=Things["SetIntervalThing"].TiltMin;
me.max_4=Things["SetIntervalThing"].TempMax;
me.min_4=Things["SetIntervalThing"].TempMin;
me.max_5=Things["SetIntervalThing"].StrainMax;
me.min_5=Things["SetIntervalThing"].StrainMin;
}else{
me.max_1=me.min_1=me.max_4=me.min_4=me.max_5=me.min_5=0;
me.Prop_1=me.Prop_2=me.Prop_3=me.Prop_4=me.Prop_5=0;
}
me.max_1=Things["SetIntervalThing"].TiltMax;
me.min_1=Things["SetIntervalThing"].TiltMin;
me.max_4=Things["SetIntervalThing"].TempMax;
me.min_4=Things["SetIntervalThing"].TempMin;
me.max_5=Things["SetIntervalThing"].StrainMax;
me.min_5=Things["SetIntervalThing"].StrainMin;
var maxTime = 60;
var minTime = 10;
var intervalTime = ((maxTime/2)-minTime);
var start = Date.now();
var curDate = null;
var delay = (Math.floor(Math.random()*10)+1)*1000;
if(Things["StartThing"].Start==true){
for(var i=0; i<maxTime; i++){
pause(1000);
curDate = Date.now();
if(curDate-start >= delay){
me.Prop_1=Math.floor(Math.random()*(me.max_1-me.min_1))+me.min_1;
break;
}
}
}
When I turn Thingworx on (so it means, in the morning when I come to the office), I have all the DS-TH_ with their old values but they don't change them, even if I change the start's state.
If I edit and save DS-TH_1, for example, I'll see its values changing but not for all the other 9 things.
Hope is clearer
Some things:
Not sure if the code here is copied directly from your project, but in case, if it is I see couple of discrepancies:
1. Subscription -> SetIntervalThing:Event: AnyDataChange references max_4 & max_5 that probably do not exist.
2. Also the case of the properties matters, these should match
Application log may report such conditions.
I just turned on my virtual machine and Thingworx and this is what my I see in log
DS-Timer_1 is the name of the TimerThing of the subscription.
@Sajid Patel:
Actually, my properties are 1, 4, 5 and not 1, 2, 3 as I wrote above, so max_4 and max_5 is correct.
Maybe one thing I didn't mention:
ThingTemplate is a RemoteThing Template and all its child things are remote thing.
This properties are bind to other generic thing and those things are the one I see on my mashup.
This messages, seems to refer that you are trying to create each time the Things, that's it?
It's the same thing I thought.
TimerThings are created by a subscription of another thing I called TimerThingCreator.
The event for this subscription is "ThingStart".
Do you think this may "stop" my timer anytime because I try to create a new one?
Because, if so, I disable the subscription and that's it.
Once created the Timer Thing, you don't need to create it anymore, all Things are persistent, why you are trying to create it again and again? The features which aren't persistent:
I don't want to create it again and again.
I just created my first time through my subscription but then I don't use that TimerThingCreator anymore so I thought it was fine.
I didn't know it was a bad idea.