Premise VoltageSensor device?

Motorola Premise

ckindel

Member
I want to create a new device called a Voltage Sensor.

I am using an Adicon SECU8 for my analog input. It reads 0 to 5V. But in some cases I will REALLY be measuring much higher voltages and using an external circuit to scale down.

ADI has ADI_InputAnalogEx as the type of it's inputs.

There exists in Premise AnalogInputEx which has all the logic/proprites I need to manage the scaling.

I want my Voltage Sensor class to:

- have the following properties when added to a Home object
PowerState (True/False) (ValueProperty) (True of voltage > 0)
Voltage (Real)
BoundObject (to the ADI_InputAnalogEx)
The appropriate properties of AnalogInputEx (e.g. RawValue, Offset, Gain)

- Be added to a Home Object as either an HVAC, Saftey, or Appliance object (I don't care, I just want it to show up).

I have massively confused myself on how to create such a class. It's been so long since i've hacked on Premise I just don't remember all the details. Can someone please explain the right recipe?

Oh, and while I'm at it, does anyone know why ADI_InputAnalogEx and ADI_InputCurrentEx inherit from DigitalInputEx instead of AnalogInputEx. It seems like if they had just done this right...
 
Figured it out. I think.

Created a class called Kindel_VoltageSensor

It contains

- Appliance (inherited class)
- PowerState - Boolean (ReadOnly, Bindable, ...)
- Voltage - Voltage (ReadOnly, Bindable, ...)
- RawValue - Integer (ReadOnly, Bindable, ...)
- Offset - Integer
- Gain - Real (Default value of 0.01953 because thats 5/256 (0-5v read using 0-255)
- OnChangeRawValue
Code:
if sysevent.newVal > 0 then
	this.PowerState = true
else
	this.PowerState = false
end if

this.Voltage = (this.RawValue + Offset) * this.Gain

There is no ValueProperty set.

LinkProperty is set to RawValue

The only issue I have with this when I create one of them under Home and attach BoundObject to my ADI_InputAnalogEx device I have to manually map the bindings for the values (click on "Values" under "BoundObject") to get RawValue to bind to Value and Offset to bind to Offset. I wish there was a way to make this automatic (?!?!).

Did I do this right? Any better way to do it?
 
Back
Top