they require decoding the lighting messages as the occur (not hard) and keeping a local copy of the level of each of the groups you want to monitor < sorry nick..i don't really get what are you trying to say..would you mind to elaborate further?
Basically I need to get the lighting status (On/Off Only, not level) of all together 10 groups (Application address = 38hex in Cbus). However, as i have mentioned, it tooks bout 5-8 seconds to update n display in my pronto because of the following reasons:
(1) "Status Report" time of a s/w could only be set at 3 sec (min & could not b reduced further using C-bus Toolkit) which means when a switch is being press to on/off the light, it will takes the switch about 3 sec to update it status to c-bus b4 i could retrieve it using my pronto.
(2) The 1st 4 lines of PCI returns (e.g Ackowledgement char: .g) which i have mentioned earlier in the post further delay the decoding process about 1 sec.
(3) One thing i am not sure is that why the 3 lines of MMI report comes in line-by-line slowly (i retrieve it and display on my pronto) whereas it could be retrieve n display immediately when I use c-bus diagnostic kit to read the MMI application report.
CF.widget("label1").label = Com1.match("","\r",0);
message = CF.widget("label1").label;
checkstr = message.substr(1,6);
(4) I could only set my pronto page script to excute every 1 sec. Further reduces would causes some status fail to retrieve n update.
Hence, the delay here n there added up causes my status update process becomes very slow. Anyway..i have pasted my script here and would really appreciate if someone could help. THANK YOU VERY MUCH!
Page Script
-----------
var Com1 = CF.extender[0].serial[0];
var checkstr = "";
var group1 = "";
var group2 = "";
var group3 = "";
var group17 = "";
var group174 = "";
var group230 = "";
var group1hex = "";
var group2hex = "";
var group3hex = "";
var group17hex = "";
var group174hex = "";
var group230hex = "";
var message = "";
if (Com1 == null)
{
Diagnostics.log("Extender 0 is not a serial extender");
}
Com1.bitrate = 9600;
Com1.databits = 8;
Com1.parity = 0;
Com1.stopbits = 1;
if (CF.widget("label1").label == "")
{
CF.widget("label1").visible = false;
RefreshPage();
}
function initializepage()
{
CF.widget("label1").visible = false;
CF.widget("status1").visible = false;
CF.widget("status2").visible = false;
CF.widget("status3").visible = false;
CF.widget("status4").visible = false;
CF.widget("status5").visible = false;
CF.widget("status6").visible = false;
CF.widget("status7").visible = false;
CF.widget("status8").visible = false;
CF.widget("status9").visible = false;
CF.widget("status17").visible = false;
CF.widget("status174").visible = false;
CF.widget("status230").visible = false;
}
function RefreshPage()
{
Com1.send("~~~\r");
Com1.send("A3210038g\r");
Com1.send("A3420002g\r");
Com1.send("A3300079g\r");
}
GetState();
convertBase="0123456789abcdefghijklmnopqrstuvwxyz";
function convert(input,origin,dest)
{
input=input.toString().toLowerCase();
origin=origin.toString();
dest=dest.toString();
var b=0; var Result = "";
if (Number(origin)>convertBase.length || Number(dest)>convertBase.length || Number(origin)<2 || Number(dest)<2)
{
return "Invalid numbering system";
}
for (var c=1;c<=input.length;c++)
{
b+=convertBase.indexOf(input.substring(c-1,c))*(Math.pow(origin,input.length-c));
if (convertBase.indexOf(input.substring(c-1,c)) > Number(origin))
{
return 'Character "'+input.substring(c-1,c)+'" not present in origin system';
}
}
var a=Math.floor(Math.log(b)/Math.log(dest));
while (a>-1)
{
var e=Math.pow(dest,a);
a--;
var d=(b-b%e)/e+1;
b%=e;
Ciffer=convertBase.substring(d-1,d);
Result+=Ciffer;
}
return Result;
}
function GetState()
{
CF.widget("label1").label = Com1.match("","\r",0);
message = CF.widget("label1").label;
checkstr = message.substr(1,6);
if (checkstr == "D638B0" )
{
group230 = message.substr(33,2);
group230hex =convert(group230,16,2);
while (group230hex.length != 8)
{
group230hex = "0" + group230hex;
}
toggle(group230hex.substr(2,2),"230");
}
if (checkstr == "D83858")
{
group174 = message.substr(49,2);
group174hex =convert(group174,16,2);
while (group174hex.length != 8)
{
group174hex = "0" + group174hex;
}
toggle(group174hex.substr(2,2),"174");
}
if (checkstr == "D83800")
{
group1 = message.substr(7,2);
group2 = message.substr(9,2);
group3 = message.substr(11,2);
group17 = message.substr(15,2);
group1hex =convert(group1,16,2);
while (group1hex.length != 8)
{
group1hex = "0" + group1hex;
}
group2hex = convert(group2,16,2);
while (group2hex.length != 8)
{
group2hex = "0" + group2hex;
}
group3hex = convert(group3,16,2);
while (group3hex.length != 8)
{
group3hex = "0" + group3hex;
}
group17hex = convert(group17,16,2);
while (group17hex.length != 8)
{
group17hex = "0" + group17hex;
}
toggle(group1hex.substr(0,2),"3");
toggle(group1hex.substr(2,2),"2");
toggle(group1hex.substr(4,2),"1");
toggle(group2hex.substr(0,2),"7");
toggle(group2hex.substr(2,2),"6");
toggle(group2hex.substr(4,2),"5");
toggle(group2hex.substr(6,2),"4");
toggle(group3hex.substr(4,2),"9");
toggle(group3hex.substr(6,2),"8");
toggle2(group17hex.substr(4,2),"17");
}
}
function toggle(v,no)
{
if (v=="01")
{
CF.widget("Light"+no).label = "On";
CF.widget("status"+ no).label = v;
}
else
{
CF.widget("Light"+no).label = "Off";
CF.widget("status"+ no).label = v;
}
initializepage();
}
function toggle2(v2,no2)
{
if (v2=="01")
{
CF.widget("Light"+no2).label = "On";
CF.widget("status"+ no2).label = v2;
CF.widget("PLEASEWAIT").visible = false;
}
else
{
CF.widget("Light"+no2).label = "Off";
CF.widget("status"+ no2).label = v2;
CF.widget("PLEASEWAIT").visible = false;
}
initializepage();
}
********************************************************************************************************************************************************************
Button Script
-------------
Com1.send("~~~\r");
Com1.send("A3210038g\r");
if (CF.widget("status1").label == "10")
{
Com1.send("
\\053801007901g\r");
CF.widget("status1").label = "01";
toggle("01","1");
}
else
{
Com1.send("
\\053801000101g\r");
CF.widget("status1").label = "10";
toggle("10","1");
}
<!-- / message --><!-- attachments -->
Last edited by deric.lts on October 1, 2010 06:27.