DEFINT a-z DECLARE FUNCTION INPy LIB "C:\K8000\VISBAS\InpOut32.DLL" ALIAS "Inp32" (BYVAL portAdress AS INTEGER) AS INTEGER DECLARE SUB OUTx LIB "C:\K8000\VISBAS\InpOut32.DLL" ALIAS "Out32" (BYVAL portAdress AS INTEGER, BYVAL Value AS INTEGER) DECLARE FUNCTION OpenDevice LIB "c:\qb\src\k8055d.dll" ALIAS "OpenDevice" (BYVAL CardAddr AS LONG) AS LONG DECLARE FUNCTION ReadDigital LIB "c:\qb\src\k8055d.dll" ALIAS "ReadDigitalChannel" (BYVAL Channel AS LONG) AS BYTE DECLARE FUNCTION ReadAnalog LIB "c:\qb\src\k8055d.dll" ALIAS "ReadAnalogChannel" (BYVAL Channel AS LONG) AS LONG DECLARE SUB CloseDevice LIB "c:\qb\src\k8055d.dll" ALIAS "CloseDevice" () DECLARE SUB OutputAnalog LIB "c:\qb\src\k8055d.dll" ALIAS "OutputAnalogChannel" (BYVAL Channel AS LONG, BYVAL Dat AS LONG) DECLARE SUB ClearDigital LIB "c:\qb\src\k8055d.dll" ALIAS "ClearDigitalChannel" (BYVAL Channel AS LONG) DECLARE SUB SetDigital LIB "c:\qb\src\k8055d.dll" ALIAS "SetDigitalChannel" (BYVAL Channel AS LONG) DECLARE SUB readIOchip (ChipNo%) DECLARE SUB OutputDACchannel (ChannelNo%, DataVar%) DECLARE SUB setIOchannel (ChannelNo%, i%) DECLARE SUB readADchannel (ChannelNo%) DECLARE SUB I2Cstart () DECLARE SUB I2Coutput (Serdata%) DECLARE SUB I2Cclockpulse () DECLARE SUB I2Cstop () DECLARE SUB setIO(i, j) DECLARE FUNCTION DecToBin$ (DecNumber%) DECLARE FUNCTION BinToDec% (BinNumber$) DECLARE FUNCTION BINNOT% (Dec%) DECLARE FUNCTION I2Cinput% () DECLARE FUNCTION SHL% (Dec%, Positions%) DECLARE SUB setchannel(i, j) DECLARE FUNCTION dat() AS STRING DECLARE FUNCTION datum(a$) AS STRING DECLARE FUNCTION klo(i) AS WORD DECLARE FUNCTION vraag! (i AS SINGLE, j AS SINGLE) DECLARE FUNCTION ttm(i) AS STRING DECLARE FUNCTION iokk(i%) AS INTEGER DECLARE FUNCTION inkk$ AS STRING DECLARE SUB showttab (a$, j1, tm1, tn1, z1) DECLARE SUB sh(a$) DECLARE SUB msg(a$) DECLARE SUB SETt(k, ii) DECLARE SUB tempcorr (tc AS SINGLE, tm, i, tcx AS SINGLE, tcy AS SINGLE) DECLARE SUB frm (tc3 AS SINGLE, i) DECLARE SUB klep (i, tc4 AS SINGLE) DECLARE SUB settijd (u, k) DECLARE SUB now (j1, tm1, tn1, z1, tc AS SINGLE) DECLARE SUB sp (ll, a$) DECLARE SUB ncol (i%) DECLARE SUB syslog(a$) DECLARE FUNCTION ionstatus() AS INTEGER DECLARE SUB dualp(i) DECLARE SUB dualps(a$) SUB setusb(i AS INTEGER, j AS INTEGER) IF j THEN CALL setdigital (i) ELSE CALL cleardigital (i) END IF SLEEP 1 END SUB STATIC FUNCTION ttx(a$) ' conversion time$ to timeindex [0..144] ttx = VAL(LEFT$(a$, 2)) * 6 + VAL(MID$(a$, 4, 1)) END FUNCTION #INCLUDE "..\kconst.bi" %MaxIOcard = 1: %MaxIOchip = 2: %MaxIOchannel = 16: %MaxADchannel = 4 %StatusPort = 889: %ControlPort = 890: %I2Cbusdelay = 100 $ddd = "janfebmaraprmeijunjulaugsepoktnovdec" GLOBAL tc1 AS SINGLE GLOBAL dow AS INTEGER GLOBAL fb AS INTEGER GLOBAL tc8 AS SINGLE GLOBAL man AS INTEGER GLOBAL bb AS INTEGER GLOBAL bad AS INTEGER ' afteller bad GLOBAL bx AS INTEGER GLOBAL ink AS INTEGER GLOBAL mms AS STRING *10 GLOBAL powergood AS INTEGER GLOBAL DACchipCode() AS INTEGER: GLOBAL IOChipCode() AS INTEGER: GLOBAL IOConfig() AS INTEGER GLOBAL IOData() AS INTEGER: GLOBAL io() AS INTEGER: GLOBAL ADDAChipcode() AS INTEGER GLOBAL ad() AS INTEGER GLOBAL brst AS INTEGER GLOBAL ion AS INTEGER GLOBAL restart AS INTEGER #INCLUDE "..\bib\inl.bi" ' screen input/output ' ini file handling ' random record length file handling #INCLUDE "..\K8000.bi" FUNCTION PBMAIN() CLS PRINT "Starting ..." IF opendevice(3) < 0 THEN PRINT "Error opening USB device" EXIT FUNCTION END IF note = 0 insr = 0 upos = 0 DIM IOChipCode(0 TO %MaxIOchip) AS GLOBAL INTEGER FOR i = 0 TO %MaxIOchip IOChipCode(i) = 112 + 2 * i NEXT i DIM IOConfig(0 TO %MaxIOchip) AS GLOBAL INTEGER DIM IOData(0 TO %MaxIOchip) AS GLOBAL INTEGER DIM io(1 TO %MaxIOchannel) AS GLOBAL INTEGER DIM ADDAchipCode(0 TO %MaxIOcard) AS GLOBAL INTEGER FOR i = 0 TO %MaxIOcard ADDAchipCode(i) = 144 + 2 * i NEXT i DIM DACchipCode(0 TO %MaxIOcard) AS GLOBAL INTEGER FOR i = 0 TO %MaxIOcard DACchipCode(i) = 64 + 2 * i NEXT DIM ad(1 TO %MaxADchannel) AS GLOBAL INTEGER DIM outsw(1 TO 8) AS GLOBAL INTEGER 'positie uitgangen DIM ttp(4, 7) AS GLOBAL SINGLE 'temperatuurtabellen DIM tcb AS SINGLE 'branderoffset DIM tc0 AS SINGLE 'kelderoffset DIM tck AS SINGLE 'keldercorr DIM tc1 AS SINGLE 'gecorrigeerde setwaarde living DIM dow AS INTEGER 'temperatuur naar omlaag DIM fb AS INTEGER 'bad-flag: ook tweede klep open DIM tc2 AS SINGLE 'gecorrigeerde setwaarde kamers DIM tc3 AS SINGLE 'setwaarde ketel DIM tc4 AS SINGLE 'warmtevraag living (waarde voor brander) DIM tc5 AS SINGLE 'warmtevraag kamers DIM tc4a AS SINGLE 'warmtevraag living (waarde voor circulateur) DIM tc5a AS SINGLE 'warmtevraag kamers DIM tc6 AS SINGLE 'totale warmtevraag voor brander DIM tcc AS SINGLE 'totale warmtevraag voor circulateur DIM tc7 AS SINGLE 'evolutie warmtevraag DIM kbc AS SINGLE 'kelderbrandercorrectie DIM tc8 AS SINGLE 'temperatuurcorrectie DIM txp AS SINGLE DIM tca AS SINGLE 'tijdelijke waarde temperatuurberekening DIM s AS SINGLE DIM ss AS SINGLE DIM badt AS INTEGER ' preset temperatuur bad DIM bs AS INTEGER 'man branderteller DIM statu(1 TO 7) AS GLOBAL STRING statu$(1) = "Living" statu$(2) = "Kamer" statu$(3) = "CircLow" statu$(4) = "Brander" statu$(5) = "Watchdog" ' wordt niet ingesteld ! statu$(6) = "Bad" statu$(7) = "CircHigh" COMM OPEN "com1" AS #5 COMM SET #5, BAUD = 9600 COMM SET #5, BYTE = 8 COMM SET #5, PARITY = 0 COMM SET #5, STOP = 0 COMM SET #5, TXBUFFER = 128 COMM SET #5, RXBUFFER = 128 COMM PRINT #5, $FF; outx %ControlPort, 4 FOR i = 8 TO 16 ' config channel as input ChipNo% = (i - 1) \ 8 Channel% = (i - 1) MOD 8 IOconfig(ChipNo%) = IOconfig(ChipNo%) AND BINNOT(SHL(1, Channel%)) setIOchannel i, 0 IOconfig(ChipNo%) = IOconfig(ChipNo%) OR SHL(1, Channel%) NEXT i FOR i = 1 TO 7 'config channel as output ChipNo% = (i% - 1) \ 8 Channel% = (i% - 1) MOD 8 IOconfig(ChipNo%) = IOconfig(ChipNo%) AND BINNOT(SHL(1, Channel%)) NEXT i badt = VAL(getini($ini, "badt")) DIM stat(1 TO 8, 1 TO 2) AS GLOBAL STRING DIM stot(1 TO 8) AS GLOBAL INTEGER DIM stxt(1 TO 8) AS GLOBAL INTEGER DIM tend(1 TO 8) AS GLOBAL INTEGER DIM dagg AS GLOBAL STRING DIM td(1 TO 2) AS GLOBAL INTEGER ' tijd open klep FOR i = 1 TO 2 a$ = "td" + FORMAT$(i) td(i) = VAL(getini($ini, a$)) IF td(i) THEN setini $ini, a$, "" END IF NEXT i DIM ct(1 TO 4) AS GLOBAL INTEGER DIM man AS INTEGER DIM bb AS INTEGER DIM bad AS INTEGER DIM bx AS INTEGER DIM ink AS INTEGER DIM mms AS GLOBAL STRING * 10 FOR i = 1 TO 4 a$ = FORMAT$(i) ttp(i, 1) = VAL(getini($ini, "offset" + a$)) ttp(i, 2) = VAL(getini($ini, "divider" + a$)) ttp(i, 6) = VAL(getini($ini, "fast" + a$)) ttp(i, 7) = VAL(getini($ini, "slow" + a$)) ttp(i, 3) = VAL(getini($ini, "3" + a$)) ttp(i, 4) = VAL(getini($ini, "4" + a$)) setini $ini, "3" + a$, "" setini $ini, "4" + a$, "" NEXT i tc0 = VAL(getini($ini, "kelderoffset")) 'correctie gevraagde temperatuur door keldertemp. Wordt tc8 tck = VAL(getini($ini, "keldercorr")) 'brandertemperatuur bepalen rekening houdend met keldertemp bc = VAL(getini($ini, "brandercorr")) 'voor de lange-termijn berekening branderoffset '(temp lager dan bc: geen down-correctie bij kleppen gesloten) kbn = VAL(getini("kb.ini", "n")) DIM kb(1 TO kbn, 1 TO 2) AS INTEGER i = 1 OPEN "kb.ini" FOR INPUT AS #1 WHILE NOT EOF(1) LINE INPUT #1, a$ j = VAL(LEFT$(a$, 3)) k = VAL(MID$(a$, 5, 2)) IF j <> 0 OR k <> 0 THEN kb(i, 1) = j kb(i, 2) = k INCR i END IF WEND CLOSE #1 FOR i = 1 TO 8 stat(i, 1) = getini("ks.ini", "stat" + FORMAT$(i)) stat(i, 2) = getini("ks.ini", "stit" + FORMAT$(i)) setIO i, 0 cleardigital i NEXT i tcb = VAL(getini($ini, "branderoffset")) 'corrigeert brandertemp. op lange termijn bad = VAL(getini($ini, "bad")) 'overblijvende tijd bad bb = -8 msg "S " + TIME$ COMM PRINT #5, CHR$(12); SHELL "kd" 'dagbepaling, backup, copy naar f:\, display layout CURSOR OFF dagg$ = getini($ini, "dagg") powergood = -1 eindeinlezen: GOSUB cleam LOCATE 12, 1 ppp "<*>- Einde", 0, 0: LOCATE , 21: ppp "<.>- Showtemp", 0, 1 ppp "<1>- Manuele modus", 0, 1 ppp "<2>- Annul tijdel status", 0, 1 ppp "<4>- Tijdelijke temp", 0, 1 ppp "<7>- Restart", 0, 1 reloadtemp = -1: start = 0 terug: GOSUB intemp IF reloadtemp OR MID$(oldtime$, 5, 4) = "0:00" THEN reloadtemp = 0 LOCATE 2, 1: COLOR 3: PRINT "Inlezen temperatuurtabel": COLOR 7 LOCATE 7 showttab "1", j1, tm1, tn1, z1 ' vaste temp, tijdelijke temp, showttab "2", k2, tm2, tn2, z2 ' volgende vaste, volgende tijdelijke bx = k2 < 0 OR tm2 < 0 k2 = ABS(k2): tm2 = ABS(tm2) END IF LOCATE 2, 1: COLOR 3 IF se < 54 AND start = 0 AND tc8 <> 0 THEN start = 5 PRINT "Bad modus bepalen en correctietemperatuur (kelderoffset) tonen" LOCATE 22, 25: COLOR 6: PRINT "Bad-modus:"; IF bx THEN COLOR 4: PRINT " aan"; ELSE IF bad < 0 THEN INCR bad COLOR 4: PRINT -bad; ELSE COLOR 9: PRINT " uit"; END IF END IF COLOR 6: PRINT " Bad-status:"; COLOR IIF(fb, 9, 4) PRINT fb LOCATE 5, 59: COLOR 7: PRINT FORMAT$(tc8, "* 0.0"); IF DOWNn THEN SETt 3, 0: SETt 7, 0 ELSEIF tcc > .02 AND tcc < .2 AND klo(5) THEN 'ct(3) = 1 'warmtevraag circulateur groter SETt 3, 1: SETt 7, 0 'dan 0.5ø: laagste vermogen op END IF '50% van de tijd ELSEIF se > 4 AND start = 5 THEN start = 10 PRINT "Temperatuurcorrectie en warmtevraag bepalen": COLOR 7 LOCATE 7 tempcorr tc1, tm1, 1, tc4, tc4a ' tc4: brander, tc4a: circu tempcorr tc2, ABS(tm2), 2, tc5, tc5a tc4 = IIF(tc4 > 0, tc4 / 2, tc4) 'living vraag voor brander tc5a = IIF(tc5a > 0, tc5a /2, tc5a) 'kamers vraag voor circu tc5 = tc5 * 2 + .1 'kamers vraag voor brander tc6 = vraag!(tc4, tc5) 'vraag voor brander tcc = vraag!(tc4a, tc5a) 'vraag voor circulateur LOCATE 10, 39 PRINT FORMAT$(tcc, "* #0.0"); LOCATE , 46: PRINT FORMAT$(tc6, "* #0.0") LOCATE 25, 20 COLOR 6: PRINT FORMAT$(tc4a, "* ##0.00") FORMAT$(tc5a, "* #0.00") " " FORMAT$(tcc, "* #0.00") " "; COLOR 4: PRINT FORMAT$(tc4, "* ##0.00") FORMAT$(tc5, "* #0.00") FORMAT$(tc6, "* #0.00"); ELSEIF se > 9 AND start = 10 THEN start = 15 PRINT "Gewenste keteltemperatuur bepalen" j = VAL(MID$(oldtime$, 5)) i = ABS(IIF(z2, z2, tn2)) i = i + IIF(z1, z1, tn1) DOWNn = 0 i = i - (tm1 + ABS(tm2)) ' prediktie of aanpassing tc7 = 0 ' keteltemperatuur aan de IF i > 0 THEN UPp = UPp + 2 END IF IF i < 0 THEN ' dalende vraag: temperatuur DOWNn = -1 tc7 = i ELSEIF i > 0 AND j > 7 THEN tc7 = i * (j - 7) / 3 END IF kbc = -(ttp(3, 5) / 5 - tck) 'kelderbrandercorrectie COLOR 3: LOCATE 27, 1: PRINT "Warmtevraag + evolutie:"; PRINT FORMAT$(tc6, "* ##0.00") FORMAT$(tc7, "* ##0.00") LOCATE, 8: PRINT "Keldercorrectie:" FORMAT$(kbc, "* ##0.00"); PRINT " (" FORMAT$(-ttp(3, 5)/5, "0.00") " " FORMAT$(tck, "0.0") ")" ' PRINT FORMAT$(tc8, "* ###0.0") " (" FORMAT$(tc0, "0.0") " - " FORMAT$(ttp(3,5), "0.0") ")" LOCATE, 10: PRINT "Branderoffset:" FORMAT$(tcb / 10, "* ##0.00"); tc3 = (tc6 + tc7) * 10 'brandertemp = warmtevraag + evolutie tc3 = tc3 + tcb + kbc * 10 '+ branderoffset + keldertemp PRINT " =" FORMAT$(tc3 / 10, "* ##0.00") LOCATE 10, 52: COLOR 7: PRINT FORMAT$(tc3/10, "* 0.0") IF DOWNn THEN tc3 = 10 ELSEIF tc3 <= kb(1, 1) THEN ' --> setwaarde ketel tc3 = kb(1, 2) ELSE FOR i = 2 TO kbn IF tc3 = kb(i, 1) THEN ' setwaarde ketel berekenen tc3 = kb(i, 2) ' adhvd warmtevraag GOTO foundtemp ELSEIF tc3 < kb(i, 1) THEN tc3 = kb(i - 1, 2) + ((kb(i, 2) - kb(i - 1, 2)) * (tc3 - kb(i - 1, 1))) / (kb(i, 1) - kb(i - 1, 1)) GOTO foundtemp END IF NEXT i tc3 = kb(kbn, 2) END IF foundtemp: LOCATE 10, 59: PRINT FORMAT$(tc3, "* .0"); ELSEIF se > 14 AND start = 15 THEN start = 20 GOSUB bbr ELSEIF se > 19 AND start = 20 THEN start = 25 klep 1, tc1 ELSEIF se > 24 AND start = 25 THEN fb = bb < -8 OR DOWNn start = 30 klep 2, tc2 ELSEIF se > 29 AND start = 30 THEN start = 35 PRINT "Vermogen circulateur bepalen" 'COLOR 14: LOCATE 9, 79: PRINT CHR$(17): COLOR 7 br = bb > 1 'warmtevraag > 2: max vermogen MAXx = tcc > 2 'warmtevraag >.5: half vermogen high = tcc > .5 'warmtevraag >.2:laag vermogen low = tcc > .2 'warmtevraag >.02: 50% laag IF MAXx AND klo(7) THEN 'ct(3) = 6 SETt 3, 1: SETt 7, 1 ELSEIF high AND klo(6) THEN 'ct(3) = 4 SETt 7, 1: SETt 3, 0 ELSEIF (low AND klo(5)) OR br THEN 'ct(3) = 2 SETt 3, 1: SETt 7, 0 ELSE SETt 3, 0: SETt 7, 0 END IF 'IF downn THEN ' ct(3) = ct(3) / 2 'END IF ELSEIF se > 34 AND start = 35 THEN start = 40 PRINT "Offsetbepaling brandertemperatuur" COLOR 7: LOCATE 5, 72 IF outsw(1) = 0 AND outsw(2) = 0 AND outsw(6) = 0 THEN s = (bc - ttp(4, 3)) / 3333 'alle kleppen gesloten s = MIN(s, 0) PRINT CHR$(25); ELSEIF outsw(3) OR outsw(7) THEN 'circulateur aan s = s + .0001 IF outsw(7) THEN s = s + .0004 END IF PRINT CHR$(24); ELSE 'toestand OK PRINT CHR$(247); s = s / 1.2 END IF IF bad = 0 AND DOWNn = 0 THEN tcb = tcb + (s / (UPp + 1)) tcbok = -1 ELSE tcbok = 0 END IF IF UPp > 0 THEN DECR UPp END IF PRINT FORMAT$(tcb, "* .00"); 'COLOR 14: PRINT CHR$(17) COLOR 8 LOCATE 25, 1: PRINT FORMAT$(s, "* .0000"); LOCATE , 70: PRINT FORMAT$(upp, "00") CHR$(24) " " FORMAT$(downn, "00") CHR$(25); ELSEIF se > 39 AND start = 40 THEN start = 45 z = 0: GOSUB maaklog LOCATE 20, 35: PRINT SPACE$(5); ELSEIF se > 44 AND start = 45 THEN IF LEFT$(oldtime$, 5) = "23:59" THEN SETt 4, 0 SETt 5, 0 CLS FILECOPY $log, getini($ini, "log") PRINT "Statistieken van de dag" a$ = DIR$("log\" + dagg$ + "_*.log") WHILE LEN(a$) sh "ktnew 4 log\" + a$ a$ = DIR$ WEND SETt 5, -1 PRINT "Reset tijdelijke temperaturen" a$ = dagg$: GOSUB resettemp1o i = -1 PRINT "Weekstatistieken sh "ktnew 8" SETt 5, 0 PRINT "Creatie html" sh "ktnew 6" SETt 5, -1: i = -1 ttime: IF LEFT$(TIME$, 2) <> "00" THEN i = NOT i sett 5, i SLEEP 500: GOTO ttime END IF PRINT "Nieuwe dagbepaling" sh "kd" dagg$ = getini($ini, "dagg") SETt 5, -1 k = 0: GOTO shutrun ELSE start = 50 GOSUB bbr END IF ELSEIF se > 49 AND start = 50 THEN PRINT "Tijdelijke status verwerken": COLOR 7 start = 55 IF nlok = 0 THEN j = ttx(oldtime$) FOR i = 1 TO 6 LOCATE 23, 7 + i * 7 IF stot(i) THEN msg "" OPEN $tmf + "1" + dagg$ FOR RANDOM AS #2 LEN = 2 OPEN $tmf + "2" + dagg$ FOR RANDOM AS #3 LEN = 2 SELECT CASE i CASE 1 'Annul. bad = 0 FOR z = 1 TO 8 stxt(z) = 0 setIO z, 0 NEXT z IF stot(7) THEN man = -1 ELSEIF stot(8) THEN nlok = -1 setIO 1, 1 setIO 8, 0 LOCATE 23, 3: COLOR 4: PRINT "--------"; msg "ChildLock" ELSE k = j GOSUB resettemp1 END IF CLOSE #2: CLOSE #3 stot(1) = 0: stot(7) = 0: stot(8) = 0 GOTO endproces CASE 2 'bad GOSUB tijd ' bepaling van k bad = 20 FOR temp = j TO k PUT #3, temp + 1, badt bad = bad - 10 NEXT temp a$ = stat(i, 1) CASE 3 'VGS OPEN $txf + "1" + dagg$ FOR RANDOM AS #4 LEN = 2 GET #4, 1, z FOR temp = j TO 143 PUT #2, temp + 1, z NEXT temp IF stot(7) THEN z = 19 setIO 7, 0 stot(7) = 0 ELSE z = 20 END IF k = j + 2 FOR temp = j TO j + 3 PUT #3, temp, z NEXT temp z = 19 FOR temp = j + 4 TO j + 6 PUT #3, temp, z NEXT temp z = 18 FOR temp = j + 6 TO 143 PUT #3, temp + 1, z NEXT temp a$ = stat(i, 1) UPp = UPp + 20 CASE 4 'Living + 1 GOSUB tijd a$ = "1": zz = j1 GOSUB stt CASE 5 'Kamers + 1 GOSUB tijd a$ = "2": zz = k2 GOSUB stt CASE 6 'Stop GOSUB tijd z = 10 FOR temp = j + 1 TO k PUT #2, temp + 1, z PUT #3, temp + 1, z NEXT temp a$ = "Stop" END SELECT CLOSE #2: CLOSE #3 settijd i, k reloadtemp = -1 msg a$ + " " + ttm$(k + 1) END IF NEXT i IF stot(7) AND stot(8) THEN man = 1 setIO 7, 0: setIO 8, 0 END IF END IF ELSEIF se > 54 AND start = 55 THEN start = 0 PRINT "Einde tijdelijke status aangeven" j = ttx(oldtime$) FOR i = 1 TO 8 LOCATE 23, 7 + i * 7 IF tend(i) = j THEN IF i = 2 THEN bad = 0 END IF tend(i) = 0 stxt(i) = 0 stot(i) = 0 setIO i, 0 msg "" END IF NEXT i COLOR 7 END IF endproces: SETt 5, 0 i = 0 tk: a$ = inkk$ IF man < 0 THEN a$ = "1" ELSEIF man > 0 THEN a$ = "*" END IF IF a$ = "" THEN IF oldtime$ = TIME$ THEN SLEEP 1: INCR i GOTO tk END IF LOCATE 29, 75: PRINT FORMAT$(i, "000") GOTO terug END IF j = VAL(a$) PCOPY 0, 1 GOSUB cleam SELECT CASE a$ CASE "1" GOTO manu CASE "2" IF druke("Wissen tijdelijke waarden ? andaag of llemaal?", a$, "N") THEN GOTO eindeinlezen END IF IF a$ = "A" THEN FOR i = 1 TO 7 a$ = FORMAT$(i) GOSUB resettemp1o NEXT i END IF a$ = dagg$ GOSUB resettemp1o GOTO eindeinlezen CASE "4" sett 4, 0 zz = 12 terugtemp: LOCATE zz, 1 PRINT SPACE$(80) sett 5, 0 LOCATE zz, 1 a$ = inpx("Dag(en)", dagg$, 7) sett 5, -1 IF a$ = "*" THEN reloadtemp = -1 GOTO eindeinlezen END IF zone: LOCATE zz, 18 IF druke("Zone", b$, "") THEN GOTO terugtemp END IF sett 5, 0 z = VAL(b$) tempe: LOCATE zz, 25 b$ = inpx("Temperatuur", "", 3) IF b$ = "*" THEN GOTO zone END IF sett 5, -1 temp = VAL(b$) begint: LOCATE zz, 40 b$ = inpx("Begintijd hh:m", oldtime$, 4) IF b$ = "*" THEN GOTO tempe END IF sett 5, 0 rel = ttx(b$) eindt: LOCATE zz, 60 b$ = inpx("Eindtijd hh:m", "", 4) IF b$ = "*" THEN GOTO begint END IF sett 5, -1 k = ttx(b$) FOR i = 1 TO 7 b$ = FORMAT$(i) IF INSTR(a$, b$) THEN OPEN $tmf + "1" + b$ FOR RANDOM AS #2 LEN = 2 OPEN $tmf + "2" + b$ FOR RANDOM AS #3 LEN = 2 FOR j = rel TO k - 1 IF z <> 1 THEN PUT #3, j + 1, temp END IF IF z <> 2 THEN PUT #2, j + 1, temp END IF NEXT j CLOSE 2, 3 END IF NEXT i INCR zz GOTO terugtemp CASE "6" 'dis "Statistieken", "" shf = 1: sh "ktnew 3 " + dagg$ k = 1: GOTO shutrun CASE "7" ' restart k = 0: GOTO shutrun CASE "*" GOSUB clean SETt 0, 0 CLOSE GOSUB save i = SHELL("com5") EXIT FUNCTION CASE "." flg = -1 GOTO eindeinlezen END SELECT GOTO terug manu: cm = VAL(getini($ini, "cm")) GOSUB subman man = -1 SETt 0, 0 setini $stat, "man", STR$(cm) FOR i = 1 TO 8 setIO i, -outsw(i) NEXT i LOCATE 13, 1 j = 0: z = -1 bs = 0 LOCATE 13, 30: ppp "<*>- Hoofdmenu", 0, 1 ppp "<7>- CT Brander", 0, 0: LOCATE, 30: ppp "<9>- Waakvlam", 0, 1 ppp "<4>- Brander", 0, 0: LOCATE , 15: ppp "<5>- Klep bad", 0, 0: LOCATE , 30: ppp "<6>- Circ High", 0, 1 ppp "<1>- Living", 0, 0: LOCATE , 15: ppp "<2>- Kamer", 0, 0: LOCATE , 30: ppp "<3>- Circ Low", 0, 1 terugman: GOSUB intemp IF outsw(4) THEN IF j = 0 THEN j = 300 END IF ELSE j = 0 END IF a$ = RIGHT$(oldtime$, 2) IF a$ = "10" OR a$ = "40" THEN GOSUB inct IF a$ = "40" THEN start = 45 LOCATE 2, 1: z = -1: PRINT "Log aanvullen "; : GOSUB maaklog END IF ELSEIF a$ = "35" THEN start = 40 END IF inprocess: a$ = inkk$ IF a$ = "*" THEN GOTO exitman END IF k = -1 readIOchip 1 FOR i = 1 TO 8 IF iokk(i) THEN a$ = FORMAT$(i) k = 0 EXIT FOR END IF NEXT i IF fb THEN setusb 3, 0 fb = 0 END IF i = VAL(a$) IF (i = 4 OR a$ ="-") AND cm > 0 THEN DECR cm: GOSUB subman ELSEIF i = 8 OR a$ = "+" THEN IF cm > 0 THEN INCR cm: GOSUB subman ELSE GOTO exitman END IF ELSEIF i = 9 THEN fb = -1 setusb 3, 1 IF brst > 0 THEN brst = -1 ELSE brst = 11 END IF ELSEIF i = 7 THEN cm = -cm LOCATE 17, 1: PRINT SPACE$(35) IF cm >= 0 AND k THEN LOCATE 17, 1 a$ = inpx("Constante temperatuur ketel", STR$(cm), 3) IF a$ <> "*" THEN cm = VAL(a$) END IF END IF GOSUB subman ELSEIF i = 2 THEN setchannel 2, NOT outsw(2) setIO 2, outsw(2) * -1 ELSEIF i > 0 THEN m = IIF(i = 5 OR i = 6, i + 1, i) outsw(m) = NOT outsw(m) IF i = 5 THEN setchannel 6, outsw(6) ELSE sett m, outsw(m) END IF setIO i, outsw(m) * -1 IF i = 4 THEN j = 300 IF k THEN LOCATE 18, 1: PRINT SPACE$(11) END IF END IF END IF inkbt: i = 0 sett 5, 0 inktt: IF oldtime$ = TIME$ THEN SLEEP 1 INCR i GOTO inktt END IF LOCATE 29, 75: PRINT FORMAT$(i, "000") IF cm > 0 THEN IF cm + 1 < ttp(4, 5) AND outsw(4) THEN SETt 4, 0 setIO 4, 0 bs = MIN(bs, 0) ELSEIF cm - 1 > ttp(4, 5) AND NOT outsw(4) THEN SETt 4, -1 setIO 4, -1 bs = MAX(bs, 0) END IF bs = bs + IIF(outsw(4), 1, -1) LOCATE 30, 70: PRINT bs; bb = bs \ 30 PRINT bb; ELSE IF j AND brst > 0 THEN DECR j LOCATE 18, 1: PRINT "Timer:"; j IF j = 0 THEN SETt 4, 0 setIO 4, 0 GOTO terugman END IF END IF END IF GOTO terugman exitman: cm = -ABS(cm) setini $ini, "cm", STR$(cm) msg "": z = 0: man = 0: bb = 4 SETt 0, 0 FOR i = 1 TO 8 setIO i, 0 NEXT i setini $stat, "man", "0" GOTO eindeinlezen subman: msg IIF$(cm <= 0, "- Manual -", "Man" + STR$(cm)) setini $stat, "man", STR$(cm) RETURN bbr: PRINT "Branderstatus verwerken" bb = bb + IIF(brst > 0, 1, -1) COLOR 7 inct: LOCATE 20, 35 FOR i = 1 TO 3 IF outsw(i) AND (i <> 4 OR brst > 0) THEN INCR ct(i) END IF PRINT FORMAT$(ct(i)); NEXT i IF brst > 0 THEN INCR ct(4) END IF IF outsw(7) THEN ct(3) = ct(3) + 2 END IF COLOR 8: PRINT FORMAT$(ct(3)); : COLOR 7 FOR i = 1 TO 4 setini $stat, "t" + FORMAT$(i), "" + FORMAT$(ttp(i,4), "00.00 ")_ traag + "" + FORMAT$(ttp(i,3), "00.00 ")_ snel + "" + FORMAT$(ttp(i,5), "00.00 ")' evo NEXT i RETURN tijd: k = j IF stot(7) THEN k = k + 6 settijd 7, k END IF IF stot(8) THEN k = k + 12 settijd 8, k END IF IF k = j THEN k = 143 ELSEIF k > 143 THEN k = 143 END IF RETURN stt: tt = j a$ = LEFT$(stat(i, 1), 3) IF stot(6) THEN tt = j + 1: INCR k a$ = a$ + "-" ELSE a$ = a$ + "+" END IF FOR temp = tt TO k GET #i - 2, temp + 1, z IF z = 0 THEN z = zz END IF z = z + IIF(stot(6), -1, 1) PUT #i - 2, temp + 1, z NEXT temp stot(6) = 0 setIO 6, 0 CLOSE #4 RETURN shutrun: 'bewaren tabellen sett 4, 0 GOSUB save td(1) = td(1) - k IF td(1) > 0 THEN setini $ini, "td1", STR$(td(1)) END IF td(2) = td(2) - k IF td(2) > 0 THEN setini $ini, "td2", STR$(td(2)) END IF i = SHELL("krestart") closedevice EXIT FUNCTION save: FILECOPY $log, getini($ini, "log") FOR i = 1 TO 2 FOR j = 1 TO 7 FILECOPY "f:\tm" + FORMAT$(i) + FORMAT$(j), "tab\tm" + FORMAT$(i) + FORMAT$(j) NEXT j NEXT i FOR i = 1 TO 4 a$ = FORMAT$(i) setini $ini, "3" + a$, STR$(ttp(i, 3)) setini $ini, "4" + a$, STR$(ttp(i, 4)) NEXT i setini $ini, "bad", STR$(bad) setini $ini, "branderoffset", STR$(tcb) RETURN resettemp1o: OPEN $tmf + "1" + a$ FOR RANDOM AS #2 LEN = 2 OPEN $tmf + "2" + a$ FOR RANDOM AS #3 LEN = 2 resettemp1: z = 0 FOR temp = 1 TO 144 PUT #2, temp, z PUT #3, temp, z NEXT temp reloadtemp = -1 CLOSE #2: CLOSE #3 RETURN intemp: SETt 5, -1 oldtime$ = TIME$ IF outsw(4) AND restart < 5 THEN i = ionstatus SELECT CASE brst CASE 0 IF NOT i THEN setusb 1, 1 END IF brst = 1 CASE 1 TO 10 powergood = -1 INCR brst IF i THEN brst = 11 setusb 1, 0 ELSE IF brst = 10 THEN INCR restart brst = 13 END IF END IF CASE 11 IF i THEN brst = 12 setusb 2, 1 ELSE INCR restart brst = 13 END IF CASE 12 IF NOT i THEN setusb 2, 0 brst = 13 END IF CASE 13 IF NOT i THEN setusb 2, 0 brst = 14 setusb 1, 1 ELSE brst = 1 END IF CASE 14 IF NOT i THEN setusb 3, 1 brst = 15 ELSE brst = 1 END IF CASE 15 setusb 3, 0 IF NOT i THEN brst = 16 powergood = 0 ELSE brst = 1 END IF CASE 15 TO 130 INCR brst IF i THEN brst = 132 END IF CASE 131 setusb 1, 1 brst = 132 CASE 132 td(1) = 0: td(2) = 0 brst = 1 CASE -1 setusb 2, 0 brst = -2 CASE -10 TO -2 IF NOT ionstatus THEN DECR brst END IF CASE < -10 sett 4, 0 END SELECT END IF IF oldbrst <> brst THEN oldbrst = brst setini $stat, "Brander", STR$(brst) END IF COMM PRINT #5, CHR$(5) + "32" + oldtime$; LOCATE 1, 30: PRINT oldtime$ PRINT SPACE$(80) se = VAL(RIGHT$(TIME$, 2)) sss = se MOD 5 IF sss THEN readADchannel sss txp = ad%(sss) txp = (txp + ttp(sss, 1)) / ttp(sss, 2) IF ttp(sss, 3) = 0 THEN ttp(sss, 3) = txp ttp(sss, 4) = txp END IF IF sss = 4 THEN ' offset thermokoppel txp = txp + ttp(3, 4) ' slow kelder IF (ttp(4, 3) > txp AND ttp(4, 4) < ttp(4, 3)) OR (ttp(4, 3) < txp AND ttp(4, 4) > ttp(4, 3)) THEN ' (oude waarde > huidige EN traag < snel) OF (oude waarde < huidige EN traag > snel) ' (temperatuur daalt en traag loopt achter) OF (temperatuur stijgt en traag loopt achter) ttp(4, 4) = ttp(4, 3) ' aanpassing traag END IF END IF tca = ttp(sss, 6) ' fast ttp(sss, 3) = ttp(sss, 3) * (1 - tca) + txp * tca tca = ttp(sss, 7) ' slow ttp(sss, 4) = ttp(sss, 4) * (1 - tca) + txp * tca LOCATE 6 + sss, 11: PRINT CHR$(250) " "; COLOR 13: PRINT FORMAT$(ad%(sss), "* 0"); COLOR 7: LOCATE , 20: PRINT CHR$(250); COLOR 14: PRINT FORMAT$(ttp(sss, 3), "* .0"); COLOR 7: LOCATE , 28: PRINT CHR$(250) " "; ttp(sss, 5) = ttp(sss, 3) * 3 - ttp(sss, 4) * 2 IF flg THEN ' evolution COLOR 12: PRINT FORMAT$(ttp(sss, 4), "* .0"); ELSE COLOR 15: PRINT FORMAT$(ttp(sss, 5), "* .0"); END IF COMM PRINT #5, CHR$(2 + sss) + "00"; COMM PRINT #5, FORMAT$(ttp(sss, 3), "* .0"); COMM PRINT #5, FORMAT$(ttp(sss, 5), "* 0.0"); COMM PRINT #5, IIF$((sss = 2 AND outsw(6)) OR (sss = 3 AND outsw(7)), "*", " "); COMM PRINT #5, IIF$(outsw(sss), IIF$(sss = 4 AND brst < 0, ".", "*"), " "); COLOR 7 IF start = 40 THEN FOR i = 11 + sss * 2 TO 12 + sss * 2 FOR k = 40 TO 80 LOCATE i - 1, k PRINT CHR$(SCREEN(i, k)); NEXT k NEXT i END IF SELECT CASE sss CASE 1 now j1, tm1, tn1, z1, tc1 ' kleppen ... OK 'sp 7, "78 79*78 79" ' inlezen temperatuur van tabel ... OK LOCATE 7 FOR i = 1 TO 2 'sp 0, "38 46 48 56*" NEXT i 'set keteltemperatuur ... OK 'sp 10, "38 49 55 58 68" 'temperatuurcorrectie 'sp 7, "58 64*58,64" 'tijdelijke status 'LOCATE 23 'FOR i = 1 TO 8 ' LOCATE , 6 + i * 7: PRINT " "; 'NEXT i 'bad modus LOCATE 22, 24: PRINT " " LOCATE 5, 58: PRINT " " 'circu LOCATE 9, 79: PRINT " " 'branderoffset 'sp 5, "71 79" 'extra info 'sp 18, "30*30*30" CASE 2 now k2, tm2, tn2, z2, tc2 sp 7, "11 20 28" CASE 3 tc8 = (tc0 - ttp(3, 5)) / 10 'kelderoffset - COMM PRINT #5, "Cor" + FORMAT$(tc8, "* 0.0"); 'gemeten keldertemp COMM PRINT #5, mms$; sp 8, "11 20 28" CASE 4 COMM PRINT #5, FORMAT$(tcc, "* 0.0") + FORMAT$(tc6, "* 0.0"); COMM PRINT #5, IIF$(ABS(tc7) < 10, FORMAT$(tc7, "* .0"), FORMAT$(tc7, "* #0")); ' warmtevraag circulateur, warmtevraag brander, evo COMM PRINT #5, FORMAT$(tcb, "* 0.00"); COMM PRINT #5, FORMAT$(-bb, "* #0"); COMM PRINT #5, FORMAT$(tc3, "* 0.0"); sp 9, "11 20 28" IF ttp(4, 5) > 75 THEN SETt 4, 0 IF man = -1 THEN setIO 4, 0 END IF END IF IF man = 0 THEN LOCATE 10, 72 COLOR IIF(outsw(4), 2, 4) PRINT FORMAT$(bb, "* ##"); IF (ttp(4, 5) > tc3) OR (outsw(4) AND (td(1) < 4 AND td(2) < 4)) THEN COLOR 11: PRINT CHR$(250) IF tc3 > 30 THEN 'voldoende warmtevraag om waakvlam niet uit te schakelen IF outsw(4) THEN brst = -1 END IF ELSE SETt 4, 0 END IF bb = MIN(bb, 0) ELSEIF ttp(4, 5) < tc3 AND bb < -2 AND tc6 > 0 THEN COLOR 12: PRINT CHR$(250) ' tc6: totale warmtevraag brander IF td(1) > 3 OR td(2) > 3 THEN ' niet gecorrigeerd SETt 4, -1 bb = MAX(bb, 0) END IF ELSE COLOR 8: PRINT CHR$(250) END IF END IF END SELECT ELSE IF start MOD 10 THEN IF LEN(DIR$("update\*.*")) THEN k = 0 GOTO shutrun END IF END IF IF start = 40 THEN LOCATE 20, 40: PRINT SPACE$(40); END IF sp 10, "11 20 28" flg = IIF(flg < 0, 1, 0) readIOchip 0 ' powergood = io%(8) LOCATE 1, 70 IF powergood THEN COLOR 2: PRINT "Power GOOD" ELSE COLOR 28: PRINT "Power FAIL" BEEP td(1) = 0: td(2) = 0 END IF IF nlok = 0 AND man = 0 THEN readIOchip 1 FOR i = 8 TO 1 STEP -1 LOCATE 23, i + 2: COLOR 8 IF stxt(i) = 0 THEN IF iokk(i) THEN COLOR 11: PRINT "1"; stot(i) = NOT stot(i) setIO i, -stot(i) msg IIF$(stot(i), stat(i, 1), "") ELSE PRINT "0"; END IF ELSE PRINT "-"; ' inputs niet aanvaard END IF NEXT i ELSEIF nlok > 0 THEN nlok = -1 setIO 1, 1 setIO 8, 0 ELSEIF nlok < 0 THEN nlok = 1 setIO 1, 0 setIO 8, 1 END IF COLOR 7 END IF RETURN maaklog: PRINT "Log opmaken" LOCATE 20, 40: COLOR 7 OPEN $log FOR APPEND AS #1 PRINT #1, LEFT$(oldtime$, 5); ">"; FOR i = 1 TO 4 dualp ct(i) ct(i) = 0 NEXT i dualps "." dualp ABS(outsw(6)) dualp ABS(outsw(7)) dualp IIF(brst, 1, 0) dualps "-" FOR i = 1 TO 4 PRINT #1, FORMAT$(ttp(i, IIF(i = 3, 5, 4)), "* .00"); COLOR CHOOSE(i, 2, 3, 6, 4): PRINT FORMAT$(ttp(i, IIF(i = 3, 5, 4)), "* 0.00"); NEXT i COLOR 7: PRINT #1, "*"; FOR i = 1 TO 8 dualps FORMAT$(ABS(stxt(i))) NEXT i PRINT #1, CHR$(183) IIF$(man = 0 AND tcbok <> 0, FORMAT$(tcb, "00.00"), "--.--"); PRINT #1, IIF$(z, ":MA:", ":--:") IIF$(powergood, "--", "PF") CLOSE #1 RETURN clean: LOCATE 13, 1: PRINT SPACE$(640): LOCATE 13, 1 GOTO cleaz RETURN cleam: LOCATE 12, 1 FOR i = 12 TO 20 PRINT SPACE$(39) NEXT i cleaz: LOCATE 25, 1: PRINT SPACE$(79); LOCATE 13, 1 RETURN END FUNCTION STATIC SUB sh (a$) 'IF shf THEN ' PRINT #5, LEFT$(a$, 40); CHR$(10); ' PRINT #5, MID$(a$, 41, 20); ' shf = 0 'END IF syslog("Run: " + a$) COLOR 4: PRINT a$: COLOR 7: SHELL a$ b$ =getini($ini, "error") IF LEN(b$) THEN syslog("Error: " + b$) END IF END SUB STATIC SUB syslog(a$) lf = FREEFILE OPEN "log\sys.log" FOR APPEND AS #lf PRINT #lf, datum$(""); CHR$(183); TIME$; ">"; a$ CLOSE lf END SUB FUNCTION dat() AS STRING dat = MID$(DATE$, 4, 2) + LEFT$(DATE$, 2) + RIGHT$(DATE$, 2) END FUNCTION FUNCTION datum (a$) AS STRING datum$ = IIF$(LTRIM$(RTRIM$(a$)) = "",_ MID$(DATE$, 4, 3) + MID$($ddd, (VAL(LEFT$(DATE$, 2)) - 1) * 3 + 1, 3) + "-" + RIGHT$(DATE$, 2),_ IIF$(VAL(MID$(a$, 3, 2)),_ LEFT$(a$, 2) + "-" + MID$($ddd, (VAL(MID$(a$, 3, 2)) - 1) * 3 + 1, 3) + "-" + RIGHT$(a$, 2),_ " - - ")) END FUNCTION SUB dualps(a$) PRINT #1, a$; PRINT a$; END SUB SUB dualp(i) dualps FORMAT$(i) END SUB STATIC SUB setIO (i, j) COLOR 13: LOCATE 23, 7 + i * 7: PRINT CHR$(16); SPACE$(6); LOCATE , 7 + i * 7 SELECT CASE j CASE 0 OutputDACchannel i, 30: COLOR 8 CASE -1 OutputDACchannel i, 0: COLOR 10 CASE 1 OutputDACchannel i, 63: COLOR 12 END SELECT PRINT IIF$(man = 0, stat(i, 1), stat(i, 2)); COLOR 7 END SUB STATIC SUB msg (a$) mms$ = a$ 'mms$ = string*10 COMM PRINT #5, CHR$(5) + "21"; COMM PRINT #5, SPACE$(10); LOCATE 22, 56: PRINT SPACE$(10); IF a$ <> "" THEN COMM PRINT #5, CHR$(5) + "21"; COMM PRINT #5, mms$; LOCATE 22, 56: PRINT a$; END IF END SUB STATIC SUB showttab (a$, j1, tm1, tn1, z1) i = ttx(TIME$) + 1 OPEN $txf + a$ + dagg FOR RANDOM AS #2 LEN = 2 GET #2, i, j1 OPEN $tmf + a$ + dagg FOR RANDOM AS #3 LEN = 2 GET #3, i, tm1 IF tm1 = 0 THEN tm1 = j1 END IF IF i < 144 THEN GET #2, i + 1, tn1 GET #3, i + 1, z1 ELSE tn1 = tm1 END IF CLOSE #2: CLOSE #3 ' COLOR 14: LOCATE , 38: PRINT CHR$(16); : COLOR 7 LOCATE , 39: ncol j1 PRINT " " CHR$(26) " ";: ncol tn1 ' COLOR 14: PRINT CHR$(17); ' LOCATE , 48: PRINT CHR$(16); : COLOR 7 LOCATE, 49: ncol tm1 PRINT " " CHR$(26) " "; i = z1 IF i = 0 THEN i = tn1 END IF COLOR 7: ncol i PRINT 'COLOR 14: PRINT CHR$(17): COLOR 7 'locate 28,1 : print "-" dagg "-" END SUB SUB setchannel(i, j) setIOchannel i, j outsw(i) = j IF i <> 5 THEN setini $stat, statu$(i), STR$(j) END IF END SUB SUB SETt (k, ii) 'k:channel i:status k=0: alle statussen op nul i = powergood AND ii bbx = bad < 0 OR bx < 0 'bad-funktie of neg.temp IF k THEN IF k = 2 AND i THEN setchannel IIF(bbx, 6, 2), -1 ' kamer of bad minstens aan IF NOT fb THEN ' teller bad (-5/5) setchannel IIF(bbx, 2, 6), 0 ELSE setchannel IIF(bbx, 2, 6), -1 END IF LOCATE 8, 71 COLOR IIF(outsw(2), 12, 2): PRINT "Kam "; COLOR IIF(outsw(6), 12, 2): PRINT "Bad" ELSEIF k = 1 THEN LOCATE 7, 71 j = IIF(fb AND td(2) > 7 AND ttp(1, 5) > tc1 - .3, 0, i) GOSUB CSETt PRINT "Klep Lv" ELSEIF k = 2 THEN setchannel 2, 0: setchannel 6, 0 LOCATE 8, 71: COLOR 2: PRINT "Kam Bad" ELSEIF k = 3 THEN LOCATE 9, 74 j = i: GOSUB CSETt PRINT "cu" ELSEIF k = 4 THEN brst = 0 IF ii THEN restart = 0 ELSE LOCATE 30,1: PRINT SPACE$(70); setusb 1, 0: setusb 2, 0 END IF LOCATE 10, 71 j = ii: GOSUB CSETt PRINT "B" CHR$(15) ELSEIF k = 5 THEN LOCATE 23, 71 j = i: GOSUB CSETt PRINT "Watchdog" ELSEIF k = 7 THEN LOCATE 9, 71 j = i: GOSUB CSETt PRINT "Cir" END IF COLOR 7 ELSE FOR j = 1 TO 7 SETt j, 0 NEXT j END IF EXIT SUB CSETt: setchannel k, j COLOR IIF(j, 12, 2) RETURN END SUB FUNCTION ionstatus ion = (ion + readanalog(2)) / 2 SLEEP 1 j = readanalog(1) ionstatus = ion > j LOCATE 30, 1: PRINT j " Ionisatieniveau:" ion " Branderstatus:" brst; END FUNCTION STATIC FUNCTION klo(i) AS WORD klo = td(1) > i OR td(2) > i END FUNCTION STATIC SUB tempcorr (tc AS SINGLE, tm, i, tcx AS SINGLE, tcy AS SINGLE) tc = tm + tc8 'correctie setwaarde temperatuur tc = MAX(tc, 0) 'bepalen adhvd keldertemperatuur ' LOCATE , 58: COLOR 14: PRINT CHR$(16); LOCATE, 59: PRINT FORMAT$(tc, "* 0.0") 'COLOR 14: PRINT CHR$(17): COLOR 7 tcx = MAX(ttp(i, 3), ttp(i, 5)) 'bepalen van de hoogste temperatuur per 'ruimte (huidig of prediktie) 'tcx(warmtevraag per ruimte voor brander)= 'gecorrigeerde setwaarde - tcx = tc - tcx 'hoogste gemeten temperatuur tcy = tc - ttp(i, 5) 'tcy(warmtevraag per ruimte voor END SUB 'circulateur) STATIC FUNCTION vraag! (i AS SINGLE, j AS SINGLE) vraag = IIF(i > 0 AND j > 0, i + j, MAX(i, j)) ' warmtevraag = grootste ' vraag of som van beide END FUNCTION ' indien beide positief STATIC SUB frm (tc3 AS SINGLE, i) PRINT FORMAT$(tc3, IIF$(ABS(tc3) >= 10, STRING$(i, "#"), STRING$(i - 2, "#") + ".#")); END SUB STATIC SUB klep (i, tc4 AS SINGLE) DIM tc AS SINGLE PRINT "Kleppen "; PRINT IIF$(i = 1, "living", "kamers"); ' LOCATE 6 + i, 79: COLOR 14: PRINT CHR$(17); tc = IIF(td(i) > 7, .05, .15) k = ttp(i, 5) < tc4 + tc 'klep open vanaf SETt i, k 'gemeten temp < gewenst +0.1 td(i) = IIF(k, MIN(td(i) + 1, 9), MAX(td(i) -2, 0)) COLOR 9: LOCATE 9, 76 PRINT IIF$(td(1), FORMAT$(td(1)), " "); PRINT IIF$(td(2), FORMAT$(td(2)), " "); END SUB STATIC SUB settijd (u, k) stxt(u) = -1 stot(u) = 0 setIO u, -1 tend(u) = k + 1 END SUB STATIC FUNCTION ttm$ (i) ' conversion timeindex to hh:m0 ttm$ = RIGHT$("0" + FORMAT$(INT(i / 6)), 2) + ":" + FORMAT$(i MOD 6) + "0" END FUNCTION STATIC FUNCTION inkk$ a$ = INKEY$ IF LEN(a$) > 1 THEN ink = ASC(RIGHT$(a$, 1)) - 58 a$ = "" END IF inkk$ = a$ END FUNCTION STATIC FUNCTION iokk% (i%) iokk% = io%(i + 8) OR ink = i IF ink = i THEN ink = 0 END IF END FUNCTION STATIC SUB now (j1, tm1, tn1, z1, tc AS SINGLE) STATIC COMM PRINT #5, "Now " + FORMAT$(j1, "* "); COMM PRINT #5, IIF$(tm1 = j1, " ", FORMAT$(tm1, "* 0")); COMM PRINT #5, " Nxt " + FORMAT$(tn1, "* "); COMM PRINT #5, IIF$(z1, " ", FORMAT$(z1, "* #")); COMM PRINT #5, " Set " + FORMAT$(tc, "* 0.0"); END SUB SUB sp (ll, a$) STATIC IF ll THEN LOCATE ll END IF j = LEN(a$) - 1 FOR i = 1 TO j STEP 3 LOCATE , VAL(MID$(a$, i, 3)): PRINT " "; IF MID$(a$, i + 2, 1) = "*" THEN PRINT END IF NEXT i END SUB STATIC SUB ncol (i%) IF i < 0 THEN COLOR 7, 1 END IF PRINT FORMAT$(ABS(i), "00"); COLOR 7, 0 END SUB