// This module implements the visualization layer for devices
// in the Exhausto iTool WebServer.
Vex100Device.prototype = new Device();
Vex100Device.prototype.constructor = Vex100Device;
Vex100Device.superclass = Device.prototype;
Vex200Device.prototype = new Device();
Vex200Device.prototype.constructor = Vex200Device;
Vex200Device.superclass = Device.prototype;
MacDevice.prototype = new Device();
MacDevice.prototype.constructor = MacDevice;
MacDevice.superclass = Device.prototype;
TempDevice.prototype = new Device();
TempDevice.prototype.constructor = TempDevice;
TempDevice.superclass = Device.prototype;
function Device()
{
this.id = -1;
this.type = "Device";
this.name = "";
this.installed = false;
return this;
}
Device.prototype.WriteXmlAttributes = function(element)
{
element.setAttribute("Id", this.id);
element.setAttribute("Name", this.name);
element.setAttribute("BaseLogId", this.baseLog);
element.setAttribute("BasePointId", this.basePoint);
element.setAttribute("Installed", this.installed ? "true" : "false");
}
Device.prototype.ReadXmlAttributes = function(element)
{
var attributes = element.attributes;
this.id = Number(attributes.getNamedItem("Id").text);
if (attributes.length > 1)
{
this.name = attributes.getNamedItem("Name").text;
this.baseLog = Number(attributes.getNamedItem("BaseLogId").text);
this.basePoint = Number(attributes.getNamedItem("BasePointId").text);
this.installed = attributes.getNamedItem("Installed").text == "true" ? true : false;
}
}
function Vex100Device(element)
{
this.type = "VEX100";
this.heatType = "HCW";
this.coolType = "none";
this.co2Sensor = true;
this.humiditySensor = true;
this.exhaustSensor = true;
this.extractSensor = true;
this.airSensor = true;
this.heatSensor = false;
if (arguments.length > 0)
this.ReadXmlAttributes(element);
return this;
}
Vex100Device.prototype.WriteXmlAttributes = function(element)
{
Vex100Device.superclass.WriteXmlAttributes.call(this, element);
element.setAttribute("HeatType", this.heatType);
element.setAttribute("CoolType", this.coolType);
element.setAttribute("Co2Sensor", this.co2Sensor ? "true" : "false");
element.setAttribute("HumiditySensor", this.humiditySensor ? "true" : "false");
element.setAttribute("ExhaustSensor", this.exhaustSensor ? "true" : "false");
element.setAttribute("ExtractSensor", this.extractSensor ? "true" : "false");
element.setAttribute("AirSensor", this.airSensor ? "true" : "false");
element.setAttribute("HeatSensor", this.heatSensor ? "true" : "false");
}
Vex100Device.prototype.ReadXmlAttributes = function(element)
{
Vex100Device.superclass.ReadXmlAttributes.call(this, element);
var attributes = element.attributes;
if (attributes.length > 1)
{
this.heatType = attributes.getNamedItem("HeatType").text;
if (attributes.getNamedItem("CoolType"))
this.coolType = attributes.getNamedItem("CoolType").text;
else
this.coolType = attributes.getNamedItem("Cooler").text == "true" ? "CU" : "none";
this.co2Sensor = attributes.getNamedItem("Co2Sensor").text == "true" ? true : false;
this.humiditySensor = attributes.getNamedItem("HumiditySensor").text == "true" ? true : false;
this.exhaustSensor = attributes.getNamedItem("ExhaustSensor").text == "true" ? true : false;
this.extractSensor = attributes.getNamedItem("ExtractSensor").text == "true" ? true : false;
this.airSensor = attributes.getNamedItem("AirSensor").text == "true" ? true : false;
if (attributes.getNamedItem("HeatSensor"))
this.heatSensor = attributes.getNamedItem("HeatSensor").text == "true" ? true : false;
}
}
function Vex200Device(element)
{
this.type = "VEX200";
this.heatType = "HCW";
this.coolType = "none";
this.co2Sensor = true;
this.humiditySensor = true;
this.exhaustSensor = true;
this.extractSensor = true;
this.airSensor = true;
this.heatSensor = false;
if (arguments.length > 0)
this.ReadXmlAttributes(element);
return this;
}
Vex200Device.prototype.WriteXmlAttributes = function(element)
{
Vex200Device.superclass.WriteXmlAttributes.call(this, element);
element.setAttribute("HeatType", this.heatType);
element.setAttribute("CoolType", this.coolType);
element.setAttribute("Co2Sensor", this.co2Sensor ? "true" : "false");
element.setAttribute("HumiditySensor", this.humiditySensor ? "true" : "false");
element.setAttribute("ExhaustSensor", this.exhaustSensor ? "true" : "false");
element.setAttribute("ExtractSensor", this.extractSensor ? "true" : "false");
element.setAttribute("AirSensor", this.airSensor ? "true" : "false");
element.setAttribute("HeatSensor", this.heatSensor ? "true" : "false");
}
Vex200Device.prototype.ReadXmlAttributes = function(element)
{
Vex200Device.superclass.ReadXmlAttributes.call(this, element);
var attributes = element.attributes;
if (attributes.length > 1)
{
this.heatType = attributes.getNamedItem("HeatType").text;
this.coolType = attributes.getNamedItem("CoolType").text;
this.co2Sensor = attributes.getNamedItem("Co2Sensor").text == "true" ? true : false;
this.humiditySensor = attributes.getNamedItem("HumiditySensor").text == "true" ? true : false;
this.exhaustSensor = attributes.getNamedItem("ExhaustSensor").text == "true" ? true : false;
this.extractSensor = attributes.getNamedItem("ExtractSensor").text == "true" ? true : false;
this.airSensor = attributes.getNamedItem("AirSensor").text == "true" ? true : false;
this.heatSensor = attributes.getNamedItem("HeatSensor").text == "true" ? true : false;
}
}
function MacDevice(element)
{
this.type = "MAC";
this.outdoorTemp = true;
if (arguments.length > 0)
this.ReadXmlAttributes(element);
return this;
}
MacDevice.prototype.WriteXmlAttributes = function(element)
{
MacDevice.superclass.WriteXmlAttributes.call(this, element);
element.setAttribute("OutdoorTemp", this.outdoorTemp ? "true" : "false");
}
MacDevice.prototype.ReadXmlAttributes = function(element)
{
MacDevice.superclass.ReadXmlAttributes.call(this, element);
var attributes = element.attributes;
if (attributes.length > 1)
{
this.outdoorTemp = attributes.getNamedItem("OutdoorTemp").text == "true" ? true : false;
}
}
function TempDevice(element)
{
this.type = "TEMP";
if (arguments.length > 0)
this.ReadXmlAttributes(element);
return this;
}

