Premise Another noob question: Using unit types like Temperature

Motorola Premise

ckindel

Member
I have an OnChangeTemperature property change script on a temperature sensor for my equipment room.

In it I want to do the following:
Code:
Dim t As Sys.Schema.Units.Temperature

t.Kelvin = sysevent.newVal

if t.Farenheit >= 90 and t.Farenheit < 200 then
...

Of course there's no Dim in VBScript so this won't work. How do I delcare my variable so that I can have it hold a Temperature value?

(Yes I know I could manually convert Kelvin to Farenheit. That's how I had coded it 8 years ago. But was ugly and bugging me and now I really want to understand how to do this).
 
This may circumvent the issue, but why not simply use the temperature sensor's Temperature property instead of sysvent.newVal?

Code:
with this.Temperature
	if .Fahrenheit >=90 and .Fahrenheit < 200 then
		...
	end if
end with
 
This may circumvent the issue, but why not simply use the temperature sensor's Temperature property instead of sysvent.newVal?

Code:
with this.Temperature
	if .Fahrenheit >=90 and .Fahrenheit < 200 then
		...
	end if
end with

That would work.

But does circumvent what I'm really asking: How do I instantiate an object of type "unit" like Temperature in a script?
 
I'm no where near the Premise expert you and 123 are, but the only way I know to do this is to use the CreateObject method. I didn't try the code below, but I'm sure you get the idea... When you're done using the variable, you can use the DeleteObject method to remove it...

this.CreateObject(Schema.System.Units.Temperature.Path, "Temp")
 
Back
Top