konijn
Junior Member
Posts: 96
|
Post by konijn on Jun 20, 2020 13:58:05 GMT -5
datum$ =date$("mm/dd/yyyy") dt$=word$(datum$,2,"/")+"-"+word$(datum$,1,"/")+"-"+word$(datum$,3,"/") tijdopstart = TIME$("seconds") + 20 run "c:\melkteller\herkenning\inlees.bat" [start] if TIME$("seconds")< tijdopstart then goto [start] 'open "com4:9600,n,8,1," for input as #com OPEN "c:\melkteller\links.txt" FOR OUTPUT AS #1 OPEN "c:\melkteller\rechts.txt" FOR OUTPUT AS #2 'OPEN "c:\melkteller\log.txt" FOR OUTPUT AS #log close #1 close #2 open "WS2_32" for DLL as #winsock run "c:\melkteller\unidata.exe"
dim a$(3000), b$(3000), c$(3000), d$(3000), e$(3000), f$(3000), g$(3000) ' 15 fields dim h$(3000), i$(3000), j$(3000), k$(3000), l$(3000), m$(3000), n$(3000), o$(3000)
dim voera$(3000), voerb$(3000), voerc$(3000), voerd$(3000), voere$(3000), voerf$(3000), voerh$(3000), voerg$(3000), voers$(3000), voert$(3000) dim voeri$(3000), voerj$(3000), voerk$(3000), voerl$(3000), voerm$(3000), voern$(3000), voero$(3000), voerp$(3000), voerq$(3000), voerr$(3000) ' 20 fields
dim tochta$(3000), tochtb$(3000), tochtc$(3000), tochtd$(3000), tochte$(3000), tochtf$(3000), tochtg$(3000)
i =0 open "c:\melkteller\herkenning\inlees.csv" for input as #readFile while not( eof( #readFile)) inputcsv #readFile, a$(i), b$(i), c$(i), d$(i), e$(i), f$(i), g$(i), h$(i), i$(i), j$(i), k$(i), l$(i), m$(i), n$(i), o$(i) 'print a$(j), b$(j), c$(j), d$(j), e$(j), f$(j), g$(j), h$(j), i$(j), k$(j), l$(j), m$(j), n$(j) i =i +1 wend close #readFile
[voerinlees] i =0 open "c:\melkteller\herkenning\voer1.csv" for input as #voer while not( eof( #voer)) inputcsv #voer, voera$(i), voerb$(i), voerc$(i), voerd$(i), voere$(i), voerf$(i), voerg$(i), voerh$(i), voeri$(i), voerj$(i), voerk$(i), voerl$(i), voerm$(i), voern$(i), voero$(i), voerp$(i), voerq$(i), voerr$(i), voers$(i), voert$(i) 'print voera$(i), voerb$(i), voerc$(i), voerd$(i), voere$(i), voerf$(i), voerg$(i), voerh$(i), voeri$(i), voerj$(i), voerk$(i), voerl$(i), voerm$(i), voern$(i), voero$(i), voerp$(i), voerq$(i), voerr$(i), voers$(i), voert$(i) i =i +1 wend close #voer
i =0 open "c:\melkteller\herkenning\tocht.csv" for input as #tocht while not( eof( #tocht)) inputcsv #tocht, tochta$(i), tochtb$(i), tochtc$(i), tochtd$(i), tochte$(i), tochtf$(i), tochtg$(i) print tochta$(i), tochtb$(i), tochtc$(i), tochtd$(i), tochte$(i), tochtf$(i), tochtg$(i) i =i +1 wend close #tocht
gosub [structInit]
Call OpenWinsock port = 26080 sock = OpenUDPServSocket(port) tijdlinks = 999999 tijdrechts = 999999
[begin] while info$ <> "end"
sckadrSize = len(sockaddr.struct) sckadr$ = space$(sckadrSize) recv = recvfrom(sock, buf$, 1024, 0, sckadr$, sckadrSize) If recv < 0 then print "recv error: ";WSAGetLastError() a = closesocket(sock) a = WSACleanup() call CloseWinsock end end if print recv info$ = left$(buf$, recv)
antenne$=word$(info$,4,"#") antenne=val(antenne$) zender$=word$(info$,7,"#") koehand$=word$(info$,1,"#") if koehand$ = "koe" then goto [handmatig] if koehand$ = "einde" then goto [inlees] if koehand$ = "start" then goto [startmeter] if koehand$ = "stop" then goto [stopmeter] print info$ print antenne antenne$ = TRIM$(antenne$) print zender$ 'print #log, zender$+","+antenne$+","+time$() zender$ = TRIM$(zender$)
j =0 while zender$ <> b$( j) and j <3000 j =j +1 wend
if j =3000 then goto [begin] tijd = time$("seconds") if tijd > tijdlinks goto [opslaanlinks] if tijd > tijdrechts goto [opslaanrechts]
[antenne]
if antenne + corr1 = 1 goto [LV1]
if antenne + corr2 = 2 goto [LV2]
if antenne + corr3 = 3 goto [LV3]
if antenne + corr4 = 4 goto [LV4]
if antenne + corr5 = 5 goto [LV5]
if antenne + corr6 = 6 goto [LV6]
if antenne + corr7 = 7 goto [LV7]
if antenne + corr8 = 8 goto [LV8]
if antenne + corr9 = 9 goto [RV1]
if antenne + corr10 = 10 goto [RV2]
if antenne + corr11 = 11 goto [RV3]
if antenne + corr12 = 12 goto [RV4]
if antenne + corr13 = 13 goto [RV5]
if antenne + corr14 = 14 goto [RV6]
if antenne + corr15 = 15 goto [RV7]
if antenne + corr16 = 16 goto [RV8]
' if info$ = "stop" then ' goto [END] ' end if 'sendBuf$ = "testReturn" 'ret = sendto(sock, sendBuf$, len(sendBuf$), sckadr$) 'if ret = -1 then ' print "Send error - ";WSAGetLastError() 'end if wend
a = closesocket(sock) call CloseWinsock
'[END] 'print "bye bye!!"
close #ws2 '[quit]
[handmatig] print "in handmatig" koehandnr$=word$(info$,2,"#") j =0 while koehandnr$ <> a$( j) and j <3000 j =j +1 wend zender$ = b$( j) print "hand"+ koehandnr$ print zender$ antenne$=word$(info$,3,"#") antenne=val(antenne$) print antenne
if antenne = 2 and zender$ = result1$ then print "correct" corr1 = 1 corr2 = 1 corr3 = 1 corr4 = 1 corr5 = 1 corr6 = 1 corr7 = 1 corr8 = 1 antenne = antenne-1 tijdcorrectie = TIME$("seconds") + 360 result1$ ="" result2$ ="" result3$ ="" result4$ ="" result5$ ="" result6$ ="" result7$ ="" result8$ ="" ok=UDPsend("10.0.0.201", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.202", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 3 and zender$ = result2$ then corr1 = 0 corr2 = 1 corr3 = 1 corr4 = 1 corr5 = 1 corr6 = 1 corr7 = 1 corr8 = 1 antenne = antenne-1 tijdcorrectie = TIME$("seconds") + 360 result2$ ="" result3$ ="" result4$ ="" result5$ ="" result6$ ="" result7$ ="" result8$ ="" ok=UDPsend("10.0.0.202", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 4 and zender$ = result3$ then corr1 = 0 corr2 = 0 corr3 = 1 corr4 = 1 corr5 = 1 corr6 = 1 corr7 = 1 corr8 = 1 antenne = antenne-1 tijdcorrectie = TIME$("seconds") + 360 result3$ ="" result4$ ="" result5$ ="" result6$ ="" result7$ ="" result8$ ="" ok=UDPsend("10.0.0.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 5 and zender$ = result4$ then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 1 corr5 = 1 corr6 = 1 corr7 = 1 corr8 = 1 antenne = antenne-1 tijdcorrectie = TIME$("seconds") + 360 result4$ ="" result5$ ="" result6$ ="" result7$ ="" result8$ ="" ok=UDPsend("10.0.0.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 6 and zender$ = result5$ then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 1 corr6 = 1 corr7 = 1 corr8 = 1 antenne = antenne-1 tijdcorrectie = TIME$("seconds") + 360 result5$ ="" result6$ ="" result7$ ="" result8$ ="" ok=UDPsend("10.0.0.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 7 and zender$ = result6$ then print "correctie 7" corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 1 corr7 = 1 corr8 = 1 antenne = antenne-1 tijdcorrectie = TIME$("seconds") + 360 result6$ ="" result7$ ="" result8$ ="" ok=UDPsend("10.0.0.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 8 and zender$ = result7$ then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 1 corr8 = 1 antenne = antenne-1 tijdcorrectie = TIME$("seconds") + 360 result7$ ="" result8$ ="" ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if print "nu naar antenne" goto [antenne]
[startmeter] ip$=word$(info$,2,"#") if ip$ = "10.0.0.201" then starttijd1 = time$("seconds") begintijd1$ = time$() goto [begin]
[stopmeter] ip$=word$(info$,2,"#") if ip$ = "10.0.0.201" then stoptijd1 = time$("seconds") melkduur = (stoptijd1-starttijd1) melkgift1$ = word$(info$,4,"#") 'if (val(melkgift1$ < 0.5 goto [begin]) gem1 = (val(melkgift1$)/(melkduur/60)) koeserver$ = word$(info$,3,"#") koeserver$ = (trim$(koeserver$)) OPEN "c:\melkteller\server.txt" FOR append AS #ser print #ser, koeserver$; " "; dt$; " "; begintijd1$; " "; melkgift1$; " "; melkduur; " "; using( "##.#", gem1) close #ser goto [begin]
[LV1] if zender$ = result1$ goto [begin] if tijd > resettijdlinks then gosub [resetlinks] result1$=zender$ result1$ = TRIM$(result1$) print result1$ transponder$ = result1$ ipnr$ = "10.0.0.201" plaats$ = "LV1" tijdlinks = time$("seconds")+ 360 resettijdlinks = time$("seconds")+ 360 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[LV2] if zender$ = result2$ goto [begin] if tijd > resettijdlinks then gosub [resetlinks] result2$=zender$ result2$ = TRIM$(result2$) print result2$ transponder$ = result2$ ipnr$ = "10.0.0.202" plaats$ = "LV2" tijdlinks = time$("seconds")+ 360 resettijdlinks = time$("seconds")+ 360 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[LV3] if zender$ = result3$ goto [begin] if tijd > resettijdlinks then gosub [resetlinks] result3$=zender$ result3$ = TRIM$(result3$) print result3$ transponder$ = result3$ ipnr$ = "10.0.0.203" plaats$ = "LV3" resettijdlinks = time$("seconds")+ 360 'tijdlinks = time$("seconds")+ 300 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[LV4] if zender$ = result4$ goto [begin] result4$=zender$ result4$ = TRIM$(result4$) print result4$ transponder$ = result4$ ipnr$ = "10.0.0.204" plaats$ = "LV4" ' tijdlinks = time$("seconds")+ 300 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[LV5] if zender$ = result5$ goto [begin] result5$=zender$ result5$ = TRIM$(result5$) print result5$ transponder$ = result5$ ipnr$ = "10.0.0.205" plaats$ = "LV5" ' tijdlinks = time$("seconds")+ 300 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[LV6] if zender$ = result6$ goto [begin] result6$=zender$ result6$ = TRIM$(result6$) print result6$ transponder$ = result6$ ipnr$ = "10.0.0.206" plaats$ = "LV6" ' tijdlinks = time$("seconds")+ 300 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[LV7] if zender$ = result7$ goto [begin] result7$=zender$ result7$ = TRIM$(result7$) print result7$ transponder$ = result7$ ipnr$ = "10.0.0.207" plaats$ = "LV7" ' tijdlinks = time$("seconds")+ 300 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[LV8] if zender$ = result8$ goto [begin] result8$=zender$ result8$ = TRIM$(result8$) print result8$ transponder$ = result8$ ipnr$ = "10.0.0.208" plaats$ = "LV8" ' tijdlinks = time$("seconds")+ 300 if tijd > tijdcorrectie then corr1 = 0 corr2 = 0 corr3 = 0 corr4 = 0 corr5 = 0 corr6 = 0 corr7 = 0 corr8 = 0 end if goto [verstuur]
[opslaanlinks]
OPEN "c:\melkteller\links.txt" FOR append AS #8 if opslaanL1$ = opgeslagenL1$ then opslaanL1$ = "0" if opslaanL2$ = opgeslagenL2$ then opslaanL2$ = "0" if opslaanL3$ = opgeslagenL3$ then opslaanL3$ = "0" if opslaanL4$ = opgeslagenL4$ then opslaanL4$ = "0" if opslaanL5$ = opgeslagenL5$ then opslaanL5$ = "0" if opslaanL6$ = opgeslagenL6$ then opslaanL6$ = "0" if opslaanL7$ = opgeslagenL7$ then opslaanL7$ = "0" if opslaanL8$ = opgeslagenL8$ then opslaanL8$ = "0" print #8, opslaanL1$ print #8, opslaanL2$ print #8, opslaanL3$ print #8, opslaanL4$ print #8, opslaanL5$ print #8, opslaanL6$ print #8, opslaanL7$ print #8, opslaanL8$ close #8 opgeslagenL1$=opslaanL1$ opgeslagenL2$=opslaanL2$ opgeslagenL3$=opslaanL3$ opgeslagenL4$=opslaanL4$ opgeslagenL5$=opslaanL5$ opgeslagenL6$=opslaanL6$ opgeslagenL7$=opslaanL7$ opgeslagenL8$=opslaanL8$
plaats$="" tijdlinks = time$("seconds")+ 7200 goto [begin]
[RV1] if zender$ = resultR1$ goto [begin]
resultR1$=zender$ resultR1$ = TRIM$(resultR1$) print resultR1$ transponder$ = resultR1$ ipnr$ = "10.0.0.209" plaats$ = "RV1" tijdrechts = time$("seconds")+ 360 goto [verstuur]
[RV2] if zender$ = resultR2$ goto [begin]
resultR2$=zender$ resultR2$ = TRIM$(resultR2$) print resultR2$ transponder$ = resultR2$ ipnr$ = "10.0.0.210" plaats$ = "RV2" tijdrechts = time$("seconds")+ 360 goto [verstuur]
[RV3] if zender$ = resultR3$ goto [begin] resultR3$=zender$ resultR3$ = TRIM$(resultR3$) print resultR3$ transponder$ = resultR3$ ipnr$ = "10.0.0.211" plaats$ = "RV3" ' tijdrechts = time$("seconds")+ 300 goto [verstuur]
[RV4] if zender$ = resultR4$ goto [begin] resultR4$=zender$ resultR4$ = TRIM$(resultR4$) print resultR4$ transponder$ = resultR4$ ipnr$ = "10.0.0.212" plaats$ = "RV4" ' tijdrechts = time$("seconds")+ 300 goto [verstuur]
[RV5] if zender$ = resultR5$ goto [begin] resultR5$=zender$ resultR5$ = TRIM$(resultR5$) print resultR5$ transponder$ = resultR5$ ipnr$ = "10.0.0.213" plaats$ = "RV5" ' tijdrechts = time$("seconds")+ 300 goto [verstuur]
[RV6] if zender$ = resultR6$ goto [begin] resultR6$=zender$ resultR6$ = TRIM$(resultR6$) print resultR6$ transponder$ = resultR6$ ipnr$ = "10.0.0.214" plaats$ = "RV6" ' tijdrechts = time$("seconds")+ 300 goto [verstuur]
[RV7] if zender$ = resultR7$ goto [begin] resultR7$=zender$ resultR7$ = TRIM$(resultR7$) print resultR7$ transponder$ = resultR7$ ipnr$ = "10.0.0.215" plaats$ = "RV7" ' tijdrechts = time$("seconds")+ 300 goto [verstuur]
[RV8] if zender$ = resultR8$ goto [begin] resultR8$=zender$ resultR8$ = TRIM$(resultR8$) print resultR8$ transponder$ = resultR8$ ipnr$ = "10.0.0.216" plaats$ = "RV8" ' tijdrechts = time$("seconds")+ 300 goto [verstuur]
[opslaanrechts]
OPEN "c:\melkteller\rechts.txt" FOR append AS #9 if opslaanR1$ = opgeslagenR1$ then opslaanR1$ = "0" if opslaanR2$ = opgeslagenR2$ then opslaanR2$ = "0" if opslaanR3$ = opgeslagenR3$ then opslaanR3$ = "0" if opslaanR4$ = opgeslagenR4$ then opslaanR4$ = "0" if opslaanR5$ = opgeslagenR5$ then opslaanR5$ = "0" if opslaanR6$ = opgeslagenR6$ then opslaanR6$ = "0" if opslaanR7$ = opgeslagenR7$ then opslaanR7$ = "0" if opslaanR8$ = opgeslagenR8$ then opslaanR8$ = "0" print #9, opslaanR1$ print #9, opslaanR2$ print #9, opslaanR3$ print #9, opslaanR4$ print #9, opslaanR5$ print #9, opslaanR6$ print #9, opslaanR7$ print #9, opslaanR8$ close #9 opgeslagenR1$=opslaanR1$ opgeslagenR2$=opslaanR2$ opgeslagenR3$=opslaanR3$ opgeslagenR4$=opslaanR4$ opgeslagenR5$=opslaanR5$ opgeslagenR6$=opslaanR6$ opgeslagenR7$=opslaanR7$ opgeslagenR8$=opslaanR8$ plaats$="" tijdrechts = time$("seconds")+ 7200 goto [begin]
[verstuur]
Print "we zijn in verstuur" print transponder$ PRINT ipnr$
i =0 while transponder$ <> voerb$( i) and i <3000 i =i +1 wend if i <3000 then print "Found in voerb$"
j =0 while transponder$ <> b$( j) and j <3000 j =j +1 wend if j <3000 then print "Found in b$()"
k =0 while transponder$ <> tochtb$( k) and k <3000 k =k +1 wend
if k$(j) = "Geinsemineerd" then k$(j) = "Geins" if k$(j) = "Bewust gust" then k$(j) = "Bew.gust" if i =3000 or j =3000 then print ok=UDPsend(ipnr$, 12080, ";"+transponder$+";;;;;;;;;;;;;;;;;;;;;") : goto [begin]
if val( voere$(i)) <>0 then percentage =100 *(val( voere$(i)) -val( voerd$(i)) ) /val( voere$(i))
print percentage; " shown as a raw decimal number." print using( "###", percentage); "% with decimal parts suppressed."
opname = (val( voere$( i)) -val( voerd$( i))) if k$(j) = "Geinsemineerd" then k$(j) = "Geins" if k$(j) = "Bewust gust" then k$(j) = "Bew.gust" percentage$ = Using("###", percentage)
m = 0 for m = 1 to 1 ok=UDPsend(ipnr$, 12080, ";"+a$(j)+" "+tochtf$(k)+";Vader: ;"+m$(j)+";Klfdt: ;"+l$(j)+"("+h$(j)+")("+d$(j)+");"+tochte$(k)+"% "+tochtc$(k)+" uur"+" "+tochtf$(k)+" "+tochtd$(k)+";;Status:;"+k$(j)+" ("+i$(j)+")("+j$(j)+");Voer; "+voere$(i)+"/"+str$(opname)+" "+percentage$+"%;Mlk305:;"+n$(j)+" (LW"+o$(j)+");V/E: ;"+f$(j)+" "+g$(j)+";Cel: ;"+e$(j)+";;;Apart:;"+c$(j)+";;;;;") print ipnr$,";"+a$(j)+" "+tochtf$(k)+";Vader: ;"+m$(j)+";Klfdt: ;"+l$(j)+"("+h$(j)+")("+d$(j)+");;;Status:;"+k$(j)+" ("+i$(j)+")("+j$(j)+");Voer; "+voere$(i)+"/"+str$(opname)+" "+percentage$+"%;Mlk305:;"+n$(j)+" (LW"+o$(j)+");V/E: ;"+f$(j)+" "+g$(j)+";Cel: ;"+e$(j)+";;;Apart:;"+c$(j)+";;;;;" next m else if k$(j) = "Geinsemineerd" then k$(j) = "Geins" if k$(j) = "Bewust gust" then k$(j) = "Bew.gust" m = 0 for m = 1 to 1 ok=UDPsend(ipnr$, 12080, ";"+a$(j)+" "+tochtf$(k)+";Vader: ;"+m$(j)+";Klfdt: ;"+l$(j)+"("+h$(j)+")("+d$(j)+");"+tochte$(k)+"% "+tochtc$(k)+" uur"+" "+tochtf$(k)+" "+tochtd$(k)+";;Status:;"+k$(j)+" ("+i$(j)+")("+j$(j)+");Voer; geen;Mlk305:;"+n$(j)+" (LW"+o$(j)+");V/E: ;"+f$(j)+" "+g$(j)+";Cel: ;"+e$(j)+";;;Apart:;"+c$(j)+";;;;;") print "Invalid operation- voerd$ =0" print ipnr$,";"+a$(j)+" "+tochtf$(k)+";Vader: ;"+m$(j)+";Klfdt: ;"+l$(j)+"("+h$(j)+")("+d$(j)+");;;Status:;"+k$(j)+" ("+i$(j)+")("+j$(j)+");Voer; geen;Mlk305:;"+n$(j)+" (LW"+o$(j)+");V/E: ;"+f$(j)+" "+g$(j)+";Cel: ;"+e$(j)+";;;Apart:;"+c$(j)+";;;;;" next m end if
print a$( j), voera$( i), m$( j), voerb$( i)
print koenr$; " was found in line "; i; " of voerab$ array" print " and in line "; j; " of b$ array." print "Done"
[terug]
if plaats$ = "LV1" then opslaanL1$ = a$(j) if plaats$ = "LV1" goto [begin] if plaats$ = "LV2" then opslaanL2$ = a$(j) if plaats$ = "LV2" goto [begin] if plaats$ = "LV3" then opslaanL3$ = a$(j) if plaats$ = "LV3" goto [begin] if plaats$ = "LV4" then opslaanL4$ = a$(j) if plaats$ = "LV4" goto [begin] if plaats$ = "LV5" then opslaanL5$ = a$(j) if plaats$ = "LV5" goto [begin] if plaats$ = "LV6" then opslaanL6$ = a$(j) if plaats$ = "LV6" goto [begin] if plaats$ = "LV7" then opslaanL7$ = a$(j) if plaats$ = "LV7" goto [begin] if plaats$ = "LV8" then opslaanL8$ = a$(j) if plaats$ = "LV8" goto [begin] if plaats$ = "RV1" then opslaanR1$ = a$(j) if plaats$ = "RV1" goto [begin] if plaats$ = "RV2" then opslaanR2$ = a$(j) if plaats$ = "RV2" goto [begin] if plaats$ = "RV3" then opslaanR3$ = a$(j) if plaats$ = "RV3" goto [begin] if plaats$ = "RV4" then opslaanR4$ = a$(j) if plaats$ = "RV4" goto [begin] if plaats$ = "RV5" then opslaanR5$ = a$(j) if plaats$ = "RV5" goto [begin] if plaats$ = "RV6" then opslaanR6$ = a$(j) if plaats$ = "RV6" goto [begin] if plaats$ = "RV7" then opslaanR7$ = a$(j) if plaats$ = "RV7" goto [begin] if plaats$ = "RV8" then opslaanR8$ = a$(j) if plaats$ = "RV8" goto [begin]
[resetlinks]
ok=UDPsend("10.0.0.201", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.202", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;")
return
[resetrechts]
ok=UDPsend("10.0.0.209", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.210", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.211", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.212", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.213", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("10.0.0.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;")
return
'[end] 'close #winsock
end
[inlees] CallDLL #ws2, "closesocket",_ sock as ulong,_ closesocket as long close #ws2 close #winsock 'close #log open "c:\melkteller\links.txt" for input as #original open "c:\melkteller\log\links.txt" for append as #copy print #copy, input$(#original, lof(#original)); close #original close #copy open "c:\melkteller\rechts.txt" for input as #original1 open "c:\melkteller\log\rechts.txt" for append as #copy1 print #copy1, input$(#original1, lof(#original1)); close #original1 close #copy1 open "c:\melkteller\melkteller.csv" for output as #csv close #csv kill "c:\melkteller\melkteller.csv" name "c:\melkteller\melkteller.txt" as "c:\melkteller\melkteller.csv" open "c:\melkteller\calibratie\calibratie.txt" for input as #c open "c:\melkteller\melkteller.csv" for input as #4 open "c:\melkteller\melkteller1.txt" for output as #3
OPEN "c:\melkteller\links.txt" FOR APPEND AS #5 OPEN "c:\melkteller\rechts.txt" FOR APPEND AS #6 for a =1 to 75 print #5,"250" print #6,"250" next a close #5 close #6 dim melk$(3000) for i = 1 to 146 line input #4, melk$(i) next i close #4
for i = 3 to 146 print #3, melk$(i) next i close #3
dim koenummer(3000) open "c:\melkteller\links.txt" for input as #readFile b = 1 while not( eof( #readFile)) inputcsv #readFile, koenummer(b) print koenummer(b)
if koenummer(b) < 1 then koenummer(b) =250 if koenummer(b) > 300 then koenummer(b) =250 print koenummer(b) b =b +1 wend
close #readFile
open "c:\melkteller\rechts.txt" for input as #readFile b = 73 while not( eof( #readFile)) inputcsv #readFile, koenummer(b) print koenummer(b) if koenummer(b) < 1 then koenummer(b) = 250 if koenummer(b) > 300 then koenummer(b) =250 print koenummer(b) b =b +1 wend close #readFile
M =3000 dim meterNumber( M), calibrationDate( M), calibrationValue( M) dim cowNumber(3000), recogn$(3000), followNum(3000), also(3000), data$(3000), milkingTime$(3000), milkAmount(3000), milkmeterNumber(3000), extra(3000), melkhoeveel$(3000) i =1 print " meterNumber calibrationDate calibrationValue" while not( eof( #c)) ' file entry # 1 2 3 ' meterNumber calibrationDate calibrationValue input #c, meterNumber( i), calibrationDate( i), calibrationValue( i) print ,meterNumber( i), calibrationDate( i), calibrationValue( i) i = i + 1 wend
close #c
print "" print "cowNumber recogn followNum also date milkingTime milkAmount milkmeterNumber"
open "c:\melkteller\melkteller.txt" for append as #fOut open "c:\melkteller\melkteller1.txt" for input as #m k = 1 while not( eof( #m)) ' file entry # 1 2 3 4 5 6 7 8 ' 40, Krokus, 3, 250, 6-12-20018, 17:43, 5.4, 3 inputcsv #m, recogn$(k), followNum(k), also(k), data$(k), milkingTime$(k), milkAmount(k), milkmeterNumber(k), extra(k)
k =k +1
wend
for j= 1 to 144 melkhoeveel$(j)= using( "##.#",milkAmount(j)/0.2*calibrationValue(milkmeterNumber(j))) if milkAmount(j)/0.2*calibrationValue(milkmeterNumber(j)) < 9.9 then melkhoeveel$(j)= using( "#.#",milkAmount(j)/0.2*calibrationValue(milkmeterNumber(j))) if milkAmount(j)/0.2*calibrationValue(milkmeterNumber(j)) < 2.5 then koenummer(j) = 250 end if print koenummer(j), recogn$(j), followNum(j), also(j), data$(j), milkingTime$(j), milkAmount(j), milkmeterNumber(j),_ using( "####.#", milkAmount(j)/0.2*calibrationValue( milkmeterNumber(j))) #fOut koenummer(j);";";recogn$(j);";";followNum(j);";";also(j);";";data$(j);";";milkingTime$(j);";";melkhoeveel$(j);";";milkmeterNumber(j);";"
next
close #m close #fOut print: print "Done."
goto [quit]
[quit]
'close #uni print "even inlezen" 'run "c:\Dairypln\INLEES.bat"
print " all done "
' close #1 ' CLOSE #2 ' close #r ' close #links 'close #m 'run "c:\dairypln\ASCTODII.exe" 'RUN "C:\DAIRYPLN\DPLINK.EXE MELK.DII /A" end
function readADR$(board$) while lof(#com) < 1 ' the ADR always sends back 3 digits wend readADR$ = input$(#com,lof(#com)) end function
function UDPsend(addr$, port, msg$) AF.INET = 2 SOCK.DGRAM = 2 IPPROTO.UDP = 17 UDPsend = 0
port = (port and hexdec("FF00")) / 256 + (port and 255) * 256 ' swap bytes calldll #winsock, "inet_addr", addr$ as ptr, ipaddr as ulong
struct WSAdata, d as char[398] calldll #winsock, "WSAStartup", 514 as long, WSAdata as struct, ret as long if ret then exit function
calldll #winsock, "socket", AF.INET as long, SOCK.DGRAM as long, _ IPPROTO.UDP as long, socket as long if socket = -1 then exit function
struct addr, family as short, port as short, addr as ulong, zero as char[8] addr.family.struct = AF.INET addr.port.struct = port addr.addr.struct = ipaddr
al = len(addr.struct) ml = len(msg$) calldll #winsock, "sendto", socket as long, msg$ as ptr, ml as long, _ 0 as long, addr as struct, al as long, sent as long
calldll #winsock, "closesocket", socket as long, ret as long calldll #winsock, "WSACleanup", ret as long
if sent = ml then UDPsend = 1 end function
Function OpenUDPServSocket(Port) HINTS.aiFlags.struct = 1 'Attempt to get a local address for hosting err = getsrvaddrinfo(str$(Port)) if err <> 0 then Notice "getaddrinfo failed: 0x";dechex$(err);" ";err a = WSACleanup() Call CloseWinsock end End If
'Fill the addrinfo struct with the info returned in the pointer lpAddrinfo = lp.addrinfo.struct size = len(addrinfo.struct) CallDLL #kernel32, "RtlMoveMemory",_ addrinfo as struct,_ lpAddrinfo as ulong,_ size as long,_ ret as void
'Fill the sockaddr struct from the returned addrinfo struct lpSockaddr = addrinfo.aiAddr.struct size = len(sockaddr.struct) CallDLL #kernel32, "RtlMoveMemory",_ sockaddr as struct,_ lpSockaddr as ulong,_ size as long,_ ret as void
CallDLL #kernel32, "RtlMoveMemory",_ sockaddrin as struct,_ sockaddr as struct,_ size as long,_ ret as void
print sockaddrin.sinPort.struct
'Create the socket with the types returned from getaddrinfo sock = socket(addrinfo.aiFamily.struct, addrinfo.aiSocktype.struct, addrinfo.aiProtocol.struct) If sock = hexdec("FFFFFFFF") then err = WSAGetLastError() Notice "Socket creation failed: 0x";dechex$(err);" ";err Call freeaddrinfo a = WSACleanup() call CloseWinsock end End If
'Bind the port If bind(sock, sockaddr.struct, addrinfo.aiAddrlen.struct) <> 0 then err = WSAGetLastError() Notice "Bind failed: 0x";dechex$(err);" ";err call freeaddrinfo a = closesocket(sock) a = WSACleanup() close #ws2 end End If
call freeaddrinfo 'addrinfo no longer needed OpenUDPServSocket = sock End Function
Function DoRecv$(sock, ByRef IPAddr$) buf$ = space$(1024) 'ret = recvfrom(sock, buf$, 1024, 0) If (ret = -1) then err = WSAGetLastError() Notice "recvfrom error: 0x";dechex$(err);" ";err a = closesocket(sock) a = WSACleanup() Call CloseWinsock end End If
DoRecv$ = left$(buf$, ret)
IPAddr$ = winstring(inetntoa(sockaddrin.sinAddr.struct)) End Function
Sub OpenWinsock open "ws2_32" for DLL as #ws2 err = WSAStartup() if err <> 0 then Notice "WSAStartup failed: 0x";dechex$(err);" ";err Call CloseWinsock end end if End Sub
Sub CloseWinsock a = WSACleanup() close #ws2 End Sub
Function recvfrom(sock, byref buf$, bufSize, flags, byref sockaddr$, byref sockaddrSize) buf$ = space$(bufSize) struct a, b as long a.b.struct = sockaddrSize c$ = sockaddr$ CallDLL #ws2, "recvfrom",_ sock as ulong,_ buf$ as ptr,_ bufSize as long,_ flags as long,_ c$ as ptr,_ a as struct,_ recvfrom as long
sockaddr$ = c$ sockaddrSize = a.b.struct End Function
Function recv(sock, byref buf$, bufLen) CallDLL #ws2, "recv",_ sock as ulong,_ buf$ as ptr,_ bufLen as long,_ 0 as long,_ recv as long End Function
Function sendto(sock, buf$, bufLen, sockAddr$) c$ = sockAddr$ size = len(c$)
CallDLL #ws2, "sendto",_ sock as ulong,_ buf$ as ptr,_ bufLen as long,_ 0 as long,_ c$ as ptr,_ size as long,_ sendto as long End Function
Function inetntoa(inAddr) CallDLL #ws2, "inet_ntoa",_ inAddr as ulong,_ inetntoa as ulong End Function
Function send(socket, Buf$, bufLen) CallDLL #ws2, "send",_ socket as ulong,_ Buf$ as ptr,_ bufLen as long,_ 0 as long,_ send as long End Function
Function bind(socket, lpSockAddr$, namelen) temp$ = lpSockAddr$ CallDLL #ws2, "bind",_ socket as ulong,_ temp$ as ptr,_ namelen as long,_ bind as long End Function
Function connect(socket, byref lpSockAddr, namelen) CallDLL #ws2, "connect",_ socket as ulong,_ sockaddr as struct,_ namelen as long,_ connect as long End Function
Function socket(family, socktype, protocol) CallDLL #ws2, "socket",_ family as long,_ socktype as long,_ protocol as long,_ socket as ulong End Function
Function WSAGetLastError() CallDLL #ws2, "WSAGetLastError",_ WSAGetLastError as long End Function
Function closesocket(sock) CallDLL #ws2, "closesocket",_ sock as ulong,_ closesocket as long End Function
Function getsrvaddrinfo(pServiceName$) CallDLL #ws2, "getaddrinfo",_ 0 as ulong,_ pServiceName$ as ptr,_ HINTS as struct,_ lp as struct,_ getsrvaddrinfo as long End Function
Function getaddrinfo(host$, pServiceName$) CallDLL #ws2, "getaddrinfo",_ host$ as ptr,_ pServiceName$ as ptr,_ HINTS as struct,_ lp as struct,_ getaddrinfo as long End Function
Sub freeaddrinfo CallDLL #ws2, "freeaddrinfo",_ lp.addrinfo.struct as ulong,_ ret as void End Sub
Function WSAStartup() word = MAKEWORD(2, 2) CallDLL #ws2, "WSAStartup",_ word as word,_ WSADATA as struct,_ WSAStartup as long End Function
Function WSACleanup() CallDLL #ws2, "WSACleanup",_ WSACleanup as long End Function
Function MAKEWORD(loWord, hiWord) MAKEWORD = (loWord AND hexdec("FF")) + (hiWord * hexdec("100")) End Function
Function LOBYTE(word) LOWORD = word AND hexdec("FF") End Function
Function HIWORD(word) HIWORD = (int(word / hexdec("100")) AND hexdec("FF")) End Function
Sub RtlCopyMemory lpDest, lpSource, uLength print "in sub"
'CallDLL #kernel32, "SetHandleCount",_ ' lpSource as ulong,_ ' lpStruct as ulong
struct lp2, addrinfo as ulong lp2.addrinfo.struct = addrinfo.struct
CallDLL #kernel32, "RtlMoveMemory",_ lp2 as struct,_ lp.addrinfo.struct as ulong,_ uLength as ulong,_ ret as void End Sub
[structInit] struct WSADATA,_ wVersion as word,_ wHighVersion as word,_ wsaDescription as CHAR[258],_ wsaSystemStatus as char[130],_ iMaxSockets as word,_ iMaxUdpDg as word,_ lpVendorInfo as ulong
struct sockaddr,_ saFamily as ushort,_ saData as char[14]
struct clisockaddr,_ saFamily as ushort,_ saData as char[14]
struct addrinfo,_ aiFlags as long,_ aiFamily as long,_ aiSocktype as long,_ aiProtocol as long,_ aiAddrlen as ulong,_ aiCanonname as ulong,_ aiAddr as ulong,_ aiNext as ulong
struct cliaddrinfo,_ aiFlags as long,_ aiFamily as long,_ aiSocktype as long,_ aiProtocol as long,_ aiAddrlen as ulong,_ aiCanonname as ulong,_ aiAddr as ulong,_ aiNext as ulong
struct lp,_ addrinfo as ulong
'addrinfo structure for hinting to getaddrinfo struct HINTS,_ aiFlags as long,_ aiFamily as long,_ aiSocktype as long,_ aiProtocol as long,_ aiAddrlen as ulong,_ aiCanonname as ulong,_ aiAddr as ulong,_ aiNext as ulong
struct SOCKET,_ lp as ulong
struct sockaddrin,_ sinFamily as short,_ sinPort as ushort,_ sinAddr as ulong,_ sinZero as char[8]
struct clisockaddrin,_ sinFamily as short,_ sinPort as ushort,_ sinAddr as ulong,_ sinZero as char[8]
HINTS.aiAddrlen.struct = 0 HINTS.aiAddr.struct = 0 HINTS.aiCanonname.struct = 0 HINTS.aiNext.struct = 0
HINTS.aiFlags.struct = 1 'AI_PASSIVE HINTS.aiFamily.struct = 2 'AF_INET HINTS.aiSocktype.struct = 2 'SOCK_DGRAM (Use UDP datagrams instead of TCP stream) HINTS.aiProtocol.struct = 17 'IPPROTO_UDP
'end return
|
|