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

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

Why all my things are "off" anytime I quit Thingworx?

fmanniti
10-Marble

Why all my things are "off" anytime I quit Thingworx?

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)

11 REPLIES 11

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

  • Name: DS-Template
  • Properties
    • Prop_1,  Prop_2, Prop_3 - Number
    • Max_1, Max_2, Max_3 - Number
    • Min_1, Min_2, Min_3  - Number
  • Things "child"
    • Name: DS-TH_1 ... DS-TH_10

Thing to start my device

  • Name: StartThing
  • Property
    • Start - Boolean

Thing to set my interval

  • ​Name: SetIntervalThing
  • Properties:
    • TempMax, TempMin - Number
    • TiltMax, TiltMin - Number
    • StrainMax, StrainMin - Number

On DS-Template there are the following Subscription:

  • Source: StartThing with this service I just tell my interval values (max_n min_n) to be 0 or to be the same of SetIntervalThing
    • Event: DataChange: Start

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;

}

  • Source: SetIntervalThing with this service I tell my intervals values to be equal to SetIntervalThing's values in case they are changed on the run
    • Event: AnyDataChange

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;

  • Source: Timer (is a timerThing configured at 60 seconds)
    I have three of this; one for Prop_1, prop_2 and Prop_3


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:

  • On SetIntervalThing.AnyDataChangeEvent, you should check if ( Things["StartThing"].Start==true ) before changing properties, I'm right? This won't solve your problem
  • When you turn on your TW, it comes from a total stop/start process, our you have your computer on suspension?
  • It seems that your ThingTemplate subscriptions don't start when Tomcat starts, but you should add logging messages to see whats happening behind the scenes, to see if Timer event it's triggering, or datachange event and so.
  • Logging?
    • Activate for instance Info loggging level ( Monitoring > Script -- Settings Tab , Script Log -> Select INFO )
    • And on your subscriptions code, do something like logger.info("I'm DataChange Start event on thing "+me.name);

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:

  • Properties which aren't marked as persistent
  • Dynamic Subscriptions ( subscriptions created by code )

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.

Announcements


Top Tags