Control Program 9.167K

if (pgerror) then
status_mess pgstatus;
endif;

if powerup then
gosub 2;
endif;

if BV21 on_for 5:s {stop BV21;};

a = scanrate;

if ((BV21 or SCH0) and (AV48>0)) then
AV48 = 0;
endif;

print AV22 ' ppm'; line4;
print AV21 units; line5;

AV47 = runtime;

if Button1 then
u = (u + 1) % 26;
gosub 1;
endif;

if Button2 then
u = (u - 1) % 26;
if u < 0 {u = 25;};
gosub 1;
endif;

X = minval(X,AI0);
Y = maxval(Y,AI0);

o = (o + 3) % 100;

do_every 60:s;
if (u=0) then
mainscreen;
updatelines(1);
endif;
enddo;

do_every 1:s;
if u <> 15 then
t = t + 1;
endif;
if t > 300 then
gosub 1;
u = 15;
t = 0;
endif;
enddo;


do_every 1:s;

if (u=0) then
  if (v=0) then
  v = 1;
  mainscreen;
  endif;
print AI1 '°C'; line1;
print AV21 '°C'; line2;
print AI0 '°C'; line3;
endif;

if u = 1 then
print 'Date/Time'; line1;
Print month '/' day '/' year ' - ' weekday ' - ' yearday; line2;
print hour ':' min ':' sec; line3;
endif;

if (u=2) then
print AI0 '°C'; line3;
display_tl0,3,2,1,1;
endif;

if (u=3) then
print AI1 '°C'; line3;
display_tl1,3,2,1,1;
endif;

if (u=4) then
print AI2 '°C'; line3;
display_tl2,3,2,1,1;
endif;

if (u=5) then
print AI4 '°C'; line3;
display_tl4,3,2,1,1;
endif;

if (u=6) then
print AI5 '°C'; line3;
display_tl5,3,2,1,1;
endif;

enddo;

do_every 5:s;

if u = 7 then
print F ' deg'; line3;
display_tl7,3,0.1,1,1;
endif;

enddo;

do_every 1:s;
m=limit(100* BI0,m - 10,m + 5);
n=limit(100* BI1,n - 10,n + 5);
enddo;

do_every 3:s;
if  (u=8) then
setpen(0,1);
setfont(0,1);
setbrush(1,65504,0,0,0,0);
write(35,5) hour ':' min ':' sec ' <> ' month '/' day '/' year ' - ' weekday '/' yearday;
write (45,30,1,63488,1055) 'Air Handling Unit #1';
write (85,145) AO0 '%';
write (5,65) AO2 '%';

draw(0,1,63488,2016,m) fanr(140,110,30,o,0,BI0,1,1);

draw(0,1,63488,2016,n) fanl(170,200,30,o,0,BI1,1,1);

draw line(30,110,30,170);

draw(0,1,44091,63488,AO0) rectangle(90,80,100,140);

draw(0,1,19229,20400,AO2) dmpv(15,110,50,10,0,65504);
draw(0,1,20400,19229,AO2) dmph(30,145,10,40,0,65504);

write (125,65) 'SF - ' BO4 units;
write (130,155) 'EF - ' BO5 units;

write (190,65,0,0,65504) AV30 units;
write (190,80) AI2 units;
write (40,95) AI3 units;

write (30,205,0,0,65504) 'SCH = ' SCH0;
write (30,220,0,0,65504) 'OvrT = ' AV48;

draw(0,1,905) rectangle_re(30,280,60,310,5);
draw hand(65,283,AI5.outofservice,65504);
write (30,250,0,0,65504) AV22 units;
write (30,265) AI5 units;

draw(0,1,2016) rectangle_re(180,280,210,310,5);
draw hand(215,283,AI0.outofservice,65504);
write (180,250,0,0,65504) AV21 units;
write (180,265,0,0,Z) AI0 units;

draw(0,1,400) rectangle_re(105,280,135,310,5);
draw hand(140,283,AI1.outofservice,65504);
write (110,250) 'Oat';
write (105,265) AI1 units;

endif;

enddo;

do_every 1:s;
if  (u=9) then
draw aclock(120,160,60,2,440);
endif;

if (u=10) then
draw aclock(120,85,80,3,440);
endif;


if  (u=9) then

draw gauge(60,60,50,0,100,2,10,2,300,0,10,3000,scanrate_r);

draw gauge(180,60,50,0,100,2,10,2,300,0,0,64040,scanrate);

draw(0,1,540,65488,1) mmgauge(60,260,50,19,26,2,10,2,270,0,0,3364,AI0,X,Y);

draw(0,1,540,32713,1) mmgauge(180,260,50,-30,40,2,14,2,270,0,0,3364,AI0,AI1,AI4);
endif;


if (u=10) then
draw mmgauge(120,245,70,0,2400,2,24,2,360,180,0,540,dectime(time),dectime(sunset),
dectime(sunrise));
endif;


if (u=11) then
draw aclock(120,120,115,3,440);
write(70,245,2,63488,1055) 'Tx Pkt - ' tx_pkt;
write(70,270,2,63488,1055) 'Rx Pkt - ' rx_pkt;
write(90,40,3,65095,440) 'Falcon';
write(80,180,2,63488,1055) month '/' day '/' year;

endif;
enddo;

if (u=11) then
draw(0,1,62881,63660) button(1,1,10,270,50,310,5,'C');
draw(0,1,2016,8447) button(2,1,190,270,230,310,5,'+');
endif;

if (u=12) then

draw(0,1,2016,8447) button(1,1,30,5,210,30,5,'Toggle Output');
draw(0,1,63488,8447) button(2,1,30,35,210,60,5,'B');
draw(0,1,2016,8447) button(3,1,30,65,210,90,5,'C');

if button(1) then
BO1 = !BO1;
endif;
if button(2) then
V = V + 1;
endif;
if button(3) then
V = 0;
endif;

endif;

do_every 1:s;

if (u=13) then
draw gauge(120,120,115,0,100,2,10,2,300,0,25,340,scanrate_r);
write(100,190,3,63488,340) scanrate;
endif;

enddo;

if (u=14) then
draw(63488,1,62881,1314) keypad(12,25,30,85,90,10,'123456789<0>');

V = Keypad(0);
if (V > 0) then
W = V;
endif;

endif;

if (u=15) then

do_every 1:s;
k = rand % 360;
x = rand % 360;
y = rand % 2535 + 63000;
/*
v = v + 1;
if v>20 then
cls(0);
v = 0;
endif;
*/
draw(y,1,63488) triangle(120,160,90,115,x,k);
draw(0,1,2014) slider(5,200,100,10,0,x / 3.6);
draw(0,1,2014) slider(25,290,100,10,2,k / 3.6);

enddo;

endif;
 

F = sun_alt;
av59 = sun_alt;
G = sun_az;
H = sun_dec;
I = sun_ra;
J = sun_z;

w = 10;

do_every 5:s;

K = solar_pwra(ai1,av51,elevation_press,v,90,180,1);
L = solar_pwr(ai1,av51,elevation_press,v,1);
M = solar_pwr(ai1,av51,elevation_press,v,2);
N = solar_pwra(ai1,av51,elevation_press,v,90,0,1);
O = solar_pwra(ai1,av51,elevation_press,v,90,90,1);
P = solar_pwra(ai1,av51,elevation_press,v,90,180,1);
Q = solar_pwra(ai1,av51,elevation_press,v,90,270,1);
R = solar_pwr(ai1,av51,elevation_press,v,4);
S = solar_pwra(ai1,av51,elevation_press,v,J,G,1);


if (u=16) then
write(65,60,3,63488,540) S ' w/m2';
draw mmgauge(120,120,115,0,2400,4,24,2,360,180,0,540,dectime(time),dectime(sunset),
dectime(sunrise));
write(70,270,3,63488,1055) hour ':' min ':' sec;
endif;

if (u=17) then
solar_scr1(ai1,av51,elevation_press,w,J,G,10,25,10,0,63488);
endif;

enddo;

do_every 5:s;
if (u=18) then
input_sd(25,10);
endif;

if (u=19) then
output_sd(25,10);
endif;

if (u=20) then
var_asd(25,10,0);
endif;

if (u=21) then
var_asd(25,10,20);
endif;

if (u=22) then
var_asd(25,10,40);
endif;

if (u=23) then
var_bsd(25,10,0);
endif;

if (u=24) then
var_bsd(25,10,20);
endif;

if (u=25) then
com_sd(20,10,0);
endif;

enddo;

A = sunrise;
B = sunset;

C = table(u:1,3,5,7,9,11,13,15,17,19,21,23,25);

D = longitude;
E = latitude;

z = scannercnt;

if BI2 then
AV48 = AV49;
endif;

do_every 6:s;
AV48 = limit(AV48 - 0.1, 0, AV49);
enddo;

b = minval(AI0,AI4);
c = maxval(AI0,AI4);
d = avgval(AI0,AI4);
f = ((CO0/10) - 5);
AV29 = scale(AI1, ((CO0/10) - 5), AV26, AV27, AV25, AV28);

AV21 = limit(AV21, AV24, AV23);

e = scale(AI1,0,-5,1,10,15);

do_every 5:s;
AV45 = limit(AV21, AV45 - 0.1, AV45 + 0.1);
av30=limit(av29, av30 - 0.1, av30 + 0.1);
r = limit((100*(BI0 on_for 10:s)), r - 5, r + e);
enddo;

g = scale(AI1,0,-10,50,5,100);
s = scale(CO2,0,0,0,100,50);

if SCH0
{stop BV22;}
else
{BV22 = switch(BV22, d, AV21 - 3, AV21 - 2);};

if (SCH0 or BV22 or (AV48>0.1)) {start BO4;} else {stop BO4;};

if BI0 on_for 5:s then
BO5 = switch(BO5, AO2, 35, 30);
  if BV22
  {AO0 = scale(CO0, 0, 0, 0, 100 ,100);}
  else
  {AO0 = scale(CO1, 0, 0, 100, 49 ,0);};
q = scale(CO1, 0, 51, AV46, 100, g);
AO2 = minval(r,q) * (!BV22);
endif
else then
stop BO5;
AO0 = scale(AI1,0,-25,25,10,0);
AO2 = 0;
CO0.bias = scale(AI1, 0, -10, 65, 25, 45);
CO1.bias = scale(AI1, 0, -10, 30, 25, 60);
CO2.bias = 0;
av30 = av29;
endif;

//stop BO0,BO1,BO2,BO3,BO6,BO7;
AO1 = 0;
AO3 = 0;

T = 128 + (SCH0*1) + (BI0*2) + ((AO0 > 0) * 4) + ((AO2 > 5) * 8) + ((AO1 > 0) * 16) + 64;

AV34 = T;

get 80500.AI5, AI0,10;
get 80500.AI0, AI1,12;
get 80500.AI2, AI2,14;
get 80500.AI3, AI3,15;
get 80500.AI4, AI4,18;
get 80500.AV21, AV21,8;

/*
get 10200.bv1, bv29, 10;
get 1000.bv1, bv28, 12;
*/
do_every 3:s;
av50 = elevation_press;
y = scale(ai1,0,-25,70,0,0);
av51 = scale(ai1,0,-10,15,30,45);

av52 = rhdata(ai0,av50,av51,1);

av53 = rhdata(ai0,av50,av51,2);

av54 = rhdata(ai0,av50,av51,3);

enddo;

/*
do_every 3600:s;
updatetime;
start BV23;
enddo;

if BV23 on_for 10:s then
stop BV23;
timesync;
endif;

do_every 91:s;
srand (y);
enddo;

/*
do_every 63:s;
k = rand;
enddo;

x = pgsize(0);
*/

U = alarm_a(1,AI0,AV21,1,1,0.1,5,10:s);

Z = table(U:1055,8607,64041);

ifonce BV21 then
w = rand;
endif;

ifonce BI5 then
mailsubj('Test Alarm Message');
mailmess('The Falcon is in alarm

' AI0 name ' - ' AI0 units ' / ' AI1 name ' - ' AI1 units ' @ ' hour ':' min ':' sec '


Falcon Ed');
sendmail;
endif;

ifonce screen_update then
gosub 1;
endif;

h = BI1.accum_val;
//i = BI0.accum_aval;
i = BI1.accum_time;
j = BI1.accum_aval;

/*
AI0 = 60000 / i ;
AI1 = j;
*/
p = 60000 / i ;

done;

subroutine;

1:
clearlines;
resettimer(2,3,5,6,7,8,9);
v = 0;
t = 0;
cls(0);

return;

2:
u=15; v=0;
X = 500; Y = -500;
t = 225;
k = 100;
cls(0);
CO0.bias = 50;
CO1.bias = 50;
w=0;
mailrcpt('edveldman@dtekcontrols.com');
clearlines;
start BV21;
BI0.accum_sp = 20000;
BI1.accum_sp = 20000;
BI0.accum_edge = 2;
BI1.accum_edge = 1;
BI0.accum_pval = 0.002;
BI1.accum_pval = 1;
BI0.accum_reset;
BI1.accum_reset;
stop BI0.accum_en;
start BI1.accum_en;
screen_button(1);
return;

eof;