Off Timer

A place to report bugs and discuss testing
Post Reply
Message
Author
User avatar
kherron
Posts: 639
Joined: Mon Dec 05, 2011 10:44 am
Location: Jacksonville, Fl.
Contact:

Off Timer

#1 Post by kherron » Thu Dec 24, 2015 12:48 pm

If the "Off Timer" of an object is Blank, then the object NEVER turns off automatically, However if it is set to Zero, it immediately turns off!
This should be changed so that ZERO acts the same as a Blank.

Which also brings up another issue I have noticed:
In code, an Integer CANNOT equal NULL.
So, any property set to an Integer type, should automatically set the Property to 0(Zero) and not a blank!

I can create GIT issues for these if that helps!

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Off Timer

#2 Post by Vaughn » Sun Dec 27, 2015 8:18 pm

There is a ticket opened already to store all the properties in a DB field of an appropriate datatype. That is massive, though, and there are parts I never figured out. I can store and retrieve the property value in the table, stored procs and the api, but I have no idea how you could ever pull the value out of a View, and that could impact a lot of code, so have just been scared to start tearing up too much code and not being able to work out the views, so it is not likely to get worked soon.

In the mean time, there is 2-3 fixes I can put in.

1. I can rewrite the OFF TIMER time formulas to treat 0 as disabled.
2. I can make selecting the Integer property type populate the default value of 0 on the object type page.
3. Optionally, I could put an insert trigger on the property table to convert any int's null to 0.

I think that would address your symptoms, but would not fix the need to move it into a real integer field in the future though, as that request is mainly about SQL performance and analytics.

Vaughn

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Off Timer

#3 Post by Vaughn » Mon Dec 28, 2015 12:24 am

I open and closed an issue for the Off Timer.

I implemented the first two fixes I recommended. I will also have to update the install.sql for many plugins, and it won't help upgraders since default value only affects new records. But I can write an sql update in the OSA upgrade script that could retro actively fix existing Off Timer instances.

Even if I don't get to the last parts, it should be a better experience going forward, but I will try to do those things too.


Vaughn

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Off Timer

#4 Post by Vaughn » Mon Dec 28, 2015 1:07 am

I posted it all to Git, same 047-048 upgrade script has been modified to also correct all existing data for all integers.

So I have fixed these fields to act more like an integer field should, so I am not really arguing how integers work, but I want to talk about my original thinking to see if it at least makes sense to anyone but me.

An integer in classic computer science DOES have to be a 0 and not null. But in AI, how do you represent Not Knowing a value? That is what I intended blanks/nulls to represent in an integer field. If a property like Occupants is an integer, how does the system tell you that the Occupant count is Unknown without misleading you to thinking the occupant count was 0? So in AI I saw a big difference between 0 and blank and meant to use that to represent a real null/unknown answer, but I guess I could use -1 to represent unknown and still be true to an integer datatype...

I think I even considered 0 a valid OFF TIMER value (like a auto-toggle). As soon as you turn on, Instantly turn off in 0 seconds, which now that 0 = Disable, that is no longer an option. Again, I can recode -1 to disabled, but I just don't find -1 as friendly as ""...

But I understand that if it only makes sense to me, it is a bad design. I don't know, it is really late, I know that most every "design flaw" has some reasoning behind it though...

Vaughn

User avatar
kherron
Posts: 639
Joined: Mon Dec 05, 2011 10:44 am
Location: Jacksonville, Fl.
Contact:

Re: Off Timer

#5 Post by kherron » Mon Dec 28, 2015 7:47 am

WOW,

I thought we would have a little more conversation on this before you jumped in to the work!!!
I really appreciate the effort though!

I completely agree with your way of thinking, and I kind of thought there was a magical reason for the blanks!
I understand that the DB actually stores everything as a string, and the data types are there for us to use for converting.

Also, maybe using the -1 to disable would be better, then the 0 would still work for the Auto-Toggle!

My issue was when I tried to retrieve the Level of a Dimmer, the Convert.ToInt32(level) would fail or crash if the property level was blank.
I created a quick work around by using the following:

Code: Select all

string level = OSAEObjectPropertyManager.GetObjectPropertyValue(this.ObjectName, ValProperty).value;
if (string.IsNullOrEmpty(level))
{
    level = "0";
}
int curLevel = Convert.ToInt32(level);
The Off Timer was just something I had stumbled on while playing around with my new Slider Control.
I was testing it to set the value of an "Off Timer" of an object, an noticed the effect when I set to zero(0).

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Off Timer

#6 Post by Vaughn » Mon Dec 28, 2015 9:39 am

=D Both fixes where only a couple keystrokes, and I can't resist a quick fix heheh. I can adjust them or reverse them with no problem. The SQL to fix existing objects took a bit longer, but not too bad. I have to find something to work on at 3AM =)

I ran into the same problems as you reading in properties and trying conversions, it is frustrating. I definitely like the fix to put the 0 as the default value for integers on object_types and I will play with the rest and see.

In old VB, you could do null conversions so easy, like Variable = "" & null would convert a null into a "". But new .NET is much pickier...

Vaughn

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Off Timer

#7 Post by Vaughn » Thu Dec 31, 2015 10:02 pm

So I tweaked it so Integers default to 0, except OFF TIMER specifically defaults to -1. The sql retrofits all object types and objects. Off timer calcs consider 0 instant, and -1 disabled.

In the future I would consider adding a new datatype for any timer to separate the default behaviors.

Git upgrade script and code are fully current.

I have to say over 20 git issues have been closed for v048!

Vaughn

User avatar
kherron
Posts: 639
Joined: Mon Dec 05, 2011 10:44 am
Location: Jacksonville, Fl.
Contact:

Re: Off Timer

#8 Post by kherron » Fri Jan 01, 2016 9:00 am

Cool,
This will definitely help us with future development for sure!!
I have to say over 20 git issues have been closed for v048!
This is GREAT :!:

I will download from Git again today, and try to get my Fixes completed.

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Off Timer

#9 Post by Vaughn » Fri Jan 01, 2016 12:04 pm

I won't be working any more issues this release, so you should be safe working on anything you want without conflicts. I will spend the rest of the time just using and testing all the stuff that is already in and helping and testing anything you want me to.

Let me know if you have any issues getting current 048 source working. Currently there is no osae.sql in the git installer, load the osae_047.sql, and run the 047-048 upgrade sql against it to get current.

Vaughn

Post Reply