Popup Menu/Timer

Interesting that you mention the 3.3 and 5 volt issue. I was very concerned myself when looking at the serial adapter for my interface. My WIZ 232 chip needed 5V. The Serial Adapter Module had an option jumper so I was good to go on that one. They do make a Bi-directional Logic Level Shifter Converter Module 5V to 3.3V For Arduino if you should need one. That does as you say though complicate things.

Today I start on a new preference window. I’ll see if I can rethink the process.

This perfs window sets values for a 3-speed fan that removes passively heated solar warm air from the 27 ft high ceiling and distributes it first through an electronic filter then dehumidifier and then to an under the floor duct system. The warmer the air the higher the fan speed. Electronic dampers direct the warm area to areas needing heat and if not to a mass hot water storage area. The next control is for pressurized skylights and heaters. Pressurized meaning when the blinds for the skylights are closed attic air is forced above the blinds at night in bedroom areas to stop condensation and dripping of water. If the room falls below a given temp rather then turning on the hydroponically heated floor system, skylight heaters turn on and add warm air instead of cool air. Next are the settings for the duct system dehumidifier. Days of the week settings are also included in this prefs window. I may want to sleep in on the weekend and need the skylights to be pressurized later. You get the idea. it will look something like this: https://www.dropbox.com/s/dhk43bupzipf8yg/Ventalation%20Window.jpg?dl=0

I would structure your data like this:

  • Your basic object is a zone.
  • A zone contains settings for each day of the week
  • Each day of the week contains 2 sets of settings: Normal and Economy, as well as an Away temp
  • Each set of settings contains 5 periods
  • each period contains values for: Slider A (time), Slider B (temp) and Checkbox (active)

Each of those is a separate class. Your prefs window is displaying a set of settings. You can create a container control to display the settings and pass it a Settings object to display. Then you would also give it a method that returns a settings object that represents the changes the user made.

As the user clicks the buttons on the bottom of the screen you would retrieve the current state of settings and store it in the current day of week, then get the settings for the new zone/day and pass them to the container to display/edit.

To expand a bit, you would have 5 classes:

  • prefs
  • zone
  • day
  • setting
  • period

Prefs would have an array Zones() as Zone
Zone would have an array Days() as Day
Day would have an array Settings(1) as Setting
Setting would have an array Periods() as Period
Periods would have values for Time as Integer, Temp as Integer, Active as Boolean

Now this may look a lot like your current array structure, but the power of it is you can pick up an object from any level (eg., a Settings object) and pass it to a method that simply acts on it without having to know anything about the zone or day it represents. That gives you reusable code, because you don’t have to hard code any array indexes.

To go further, each class will have a method called Clone() that returns a copy of itself. So working from inside out,
Periods.Clone()

dim p as new Period
p.time = time
p.temp = temp
p.active = active
return p

Settings.Clone()

dim s as new Setting
for i as integer = 0 to ubound(Periods)
   s.periods.append periods(i).clone
next
return s

Day.Clone()

dim d as new Day
for i as integer = 0 to ubound(settings)
   d.settings.append settings(i).clone
next
return d

And so on. So your loop within a loop within a loop is reduced to a single line

Clone_of_Heating_Prefs_Original = xferedArrayWrapper.Heating_Prefs.clone

This approach would be easily extensible. You can easily add zones or periods without have to change a lot of code.

[quote=494120:@Tim Hare]To expand a bit, you would have 5 classes:

  • prefs
  • zone
  • day
  • setting
  • period

Prefs would have an array Zones() as Zone
Zone would have an array Days() as Day
Day would have an array Settings(1) as Setting
Setting would have an array Periods() as Period
Periods would have values for Time as Integer, Temp as Integer, Active as Boolean

Now this may look a lot like your current array structure, but the power of it is you can pick up an object from any level (eg., a Settings object) and pass it to a method that simply acts on it without having to know anything about the zone or day it represents. That gives you reusable code, because you don’t have to hard code any array indexes.

To go further, each class will have a method called Clone() that returns a copy of itself. So working from inside out,
Periods.Clone()

dim p as new Period
p.time = time
p.temp = temp
p.active = active
return p

Settings.Clone()

dim s as new Setting
for i as integer = 0 to ubound(Periods)
   s.periods.append periods(i).clone
next
return s

Day.Clone()

dim d as new Day
for i as integer = 0 to ubound(settings)
   d.settings.append settings(i).clone
next
return d

And so on. So your loop within a loop within a loop is reduced to a single line

Clone_of_Heating_Prefs_Original = xferedArrayWrapper.Heating_Prefs.clone

This approach would be easily extensible. You can easily add zones or periods without have to change a lot of code.[/quote]

Tim, this now gives me something to shoot for. Having a direction from someone that has some experience helps give me enough confidence to put more time into it without feeling like it might be convoluted in the end. I have experimented and spent considerable time on this window already. It is now totally functional but I’ll revisit it just to learn more. I have started on another prefs window which is simpler so I may use your concept on it to gain experience before revisiting the heating pref window.