Write(’{’);
boolean dFirst = true;
Write(’„Devices“:[’);
string deviceId;
foreach (deviceId, root.Devices().EnumUsedIDs())
{
object oDevice = dom.GetObject(deviceId);
boolean bDevReady = oDevice.ReadyConfig();
string sDevInterfaceId = oDevice.Interface();
string sDevInterface = dom.GetObject(sDevInterfaceId).Name();
string deviceAddress = oDevice.Address();
if (bDevReady)
{
if (dFirst)
{
dFirst = false;
}
else
{
WriteLine(',');
}
Write('{');
Write('"ID":"' # oDevice.ID());
Write('","Name":"' # oDevice.Name());
Write('","HssType":"' # oDevice.HssType() # '","Address":"' # oDevice.Address() # '","Interface":"' # sDevInterface);
Write('","Datapoints":[');
boolean dpFirst = true;
string sValue;
string sValueType;
string channelId;
foreach(channelId, oDevice.Channels())
{
object oChannel = dom.GetObject(channelId);
string channelName = oChannel.Name();
string channelAddress = oChannel.Address();
integer iChnDir = oChannel.ChnDirection();
if (iChnDir == 2)
{
object oWork = oChannel.DPByHssDP('WORKING');
if (oWork)
{
if (dpFirst)
{
dpFirst = false;
}
else
{
WriteLine(',');
}
oWId = oWork.ID();
Write('{');
Write('"ID":"' # oWork.ID());
Write('","Name":"' # oWork.Name());
Write('","TypeName":"HSSDP","Operations":"5",');
Write('"ValueType":2,"ValueUnit":"","Timestamp":"' # oWork.Timestamp());
Write('","Value":null');
Write(',"ChannelName":' # '"' # channelName # '"');
Write(',"ChannelAddress":' # '"' # channelAddress # '"');
Write(',"DeviceAddress":' # '"' # deviceAddress # '"');
Write(',"ChannelId":' # '"' # channelId # '"');
Write(',"DeviceId":' # '"' # deviceId # '"');
Write('}');
}
object oDir = oChannel.DPByHssDP('DIRECTION');
if (oDir)
{
if (dpFirst)
{
dpFirst = false;
}
else
{
WriteLine(',');
}
Write('{');
Write('"ID":"' # oDir.ID());
Write('","Name":"' # oDir.Name());
Write('","TypeName":"HSSDP","Operations":"5",');
Write('"ValueType":16,"ValueList":"' # oDir.ValueList() # '","Timestamp":"' # oDir.Timestamp());
Write('","Value":null');
Write(',"ChannelName":' # '"' # channelName # '"');
Write(',"ChannelAddress":' # '"' # channelAddress # '"');
Write(',"DeviceAddress":' # '"' # deviceAddress # '"');
Write(',"ChannelId":' # '"' # channelId # '"');
Write(',"DeviceId":' # '"' # deviceId # '"');
Write('}');
}
}
if (oChannel.HssType() == "SMOKE_DETECTOR")
{
object oDP = oChannel.DPByHssDP('STATE');
if(oDP.ID())
{
if (dpFirst)
{
dpFirst = false;
}
else
{
WriteLine(',');
}
Write('{');
Write('"ID":"' # oDP.ID());
Write('","Name":"' # oDP.Name());
Write('","TypeName":"HSSDP');
Write('","Operations":5');
Write(',"ValueType":2');
Write(',"ValueUnit":"');
Write('","Timestamp":"' # oDP.Timestamp());
Write('","Value":');
sValue = oDP.Value();
if (sValue)
{
Write('"' # 'true' # '"');
}
else
{
Write('"' # 'false' # '"');
}
Write(',"ChannelName":' # '"' # channelName # '"');
Write(',"ChannelAddress":' # '"' # channelAddress # '"');
Write(',"DeviceAddress":' # '"' # deviceAddress # '"');
Write(',"ChannelId":' # '"' # channelId # '"');
Write(',"DeviceId":' # '"' # deviceId # '"');
Write('}');
}
}
string sDPId;
foreach(sDPId, oChannel.DPs().EnumUsedIDs())
{
object oDP = dom.GetObject(sDPId);
if (oDP.ID())
{
if (oDP.TypeName() != "VARDP")
{
if (dpFirst)
{
dpFirst = false;
}
else
{
WriteLine(',');
}
sValueType = oDP.ValueType();
Write('{');
Write('"ID":"' # oDP.ID());
Write('","Name":"' # oDP.Name());
Write('","TypeName":"' # oDP.TypeName());
Write('","Operations":' # oDP.Operations());
Write(',"ValueType":' # sValueType);
if (sValueType == 16)
{
Write(',"ValueList":"');
WriteURL(oDP.ValueList());
Write('"');
}
if(oDP.ValueUnit() == '""')
{
Write(',"ValueUnit":"' # "");
}
else
{
Write(',"ValueUnit":"' # oDP.ValueUnit());
}
Write('",');
Write('"Timestamp":"' # oDP.Timestamp());
Write('","Value":');
if (sValueType == 20)
{
Write('"');
WriteURL(oDP.Value());
Write('"');
}
else
{
sValue = oDP.Value();
if (sValueType == 2)
{
if (sValue)
{
Write('"' # 'true' # '"');
}
else
{
Write('"' # 'false' # '"');
}
}
else
{
if (sValue == "")
{
Write('"' # '0' # '"');
}
else
{
Write('"' # sValue # '"');
}
}
}
Write(',"ChannelName":' # '"' # channelName # '"');
Write(',"ChannelAddress":' # '"' # channelAddress # '"');
Write(',"DeviceAddress":' # '"' # deviceAddress # '"');
Write(',"ChannelId":' # '"' # channelId # '"');
Write(',"DeviceId":' # '"' # deviceId # '"');
Write('}');
}
}
}
}
Write(']}');
}
}
Write(’]}’);