konijn
Junior Member
Posts: 96
|
Post by konijn on Nov 19, 2020 16:04:45 GMT -5
Thanks. Its basic but not for me This is what I made of it: 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), p$(3000)
dim sa(3000), serverb$(3000), serverc$(3000), serverd$(3000), servere$(3000), serverf$(3000)
dim tochta$(3000), tochtb$(3000), tochtc$(3000), tochtd$(3000) ', tochte$(3000), tochtf$(3000), tochtg$(3000)
i =0 open "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), p$(i) print a(i), b$(i), c$(i), d$(i), e$(i), f$(i), g$(i), h$(i), i$(i), k$(i), l$(i), m$(i), n$(i) i =i +1 wend close #readFile
[serverinlees] k =0 open "server.txt" for input as #server while not( eof( #server)) inputcsv #server, sa(k), serverb$(k), serverc$(k), serverd$(k), servere$(k), serverf$(k) print sa(k), serverb$(k), serverc$(k), serverd$(k), servere$(k), serverf$(k) k =k +1 wend close #server
'randomize 0.1
doPrint = 1 'slower
N = i-1 'goto [skip] 'brute force - N^2, slow at big N 'but simple t0=time$("ms") for j = 1 to N found=0 for i = 1 to N if a(j)=sa(i) then found =i: exit for next if doPrint then print "Find ";a(j);"...", if not(found) then print "is MISSING" else print "found" end if next t1=time$("ms")
if doPrint then print "with printing" else print "without printing" end if
print "Brute force" print "time taken ";t1-t0
with this files inlees.csv 1,5433,,2,70,5.29,3.9,284,135,2,Drachtig,08-02-2020,AKERHOLT,7653,82,5433 2,299,,2,9,4.68,4.01,192,111,1,Drachtig,10-05-2020,R FASTRUP,10136,116,299 3,3104,,1,,,,33,33,,Gekalfd,16-10-2020,HOJDARE,,, 4,8367,42,3,,,,293,4,1,Droog,26-01-2020,PELL-PERS,7342,, 5,4894,,3,68,5.11,4.2,307,182,1,Drachtig,16-01-2020,Konijn Daimond,10177,99, 6,6506,,1,,,,391,202,5,Drachtig,24-10-2019,Konijn Rufsiga,6654,, 7,4913,,3,19,5.05,3.23,100,100,,Gekalfd,10-08-2020,KODAK,8094,87, 8,5193,,2,81,6.82,4.08,238,86,1,Drachtig,25-03-2020,VR CIGAR,8398,100, 9,2987,,2,14,4.18,3.56,86,86,,Gekalfd,24-08-2020,Konijn Rufsiga,8677,95, 10,405,,4,293,5.01,3.66,207,11,5,Geinsemineerd,25-04-2020,BRAUT,11072,110,405 and server.txt 113,19-11-2020,17:45:35,10.4,239,9 8,19-11-2020,17:45:22, 8.3,314,10 83,19-11-2020,17:46:51, 5.7,232,16 4,19-11-2020,17:46:03,12.0,469,13 7,19-11-2020,17:46:22,13.0,466,14 9,19-11-2020,17:46:34,12.7,502,15 100,19-11-2020,17:49:54,13.3,339,7 120,19-11-2020,17:50:14,17.4,340,2 37,19-11-2020,17:50:08, 8.2,352,8
This is the result: 1 5433 2 70 5.29 3.9 284 135 Drachtig 08-02-2020 AKERHOLT 7653 2 299 2 9 4.68 4.01 192 111 Drachtig 10-05-2020 R FASTRUP 10136 3 3104 1 33 33 Gekalfd 16-10-2020 HOJDARE 4 8367 42 3 293 4 Droog 26-01-2020 PELL-PERS 7342 5 4894 3 68 5.11 4.2 307 182 Drachtig 16-01-2020 Konijn Daimond 10177 6 6506 1 391 202 Drachtig 24-10-2019 Konijn Rufsiga 6654 7 4913 3 19 5.05 3.23 100 100 Gekalfd 10-08-2020 KODAK 8094 8 5193 2 81 6.82 4.08 238 86 Drachtig 25-03-2020 VR CIGAR 8398 9 2987 2 14 4.18 3.56 86 86 Gekalfd 24-08-2020 Konijn Rufsiga 8677 10 405 4 293 5.01 3.66 207 11 Geinsemineerd 25-04-2020 BRAUT 11072 113 19-11-2020 17:45:35 10.4 239 9 8 19-11-2020 17:45:22 8.3 314 10 83 19-11-2020 17:46:51 5.7 232 16 4 19-11-2020 17:46:03 12.0 469 13 7 19-11-2020 17:46:22 13.0 466 14 9 19-11-2020 17:46:34 12.7 502 15 100 19-11-2020 17:49:54 13.3 339 7 120 19-11-2020 17:50:14 17.4 340 2 37 19-11-2020 17:50:08 8.2 352 8 Find 2... is MISSING Find 3... is MISSING Find 4... found Find 5... is MISSING Find 6... is MISSING Find 7... found Find 8... found Find 9... found Find 10... is MISSING with printing Brute force time taken 11
How can I collect the missing numbers? I want to send that numbers with sms to my mobile? As one message$ Thanks
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Dec 25, 2020 12:46:09 GMT -5
All best wishes!! I will post the code which I use for all. But first I will explain what it do, what it mean and how it works! First the program is based on use to work with udp. Its a server, you can send commando's with udp to control and stop the program. For example use this one Packet Sender. For to stop the program send witht packet sender "einde" with udp on port 27016 to the ipadress where the program is running or maybe localhost (127.0.0.1) will work. What does it do. Its a server program. First it imports cow data from a .csv file. voer1.csv is the feed data what a cow has eten last 24 hours. second file inlees.csv is the most important data of the cow what is need in the milkstable; like calving date, status, just calved, or pregnant etc. How many kg she produces so far with fat and protein. I will included this files. The tocht.csv is a file with attentions cows how show more activity (are in heat). In the milkstable are 16 places 8 right and 8 left. Each place has an antenne. The cow has a transponder on her neck and the RFID system sends the transpondercode and the antenne number to Liberty Basic by udp on port 27016. Liberty basic is recognizing the transpondercode find out which cow that is and sends the data also bij udp on port 12080 to an arduino with an TFT sreen which is above the cow. When the cow start milking the arduino sends start with ipnumber to LB, the start time is placed. When the cow is finished the arduino send stop to LOB with the amount of milk and also the ip adress off the arduino. And al is witten in the file server.txt as time date amount and time how long the milking has taken. Its possible to send more commands to the server, example to send a cow number by hand if its not recognized automaticly, or send a code to all arduino's to switch the milkplace in cleaning mode. Recently I can send a code to the RFID station to give feed to a cow when she is recognizid. So there is a lot possible. If you want take a look in the code. I am sure its not programmed the right way! But its working and that for a farmer!. Last discussion was to try to send a command and the server should answer with cow numbers who are not milked yet. Looked in the files inlees.csv and server.txt and without cows with status "droog". In a seperate file it works but when I want to implant in the code below, something wend wrong. See chapter [check] Thanks Jack This are the help files: inlees.csv 1,5433,,2,103,5.56,4,320,171,2,Drachtig,08-02-2020,Anton,7581,77,5433 2,299,,2,35,5.46,4.15,228,147,1,Drachtig,10-05-2020,Donnie,10723,121,299 3,3104,,1,74,4.33,3.42,69,69,,Gekalfd,16-10-2020,Blubbel,8525,99, 4,8367,6,3,,,,293,40,1,Droog,26-01-2020,Kees,7342,, 5,4894,,3,115,5.38,4.4,343,218,1,Drachtig,16-01-2020,dots,10126,95, 6,6506,40,1,,,,421,6,5,Droog,24-10-2019,Ming,6654,, 7,4913,,3,90,6.15,3.83,136,25,1,Geinsemineerd,10-08-2020,Dirk,8262,93, 8,5193,,2,113,6.66,4.57,274,122,1,Drachtig,25-03-2020,Elvis,8384,99, 9,2987,,2,28,4.81,3.82,122,6,2,Geinsemineerd,24-08-2020,Geert,8582,93, 10,405,,4,415,5.69,3.57,243,27,6,Geinsemineerd,25-04-2020,Charli,10713,101,405 voer1.csv 1,5433,22/12/2020,-1.25,0.75 1,5433,22/12/2020,-1.25,0.75 1,5433,22/12/2020,-1.25,0.75 1,5433,22/12/2020,-1.25,0.75 2,299,22/12/2020,-0.69,6.91 2,299,22/12/2020,-0.69,6.91 2,299,22/12/2020,-0.69,6.91 2,299,22/12/2020,-0.69,6.91 3,3104,22/12/2020,-1.43,4.79 3,3104,22/12/2020,-1.43,4.79 3,3104,22/12/2020,-1.43,4.79 3,3104,22/12/2020,-1.43,4.79 4,8367,22/12/2020,3.6,3.6 4,8367,22/12/2020,3.6,3.6 4,8367,22/12/2020,3.6,3.6 4,8367,22/12/2020,3.6,3.6 5,4894,22/12/2020,-2,0 5,4894,22/12/2020,-2,0 5,4894,22/12/2020,-2,0 5,4894,22/12/2020,-2,0 6,6506,22/12/2020,0,0 6,6506,22/12/2020,0,0 6,6506,22/12/2020,0,0 6,6506,22/12/2020,0,0 7,4913,22/12/2020,-0.96,6.09 7,4913,22/12/2020,-0.96,6.09 7,4913,22/12/2020,-0.96,6.09 7,4913,22/12/2020,-0.96,6.09 8,5193,22/12/2020,-1.25,0.75 8,5193,22/12/2020,-1.25,0.75 8,5193,22/12/2020,-1.25,0.75 8,5193,22/12/2020,-1.25,0.75 9,2987,22/12/2020,-1.71,5.75 9,2987,22/12/2020,-1.71,5.75 9,2987,22/12/2020,-1.71,5.75 9,2987,22/12/2020,-1.71,5.75 10,405,22/12/2020,0.43,3.55 10,405,22/12/2020,0.43,3.55 10,405,22/12/2020,0.43,3.55 10,405,22/12/2020,0.43,3.55 tocht.csv 2,+,+ sinds 19 uur ,299 3,+,+ sinds 17 uur ,3104 4,+,+ sinds 14 uur gister,8367 5,+,+ sinds 14 uur ,4894 6,+,+ sinds 16 uur gister,6506 7,+++,+++ sinds 14 uur ,4913 9,+,+ sinds 23 uur ,2987 This is all the code: datum$ =date$("mm/dd/yyyy") dt$=word$(datum$,2,"/")+"-"+word$(datum$,1,"/")+"-"+word$(datum$,3,"/") 'tijdopstart = TIME$("seconds") + 55 'run "c:\melkteller\herkenning\inlees.bat" 'run "c:\delpro\export\tocht\tochtsms.exe" '[start] 'if TIME$("seconds")< tijdopstart then goto [start]
OPEN "links.txt" FOR OUTPUT AS #1 OPEN "rechts.txt" FOR OUTPUT AS #2
close #1 close #2 open "WS2_32" for DLL as #winsock
dim starttijd(300), begintijd$(300), stoptijd(300), melkduur(300)
dim a$(300), b$(300), c$(300), d$(300), e$(300), f$(300), g$(300) ' 15 fields dim h$(300), i$(300), j$(300), k$(300), l$(300), m$(300), n$(300), o$(300), p$(300)
dim voera$(300), voerb$(300), voerc$(300), voerd$(300), voere$(300), voerf$(300), voerh$(300), voerg$(300), voers$(300), voert$(300) dim voeri$(300), voerj$(300), voerk$(300), voerl$(300), voerm$(300), voern$(300), voero$(300), voerp$(300), voerq$(300), voerr$(300) ' 20 fields
dim tochta$(300), tochtb$(300), tochtc$(300), tochtd$(300) ', tochte$(3000), tochtf$(3000), tochtg$(3000)
dim servera$(300), serverb$(3000), serverc$(300), serverd$(300), servere$(300), serverf$(300)
i =0 open "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), p$(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 "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 "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 = 27016 sock = OpenUDPServSocket(port) tijdlinks = 999999 tijdrechts = 999999
[begin] 'print "Hoofdmenu Koeherkenning Konijn.nu Software 2020" 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] if koehand$ = "spoel1" then goto [spoel1] if koehand$ = "spoel3" then goto [spoel3] if koehand$ = "testvoer" then goto [testvoer] if koehand$ = "check" then goto [check] if koehand$ = "display*01" then goto [handmatig] if koehand$ = "display*03" then goto [spoel1] if koehand$ = "display*04" then goto [spoel3] 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("192.168.2.201", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.202", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.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("192.168.2.202", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.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("192.168.2.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.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("192.168.2.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.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("192.168.2.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.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("192.168.2.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.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("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 10 and zender$ = resultR1$ then print "correct" corr9 = 1 corr10 = 1 corr11 = 1 corr12 = 1 corr13 = 1 corr14 = 1 corr15 = 1 corr16 = 1 antenne = antenne-1 tijdcorrectieR = TIME$("seconds") + 360 resultR1$ ="" resultR2$ ="" resultR3$ ="" resultR4$ ="" resultR5$ ="" resultR6$ ="" resultR7$ ="" resultR8$ ="" ok=UDPsend("192.168.2.209", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.210", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.211", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.212", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 11 and zender$ = resultR2$ then corr9 = 0 corr10 = 1 corr11 = 1 corr12 = 1 corr13 = 1 corr14 = 1 corr15 = 1 corr16 = 1 antenne = antenne-1 tijdcorrectieR = TIME$("seconds") + 360 resultR2$ ="" resultR3$ ="" resultR4$ ="" resultR5$ ="" resultR6$ ="" resultR7$ ="" resultR8$ ="" ok=UDPsend("192.168.2.210", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.211", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.212", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 12 and zender$ = resultR3$ then corr9 = 0 corr10 = 0 corr11 = 1 corr12 = 1 corr13 = 1 corr14 = 1 corr15 = 1 corr16 = 1 antenne = antenne-1 tijdcorrectieR = TIME$("seconds") + 360 resultR3$ ="" resultR4$ ="" resultR5$ ="" resultR6$ ="" resultR7$ ="" resultR8$ ="" ok=UDPsend("192.168.2.211", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.212", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 13 and zender$ = resultR4$ then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 1 corr13 = 1 corr14 = 1 corr15 = 1 corr16 = 1 antenne = antenne-1 tijdcorrectieR = TIME$("seconds") + 360 resultR4$ ="" resultR5$ ="" resultR6$ ="" resultR7$ ="" resultR8$ ="" ok=UDPsend("192.168.2.212", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 14 and zender$ = resultR5$ then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 1 corr14 = 1 corr15 = 1 corr16 = 1 antenne = antenne-1 tijdcorrectieR = TIME$("seconds") + 360 resultR5$ ="" resultR6$ ="" resultR7$ ="" resultR8$ ="" ok=UDPsend("192.168.2.213", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 15 and zender$ = resultR6$ then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 1 corr15 = 1 corr16 = 1 antenne = antenne-1 tijdcorrectieR = TIME$("seconds") + 360 resultR6$ ="" resultR7$ ="" resultR8$ ="" ok=UDPsend("192.168.2.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if
if antenne = 16 and zender$ = resultR7$ then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 1 corr16 = 1 antenne = antenne-1 tijdcorrectieR = TIME$("seconds") + 360 resultR7$ ="" resultR8$ ="" ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") end if print "nu naar antenne" goto [antenne]
[startmeter]
ip$=word$(info$,2,"#") if ip$ = "192.168.2.201" then o = 1 : starttijd(1) = time$("seconds"): begintijd$(1) = time$(): goto [begin] if ip$ = "192.168.2.202" then o = 2 : starttijd(2) = time$("seconds"): begintijd$(2) = time$(): goto [begin] if ip$ = "192.168.2.203" then o = 3 : starttijd(3) = time$("seconds"): begintijd$(3) = time$(): goto [begin] if ip$ = "192.168.2.204" then o = 4 : starttijd(4) = time$("seconds"): begintijd$(4) = time$(): goto [begin] if ip$ = "192.168.2.205" then o = 5 : starttijd(5) = time$("seconds"): begintijd$(5) = time$(): goto [begin] if ip$ = "192.168.2.206" then o = 6 : starttijd(6) = time$("seconds"): begintijd$(6) = time$(): goto [begin] if ip$ = "192.168.2.207" then o = 7 : starttijd(7) = time$("seconds"): begintijd$(7) = time$(): goto [begin] if ip$ = "192.168.2.208" then o = 8 : starttijd(8) = time$("seconds"): begintijd$(8) = time$(): goto [begin] if ip$ = "192.168.2.209" then o = 9 : starttijd(9) = time$("seconds"): begintijd$(9) = time$(): goto [begin] if ip$ = "192.168.2.210" then o = 10 : starttijd(10) = time$("seconds"): begintijd$(10) = time$(): goto [begin] if ip$ = "192.168.2.211" then o = 11 : starttijd(11) = time$("seconds"): begintijd$(11) = time$(): goto [begin] if ip$ = "192.168.2.212" then o = 12 : starttijd(12) = time$("seconds"): begintijd$(12) = time$(): goto [begin] if ip$ = "192.168.2.213" then o = 13 : starttijd(13) = time$("seconds"): begintijd$(13) = time$(): goto [begin] if ip$ = "192.168.2.214" then o = 14 : starttijd(14) = time$("seconds"): begintijd$(14) = time$(): goto [begin] if ip$ = "192.168.2.215" then o = 15 : starttijd(15) = time$("seconds"): begintijd$(15) = time$(): goto [begin] if ip$ = "192.168.2.216" then o = 16 : starttijd(16) = time$("seconds"): begintijd$(16) = time$(): goto [begin]
[stopmeter]
ip$=word$(info$,2,"#") if ip$ = "192.168.2.201" then o = 1 : stoptijd(1) = time$("seconds") : goto [server] if ip$ = "192.168.2.202" then o = 2 : stoptijd(2) = time$("seconds") : goto [server] if ip$ = "192.168.2.203" then o = 3 : stoptijd(3) = time$("seconds") : goto [server] if ip$ = "192.168.2.204" then o = 4 : stoptijd(4) = time$("seconds") : goto [server] if ip$ = "192.168.2.205" then o = 5 : stoptijd(5) = time$("seconds") : goto [server] if ip$ = "192.168.2.206" then o = 6 : stoptijd(6) = time$("seconds") : goto [server] if ip$ = "192.168.2.207" then o = 7 : stoptijd(7) = time$("seconds") : goto [server] if ip$ = "192.168.2.208" then o = 8 : stoptijd(8) = time$("seconds") : goto [server] if ip$ = "192.168.2.209" then o = 9 : stoptijd(9) = time$("seconds") : goto [server] if ip$ = "192.168.2.210" then o = 10 : stoptijd(10) = time$("seconds"): goto [server] if ip$ = "192.168.2.211" then o = 11 : stoptijd(11) = time$("seconds"): goto [server] if ip$ = "192.168.2.212" then o = 12 : stoptijd(12) = time$("seconds"): goto [server] if ip$ = "192.168.2.213" then o = 13 : stoptijd(13) = time$("seconds"): goto [server] if ip$ = "192.168.2.214" then o = 14 : stoptijd(14) = time$("seconds"): goto [server] if ip$ = "192.168.2.215" then o = 15 : stoptijd(15) = time$("seconds"): goto [server] if ip$ = "192.168.2.216" then o = 16 : stoptijd(16) = time$("seconds"): goto [server]
[server]
melkduur(o) = (stoptijd(o)-starttijd(o)) melkgift$ = word$(info$,4,"#") koeserver1$ = word$(info$,3,"#") koeserver$ = word$(koeserver1$,1,".") koeserver$ = (trim$(koeserver$)) 'ok=UDPsend(ip$, 12080, ";"+koeserver$+";;;Melkgift verstuurd!;;;;;;;;;;;;;;;;;;;;") if (val(melkgift$) < 0.3) then goto [probleem] if (val(koeserver$) < 1) then goto [probleem]
OPEN "server.txt" FOR append AS #ser print #ser, koeserver$;",";dt$;",";begintijd$(o);",";melkgift$;",";melkduur(o);",";o close #ser goto [begin]
[probleem] OPEN "probleem.txt" FOR append AS #prob print #prob, koeserver$;",";dt$;",";begintijd$(o);",";melkgift$;",";melkduur(o);",";o close #prob goto [begin]
[check]
dim info$(10,10) fpath$ = "server.txt" if fileExists(fpath$) then print fpath$; " exists!" else goto [begin] end if
message$="" for k = 0 to 300 'print servera$(k) servera$(k)="" next k
k = 0 open "server.txt" for input as #check while not( eof( #check)) inputcsv #check, servera$(k), serverb$(k), serverc$(k), serverd$(k), servere$(k), serverf$(k) ' print servera$(k), serverb$(k), serverc$(k), serverd$(k), servere$(k), serverf$(k) k =k +1 wend close #check
'for i = 0 to 145 'print a$(i) 'next i
'randomize 0.1
doPrint = 1 'slower
N = i-1 'goto [skip] 'brute force - N^2, slow at big N 'but simple 't0=time$("ms") for j = 1 to N found=0 for i = 1 to N if a$(j)=servera$(i-1) then found =i: exit for next if doPrint then ' print "Find ";a(j) ; k$(j);"...", if not(found) and k$(j) <> "Droog" then message$=message$ +" "+a$(j) 'if k$(j) < "Droog" then print a(j) ; k$(j);"is MISSING" 'else print "found" end if next print message$
goto [begin]
[LV1] if zender$ = result1$ goto [begin] if tijd > resettijdlinks then gosub [resetlinks] result1$=zender$ result1$ = TRIM$(result1$) print result1$ transponder$ = result1$ ipnr$ = "192.168.2.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 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#1#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";1-corr1;"#1#1000#27#17000") goto [verstuur]
[LV2] if zender$ = result2$ goto [begin] if tijd > resettijdlinks then gosub [resetlinks] result2$=zender$ result2$ = TRIM$(result2$) print result2$ transponder$ = result2$ ipnr$ = "192.168.2.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 ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#1#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";1-corr2;"#1#1000#27#17000") goto [verstuur]
[LV3] if zender$ = result3$ goto [begin] if tijd > resettijdlinks then gosub [resetlinks] result3$=zender$ result3$ = TRIM$(result3$) print result3$ transponder$ = result3$ ipnr$ = "192.168.2.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 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#2#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";2-corr3;"#1#1000#27#17000") goto [verstuur]
[LV4] if zender$ = result4$ goto [begin] result4$=zender$ result4$ = TRIM$(result4$) print result4$ transponder$ = result4$ ipnr$ = "192.168.2.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 ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#2#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";2-corr4;"#1#1000#27#17000") goto [verstuur]
[LV5] if zender$ = result5$ goto [begin] result5$=zender$ result5$ = TRIM$(result5$) print result5$ transponder$ = result5$ ipnr$ = "192.168.2.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 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#3#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";3-corr5;"#1#1000#27#17000") goto [verstuur]
[LV6] if zender$ = result6$ goto [begin] result6$=zender$ result6$ = TRIM$(result6$) print result6$ transponder$ = result6$ ipnr$ = "192.168.2.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 ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#3#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";3-corr6;"#1#1000#27#17000") goto [verstuur]
[LV7] if zender$ = result7$ goto [begin] result7$=zender$ result7$ = TRIM$(result7$) print result7$ transponder$ = result7$ ipnr$ = "192.168.2.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 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#4#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";4-corr7;"#1#1000#27#17000") goto [verstuur]
[LV8] if zender$ = result8$ goto [begin] result8$=zender$ result8$ = TRIM$(result8$) print result8$ transponder$ = result8$ ipnr$ = "192.168.2.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 ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#4#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";4-corr8;"#1#1000#27#17000") 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] if tijd > resettijdrechts then gosub [resetrechts] resultR1$=zender$ resultR1$ = TRIM$(resultR1$) print resultR1$ transponder$ = resultR1$ ipnr$ = "192.168.2.209" plaats$ = "RV1" tijdrechts = time$("seconds")+ 360 resettijdrechts = time$("seconds")+ 360 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#5#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";5-corr9;"#1#1000#27#17000") goto [verstuur]
[RV2] if zender$ = resultR2$ goto [begin] if tijd > resettijdrechts then gosub [resetrechts] resultR2$=zender$ resultR2$ = TRIM$(resultR2$) print resultR2$ transponder$ = resultR2$ ipnr$ = "192.168.2.210" plaats$ = "RV2" tijdrechts = time$("seconds")+ 360 resettijdrechts = time$("seconds")+ 360 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#5#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";5-corr10;"#1#1000#27#17000") goto [verstuur]
[RV3] if zender$ = resultR3$ goto [begin] if tijd > resettijdrechts then gosub [resetrechts] resultR3$=zender$ resultR3$ = TRIM$(resultR3$) print resultR3$ transponder$ = resultR3$ ipnr$ = "192.168.2.211" plaats$ = "RV3" tijdrechts = time$("seconds")+ 300 resettijdrechts = time$("seconds")+ 360 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#6#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";6-corr11;"#1#1000#27#17000") goto [verstuur]
[RV4] if zender$ = resultR4$ goto [begin] resultR4$=zender$ resultR4$ = TRIM$(resultR4$) print resultR4$ transponder$ = resultR4$ ipnr$ = "192.168.2.212" plaats$ = "RV4" ' tijdrechts = time$("seconds")+ 300 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#6#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";6-corr12;"#1#1000#27#17000") goto [verstuur]
[RV5] if zender$ = resultR5$ goto [begin] resultR5$=zender$ resultR5$ = TRIM$(resultR5$) print resultR5$ transponder$ = resultR5$ ipnr$ = "192.168.2.213" plaats$ = "RV5" ' tijdrechts = time$("seconds")+ 300 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#7#0#0#0#0") ok=UDPsend("192.168.2.4", 5003, "1010#2#MT02#";7-corr13;"#1#1000#27#17000") goto [verstuur]
[RV6] if zender$ = resultR6$ goto [begin] resultR6$=zender$ resultR6$ = TRIM$(resultR6$) print resultR6$ transponder$ = resultR6$ ipnr$ = "192.168.2.214" plaats$ = "RV6" ' tijdrechts = time$("seconds")+ 300 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#7#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";7-corr14;"#1#1000#27#17000") goto [verstuur]
[RV7] if zender$ = resultR7$ goto [begin] resultR7$=zender$ resultR7$ = TRIM$(resultR7$) print resultR7$ transponder$ = resultR7$ ipnr$ = "192.168.2.215" plaats$ = "RV7" ' tijdrechts = time$("seconds")+ 300 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if 'ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#8#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";8-corr15;"#1#1000#27#17000") goto [verstuur]
[RV8] if zender$ = resultR8$ goto [begin] resultR8$=zender$ resultR8$ = TRIM$(resultR8$) print resultR8$ transponder$ = resultR8$ ipnr$ = "192.168.2.216" plaats$ = "RV8" ' tijdrechts = time$("seconds")+ 300 if tijd > tijdcorrectieR then corr9 = 0 corr10 = 0 corr11 = 0 corr12 = 0 corr13 = 0 corr14 = 0 corr15 = 0 corr16 = 0 end if ' ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#8#0#0#0#0") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#";8-corr16;"#1#1000#27#17000") goto [verstuur]
[spoel1] spoelstand$=word$(info$,2,"#") if spoelstand$ = "A" then goto [spoelA] if spoelstand$ = "B" then goto [spoelB] if spoelstand$ = "AB" then goto [spoel01] if spoelstand$ = "BA" then goto [spoel01]
[spoelA] ok=UDPsend("192.168.2.201", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.202", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.203", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.204", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.208", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") goto [begin]
[spoelB] ok=UDPsend("192.168.2.209", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.210", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.211", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.212", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") goto [begin]
[spoel01] ok=UDPsend("192.168.2.201", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.202", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.203", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.204", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.208", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.209", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.210", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.211", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.212", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";8801;;;;;;;;;;;;;;;;;;;;;") goto [begin]
[spoel3] ok=UDPsend("192.168.2.201", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.202", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.203", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.204", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.208", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.209", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.210", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.211", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.212", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";8803;;;;;;;;;;;;;;;;;;;;;") goto [inlees]
[testvoer]
motor$=word$(info$,2,"#") ok=UDPsend("192.168.2.230", 5003, "1010#2#MT02#"+motor$+"#1#1000#10#3000")
[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$ <> tochtd$(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)+". "+tochtb$(k)+";Vader: ;"+m$(j)+";Klfdt: ;"+l$(j)+"("+h$(j)+")("+d$(j)+");"+tochtc$(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)+";"+p$(j)+";;;;") print ipnr$,";"+a$(j)+" "+tochtb$(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)+". "+tochtb$(k)+";Vader: ;"+m$(j)+";Klfdt: ;"+l$(j)+"("+h$(j)+")("+d$(j)+");"+tochtc$(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)+";"+p$(j)+";;;;") print "Invalid operation- voerd$ =0" print ipnr$,";"+a$(j)+" "+tochtb$(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("192.168.2.201", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.202", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.203", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.204", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.205", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.206", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.207", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.208", 12080, ";;;;;;;;;;;;;;;;;;;;;;") result4$ ="" result5$ ="" result6$ ="" result7$ ="" result8$ =""
return
[resetrechts]
ok=UDPsend("192.168.2.209", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.210", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.211", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.212", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.213", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.214", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.215", 12080, ";;;;;;;;;;;;;;;;;;;;;;") ok=UDPsend("192.168.2.216", 12080, ";;;;;;;;;;;;;;;;;;;;;;") resultR4$ ="" resultR5$ ="" resultR6$ ="" resultR7$ ="" resultR8$ =""
return
'[end] 'close #winsock
end
[inlees] CallDLL #ws2, "closesocket",_ sock as ulong,_ closesocket as long close #ws2 close #winsock
goto [quit]
[quit]
print "even inlezen"
print " all done "
end
function leadingZero$( i) leadingZero$ =right$( "000" +str$( i), 3) end function
function hhmmss$( i) ' NB if i is >=86400 ( 60 *60 *24) this needs modifying! subject =i sec =i mod 60 i =( i -sec) /60 min =i mod 60 i =( i -min) /60 hrs =i hhmmss$ =right$( "00" +str$( hrs), 2) +"" +right$( "00" +str$( min), 2) +"" +right$( "00" +str$( sec), 2) if ( sec +60 *min +3600 *hrs) <>subject then notice "I failed!" end function
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
'return a true if the file in fullPath$ exists, else return false function fileExists(fullPath$) files pathOnly$(fullPath$), filenameOnly$(fullPath$), info$() fileExists = val(info$(0, 0)) > 0 end function
'return just the directory path from a full file path function pathOnly$(fullPath$) pathOnly$ = fullPath$ while right$(pathOnly$, 1) <> "\" and pathOnly$ <> "" pathOnly$ = left$(pathOnly$, len(pathOnly$)-1) wend end function
'return just the filename from a full file path function filenameOnly$(fullPath$) pathLength = len(pathOnly$(fullPath$)) filenameOnly$ = right$(fullPath$, len(fullPath$)-pathLength) end function
|
|