From: Jason S. <jas...@sh...> - 2003-06-07 17:49:08
|
On Sat, 31 May 2003, Bruce Winter wrote: > > I would like to add some properties to the Generic Item: > > > > Generic Item: > > - $fp_x - Floor plan X > > - $fp_y - Floor plan Y > > - $fp_w - Floor plan width > > - $fp_h - Floor plan height > > - %fp_img - Icon list of images Hash {state}{image.jpg} > > - $class - Type of object (switch, lamp, appliance, motion) (do we have a > > standard? Sometimes the object wont necessary indicate the type of > > object for non-X10 items DIO, etc.) > > - @nodes - Array of arbitrary relationship nodes > > > > I am not in love with the naming syntax if anyone thinks it should be > > different ;) > > > > Any comments / concerns / etc? > > -J > > Sure. To be more specific, hows about these methods: > > $light1 -> set_fp_location( $x, $y, $w, $y ); > $light1 -> set_fp_icon( on => 'light_on.jpg', off => 'light_off.jpg'); > $light1 -> set_fp_nodes(@nodes); > $light1 -> set_type('lamp'); > > We already have a set_info method (for a text description) and a set_icon > method (for picking one web icon to use on the standard web menus). For the > type of the object, type might be better so we don't confuse it with the > object class (e.g. X10_Item). set_fp_icon could be optional, as we could > use default icons based on type. > > Internally, I think I'd consider storing the location data as 1 string in a > $self->{fp_location} hash entry, since 1 has entry takes quite a bit less > memory than 4, and splitting into coordinates is fast and we would never > need just one of the 4 numbers. > > I'd be happy to add the above methods or to get an updated Generic_Item from > you. > Hi, I updated Generic_Item and finished the dynamic floorplan code to use object co-ordinates to draw floorplan with HTML tables. (code will be forthcomming shortly) I am working on the "cosmetics" of the code yet as it relates to different objects types and got me thinkingagain. I wondering if I should pitch the "type" var and instead develop some "type" classes. For example (lamp, motion, switch, etc) classes to envelope and extend functionality to all objects regardless of interface type. $x10_A10 = new X10_Item('A10'); $Bedroom_Lamp = new Lamp($x10_A10); $sg_D4 = new StargateDigitalIO('4'); $Bedroom_Motion = new Motion($sg_D4); Anyone have any comments / ideas? -J |