11 Replies Latest reply on Jul 18, 2016 4:43 AM by fmanniti RSS
    fmanniti Creator

    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)

      • Re: Why all my things are "off" anytime I quit Thingworx?
        carlesc Ninja

        If you want that properties are persisted on the database, you should select the option "Persistent"=true with the composer.

          • Re: Why all my things are "off" anytime I quit Thingworx?
            fmanniti Creator

            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)

              • Re: Why all my things are "off" anytime I quit Thingworx?
                carlesc Ninja

                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?

                  • Re: Why all my things are "off" anytime I quit Thingworx?
                    fmanniti Creator

                    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