konijn
Junior Member
Posts: 96
|
Post by konijn on Dec 28, 2018 12:22:23 GMT -5
Hello,
I have two files for input, The first file have the calibration for each milkmeter:
1,20122018,0.2 2,20122018,0.2 3,20122018,0.2 4,20122018,0.2 5,20122018,0.2 6,20122018,0.2 7,20122018,0.2 8,20122018,0.101 9,20122018,0.2 10,20122018,0.2 11,20122018,0.2 12,20122018,0.2 13,20122018,0.2 14,20122018,0.2 15,20122018,0.2 16,20122018,0.2 first row is the number of the meter, second is calibrationdate and last is the calibrationvalue
Second file is the output of the computer of all the milkmeter:
40,Krokus,3,250,6-12-20018,17:43,5.4,3 125,Krokus,4,250,6-12-20018,17:44,14.6,4 76,Krokus,5,250,6-12-20018,17:43,4.8,5 39,Krokus,6,250,6-12-20018,17:44,18.2,6 52,Krokus,7,250,6-12-20018,17:44,11.4,7 69,Krokus,8,250,6-12-20018,17:44,13.0,8 106,Krokus,9,250,6-12-20018,18:02,15.2,1 48,Krokus,10,250,6-12-20018,18:02,14.6,2 140,Krokus,11,250,6-12-20018,18:02,17.8,3 7,Krokus,12,250,6-12-20018,18:03,10.8,4 123,Krokus,13,250,6-12-20018,18:02,11.6,5 100,Krokus,14,250,6-12-20018,18:03,18.2,6 137,Krokus,15,250,6-12-20018,17:59,14.8,7 103,Krokus,16,250,6-12-20018,18:04,12.6,8 88,Krokus,17,250,6-12-20018,18:18,6.8,1 41,Krokus,18,250,6-12-20018,18:19,12.6,2 12,Krokus,19,250,6-12-20018,18:19,8.4,3 3,Krokus,20,250,6-12-20018,18:19,12.0,4 49,Krokus,21,250,6-12-20018,18:19,9.2,5 54,Krokus,22,250,6-12-20018,18:20,10.4,6 58,Krokus,23,250,6-12-20018,18:20,12.2,7 51,Krokus,24,250,6-12-20018,18:20,19.4,8 68,Krokus,25,250,6-12-20018,18:38,8.6,1 57,Krokus,26,250,6-12-20018,18:38,13.4,2 45,Krokus,27,250,6-12-20018,18:39,15.4,3 85,Krokus,28,250,6-12-20018,18:39,14.2,4 72,Krokus,29,250,6-12-20018,18:39,13.2,5 66,Krokus,30,250,6-12-20018,18:39,8.6,6 119,Krokus,31,250,6-12-20018,18:39,11.2,7 65,Krokus,32,250,6-12-20018,18:39,10.0,8 91,Krokus,33,250,6-12-20018,18:56,8.4,1 28,Krokus,34,250,6-12-20018,18:56,12.8,2 143,Krokus,35,250,6-12-20018,18:56,11.8,3 81,Krokus,36,250,6-12-20018,18:56,18.2,4 53,Krokus,37,250,6-12-20018,18:56,10.2,5 141,Krokus,38,250,6-12-20018,18:56,17.8,6 33,Krokus,39,250,6-12-20018,18:57,11.2,7 77,Krokus,40,250,6-12-20018,18:57,16.0,8 67,Krokus,41,250,6-12-20018,19:09,17.0,1 87,Krokus,42,250,6-12-20018,19:12,8.4,2 36,Krokus,43,250,6-12-20018,19:13,14.4,3 19,Krokus,44,250,6-12-20018,19:13,7.0,4 101,Krokus,45,250,6-12-20018,19:13,8.2,5 99,Krokus,46,250,6-12-20018,19:13,14.4,6 22,Krokus,47,250,6-12-20018,19:14,12.2,7 21,Krokus,48,250,6-12-20018,19:13,12.8,8 62,Krokus,49,250,6-12-20018,19:32,8.0,1 20,Krokus,50,250,6-12-20018,19:31,12.2,2 26,Krokus,51,250,6-12-20018,17:40,17.6,3 44,Krokus,52,250,6-12-20018,19:31,16.6,4 2,Krokus,53,250,6-12-20018,19:32,10.8,5 50,Krokus,54,250,6-12-20018,19:32,15.0,6 9,Krokus,55,250,6-12-20018,19:33,11.6,7 98,Krokus,56,250,6-12-20018,19:33,13.2,8 35,Krokus,73,250,6-12-20018,17:47,12.2,9 34,Krokus,74,250,6-12-20018,17:46,10.0,10 115,Krokus,75,250,6-12-20018,17:47,12.8,11 70,Krokus,76,250,6-12-20018,17:47,14.4,12 8,Krokus,77,250,6-12-20018,17:48,11.4,13 23,Krokus,78,250,6-12-20018,17:48,6.8,14 64,Krokus,79,250,6-12-20018,17:48,16.4,15 24,Krokus,80,250,6-12-20018,17:48,13.8,16 92,Krokus,81,250,6-12-20018,18:05,15.4,9 130,Krokus,82,250,6-12-20018,18:05,5.4,10 46,Krokus,83,250,6-12-20018,18:05,13.0,11 95,Krokus,84,250,6-12-20018,18:06,7.2,12 32,Krokus,85,250,6-12-20018,17:59,15.0,13 15,Krokus,86,250,6-12-20018,18:06,16.6,14 79,Krokus,87,250,6-12-20018,18:06,10.8,15 90,Krokus,88,250,6-12-20018,18:07,8.0,16 78,Krokus,89,250,6-12-20018,18:15,20.6,9 89,Krokus,90,250,6-12-20018,18:23,13.6,10 94,Krokus,91,250,6-12-20018,18:23,21.0,11 30,Krokus,92,250,6-12-20018,18:23,13.8,12 86,Krokus,93,250,6-12-20018,18:22,15.4,13 63,Krokus,94,250,6-12-20018,18:22,20.2,14 43,Krokus,95,250,6-12-20018,18:22,16.2,15 120,Krokus,96,250,6-12-20018,18:23,11.8,16 107,Krokus,97,250,6-12-20018,18:42,14.0,9 14,Krokus,98,250,6-12-20018,18:42,18.8,10 114,Krokus,99,250,6-12-20018,18:43,7.0,11 138,Krokus,100,250,6-12-20018,18:34,12.4,12 144,Krokus,101,250,6-12-20018,18:41,9.6,13 16,Krokus,102,250,6-12-20018,18:41,23.0,14 97,Krokus,103,250,6-12-20018,18:42,10.8,15 42,Krokus,104,250,6-12-20018,18:42,10.8,16 61,Krokus,105,250,6-12-20018,19:00,14.0,9 17,Krokus,106,250,6-12-20018,18:59,12.4,10 102,Krokus,107,250,6-12-20018,18:59,7.0,11 128,Krokus,108,250,6-12-20018,18:54,6.8,12 27,Krokus,109,250,6-12-20018,18:58,9.6,13 38,Krokus,110,250,6-12-20018,18:59,19.6,14 96,Krokus,111,250,6-12-20018,18:56,10.0,15 18,Krokus,112,250,6-12-20018,18:59,13.0,16 111,Krokus,113,250,6-12-20018,19:17,15.8,9 133,Krokus,114,250,6-12-20018,19:16,14.0,10 31,Krokus,115,250,6-12-20018,19:17,16.2,11 124,Krokus,116,250,6-12-20018,19:17,11.6,12 29,Krokus,117,250,6-12-20018,19:15,13.4,13 108,Krokus,118,250,6-12-20018,19:16,18.2,14 10,Krokus,119,250,6-12-20018,19:16,11.0,15 5,Krokus,120,250,6-12-20018,19:17,14.2,16
First collum is cownumber, second is a recognize for the file, third is follownumber, fourth also, fifth is the date. seventh is the millkingtime, eighth is the milkamount and the last collum is the milkmeter number which belongs to the numbers of milkmeters in the first file.
I have this code in LB:open "c:\calibratie\calibratie.txt" FOR INPUT AS #c open "c:\melkteller.csv" FOR INPUT AS #m dim ca$(3000), cb(3000), cc(3000) i =0
while not( eof( #c)) inputcsv #c, ca$(i), cb(i), cc(i)
print ca$(i), cb(i), cc(i) i = i + 1 wend close #c
dim melk$(3000), melk1$(3000), melk2$(3000), melk3$(3000), melk4$(3000), melk5$(3000), melk6(3000), melk7$(3000),aa(3000) a =0
while not( eof( #m)) inputcsv #m, melk1$(a), melk2$(a), melk3$(a), melk4$(a), melk5$(a), melk6(a), melk7$(a)
print melk1$(a), melk2$(a), melk3$(a), melk4$(a), melk5$(a), melk6(a), melk7$(a) a = a + 1 wend close #m
b=0
while melk7$(b) <> ca$(b) and b <3000 b = b + 1 wend
This is what I made so far, but its not working wel. What has it to do:
The milkvalue melk6$(a) must /0.2 and then * the value cc(i) off the calibration file where ca$(i) and melk77$(a) must be the same. I hope I explained well for understanding . This needs to write to a new file: print melk1$(0), melk2$(0), melk3$(0), melk4$(0), melk5$(0), using("####.#", melk6(0)/0.2*cc(0)), melk7$(0) print melk1$(1), melk2$(1), melk3$(1), melk4$(1), melk5$(1), using("####.#", melk6(1)/0.2*cc(1)), melk7$(1) print melk1$(2), melk2$(2), melk3$(2), melk4$(2), melk5$(2), using("####.#", melk6(2)/0.2*cc(2)), melk7$(2) print melk1$(3), melk2$(3), melk3$(3), melk4$(3), melk5$(3), using("####.#", melk6(3)/0.2*cc(3)), melk7$(3) print melk1$(4), melk2$(4), melk3$(4), melk4$(4), melk5$(4), using("####.#", melk6(4)/0.2*cc(4)), melk7$(4) print melk1$(5), melk2$(5), melk3$(5), melk4$(5), melk5$(5), using("####.#", melk6(5)/0.2*cc(5)), melk7$(5) And so on to 145
But I think I think to difficult, I hope there is an easier way!
|
|
|
Post by tenochtitlanuk on Dec 28, 2018 15:44:28 GMT -5
I've rewritten your code to get nearer to what I think you intend.. you had discrepancies between number of data items and names.. and it is not obvious wheter you are clear about string versus numeric data in files and their values. I've built in a loop through the data. I strongly recommend the kind of variable names I used- called 'camelCase' because it allows you to name variables in a memorable way, and the capitals show the separate parts of the name. Is the following getting towards what you want?
mainwin 63 30
open "calibratie\calibratie.txt" for input as #c open "melkteller.csv" for input as #m
M =3000 dim meterNumber( M), calibrationDate( M), calibrationValue( M)
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 "newFile.csv" for output as #fOut
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, cowNumber, recogn$, followNum, also, date, milkingTime, milkAmount, milkmeterNumber
print cowNumber, recogn$, followNum, also, date, milkingTime, milkAmount, milkmeterNumber,_ using( "####.#", milkAmount /calibrationValue( milkmeterNumber)) #fOut milkAmount /calibrationValue( milkmeterNumber) wend
close #m close #fOut print: print "Done."
|
|
|
Post by metro on Dec 28, 2018 18:50:49 GMT -5
My tweek to Johns code, If I understand the required outcome correctly mainwin 63 30
open "c:\calibratie\calibratie.txt" for input as #c open "melkteller.csv" for input as #m
M =3000 N=3000 dim meterNumber( M), calibrationDate( M), calibrationValue( M) dim cowNumber(N), recogn$(N), followNum(N), also(N), date(N), milkingTime(N), milkAmount(N), milkmeterNumber(N) 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"
a=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, cowNumber(a), recogn$(a), followNum(a), also(a), date(a), milkingTime(a), milkAmount(a), milkmeterNumber(a)
' print cowNumber(a), recogn$(a), followNum(a), also(a), date(a), milkingTime(a), milkAmount(a), milkmeterNumber(a)',_ ' using( "####.#", milkAmount(a) /calibrationValue( milkmeterNumber)) ' #fOut milkAmount /calibrationValue( milkmeterNumber) a=a+1 wend
close #m
open "newFile.csv" for output as #fOut for i=1 to i-1 CheckVal= meterNumber( i) for a=1 to a-1
if CheckVal= milkmeterNumber(a) then
print cowNumber(a),recogn$(a), followNum(a), also(a), date(a), using("####.#", ((milkingTime(a)/0.2)*calibrationValue(i))), milkAmount(a)', milkmeterNumber(a) CsvOut$=Str$(cowNumber(a));",";recogn$(a);",";Str$(followNum(a));",";Str$(also(a));",";Str$(date(a));",";Str$(((milkingTime(a)/0.2)*calibrationValue(i)));",";Str$(milkAmount(a))
#fOut CsvOut$ end if
next next
close #fOut print: print "Done."
|
|
|
Post by metro on Dec 28, 2018 20:15:53 GMT -5
Is there a bug with INPUTCSV ?, seems to not like "-" or "/" (it could be another Linux Wine issue for me), date just shows at 6 not 6-12-2018
mainwin 63 30
' open "calibratie.txt" for input as #c open "melkteller.csv" for input as #m 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, cowNumber, recogn$, followNum, also, date, milkingTime, milkAmount, milkmeterNumber print date ' print cowNumber, recogn$, followNum, also, date, milkingTime, milkAmount, milkmeterNumber wend close #m
open "melkteller.csv" for input as #m while not( eof( #m)) line input #m, Aline$
print WORD$(Aline$,5,",") wend close #m print: print "Done."
|
|
|
Post by tenochtitlanuk on Dec 29, 2018 7:51:19 GMT -5
Just change to
inputcsv #m, cowNumber, recogn$, followNum, also, date$, milkingTime, milkAmount, milkmeterNumber ... which forces it to see date as a string. Sorry, didn't notice, since date not used further..
|
|
|
Post by metro on Dec 29, 2018 7:57:53 GMT -5
Thanks John, lately I often can't see the obvious
|
|
|
Post by tenochtitlanuk on Dec 29, 2018 10:36:38 GMT -5
Me neither!!
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Dec 29, 2018 13:45:31 GMT -5
Hello tenochtitlanuk and metro, Thanks for your help!! Whats is the mean diffrence between both codes. The checkval? I tried both and both are working> I made some changes, see below. Is it possible in the output csv sort back on the follownumber? Thats easier find back some problems. Now its not the hole story!! (I am sorry, farmers made it difficult!!) The first collum off the melkteller.csv file, the cow number comes from to other files. Leftside of the milkstable and a file form the rightside of the milkstable. The melkteller.csv file has always 144 rows. 72 rows belong for the right side of the cow numbers and 72 for the left side. I will enclose a complete melkteller.csv link linkAs you see on row 72 is the last milkmeternumber 8 from there number 9 till 16 start. Milknumber 1 to 8 is the leftside and 9 to 16 is the rightside. link left filelink right fileThe files off cownumbers is not always exact 72 rows. In the old situation I fill that with this: print #1,chr$(13) where I use #1 is the left file and #2 for the right file. With line input I read till line 72 for the left file and from 73 to 144 for the right file. Then I need also this one: if cownumber$ < "1" then cownumber$ ="250" That is needed for the further proces, if there is "0" or a chr$(13) than the cownumber will be 250. Otherwise the data will be corrupt, cownumber 0 is not excist. Now is the question how can I implant this in the new situation as we made above? This is the code from Metro I use now:
mainwin 63 30
open "calibratie\calibratie.txt" for input as #c open "melkteller.csv" for input as #m
M =3000 N=3000 dim meterNumber( M), calibrationDate( M), calibrationValue( M) dim cowNumber(N), recogn$(N), followNum(N), also(N), data$(N), milkingTime$(N), milkAmount(N), milkmeterNumber(N) 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"
a=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, cowNumber(a), recogn$(a), followNum(a), also(a), data$(a), milkingTime$(a), milkAmount(a), milkmeterNumber(a)
' print cowNumber(a), recogn$(a), followNum(a), also(a), date(a), milkingTime(a), milkAmount(a), milkmeterNumber(a)',_ ' using( "####.#", milkAmount(a) /calibrationValue( milkmeterNumber)) ' #fOut milkAmount /calibrationValue( milkmeterNumber) a=a+1 wend
close #m
open "c:\melkteller\newFile.csv" for output as #fOut for i=1 to i-1 CheckVal= meterNumber( i) for a=1 to a-1
if CheckVal= milkmeterNumber(a) then
print cowNumber(a),recogn$(a), followNum(a), also(a), data$(a), milkingTime$(a), using("####.#", milkAmount(a)), using("####.#",((milkAmount(a)/0.2)*calibrationValue(i))), milkmeterNumber(a) CsvOut$=Str$(cowNumber(a));",";recogn$(a);",";Str$(followNum(a));",";Str$(also(a));",";data$(a);",";milkingTime$(a);",";Str$(((milkAmount(a)/0.2)*calibrationValue(i)));",";Str$(milkmeterNumber(a)) #fOut CsvOut$ end if
next next
close #fOut print: print "Done."
Many thanks You helped me a lot John last year also with the cow data. I haven't finished yet the project. I have lot of problems with the arduinos. They will stop working after a few time (freeze). Sometimes they work for 5 times and then a few stop working. I think it has to do with the ethernetshield. I hope I can fix it soon!!
|
|
|
Post by metro on Dec 30, 2018 4:31:42 GMT -5
I would check the output from each method, I'm not convinced I have the desired outcome, specifically this calculation Str$(((milkAmount(a)/0.2)*calibrationValue(i))) it Differs from what John arrived at. Sorting example can be found here www.diga.me.uk/filesorting.htmlthanks to tenochtitlanuk I have used an in memory SQLite db to sort on each field which I can post if you would like. I need to digest the rest of what you have posted to get my head around the merge of left and right sample data good luck
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Jan 21, 2019 15:28:07 GMT -5
Hello tenochtitlanuk and metro,
Sorry for the late responce!! I made something all togehther. I used the calculation from tenochtitlanuk. That was better for me for the sorting. If you run the code you see what happend. In this example a few files are generated, in the normal situation they are already on the computer. The last file "melkteller.txt" is the file I need for further proces. Here you see the left and the right (what is normally cownumbers) I hope I can make it clear to you this way.
Best regards Jack
[test] open "calibratie.txt" for output as #cal print #cal, "1,20122018,0.2" print #cal, "2,20122018,0.2" print #cal, "3,20122018,0.2" print #cal, "4,20122018,0.2" print #cal, "5,20122018,0.2" print #cal, "6,20122018,0.2" print #cal, "7,20122018,0.2" print #cal, "8,20122018,0.101" print #cal, "9,20122018,0.2" print #cal, "10,20122018,0.2" print #cal, "11,20122018,0.2" print #cal, "12,20122018,0.2" print #cal, "13,20122018,0.2" print #cal, "14,20122018,0.2" print #cal, "15,20122018,0.2" print #cal, "16,20122018,0.2" close #cal
open "melkteller.csv" for output as #csv print #csv,"" print #csv,"" print #csv,"krokus,1,250,15-1-20019,7:44,12.4,1," print #csv,"Krokus,2,250,15-1-20019,7:44,18.6,2," print #csv,"Krokus,3,250,15-1-20019,7:44,20.6,3," print #csv,"Krokus,4,250,15-1-20019,7:45,15.0,4," print #csv,"Krokus,5,250,15-1-20019,7:44,15.4,5," print #csv,"Krokus,6,250,15-1-20019,7:44,18.4,6," print #csv,"Krokus,7,250,15-1-20019,7:44,12.0,7," print #csv,"Krokus,8,250,15-1-20019,7:44,33.0,8," print #csv,"Krokus,9,250,15-1-20019,8:10,18.2,1," print #csv,"Krokus,10,250,15-1-20019,8:9,19.4,2," print #csv,"Krokus,11,250,15-1-20019,8:9,15.2,3," print #csv,"Krokus,12,250,15-1-20019,8:10,6.6,4," print #csv,"Krokus,13,250,15-1-20019,8:9,22.0,5," print #csv,"Krokus,14,250,15-1-20019,8:9,16.0,6," print #csv,"Krokus,15,250,15-1-20019,8:9,17.0,7," print #csv,"Krokus,16,250,15-1-20019,8:9,33.8,8," print #csv,"Krokus,17,250,15-1-20019,8:28,9.8,1," print #csv,"Krokus,18,250,15-1-20019,8:28,15.0,2," print #csv,"Krokus,19,250,15-1-20019,8:28,19.2,3," print #csv,"Krokus,20,250,15-1-20019,8:28,16.2,4," print #csv,"Krokus,21,250,15-1-20019,8:28,7.2,5," print #csv,"Krokus,22,250,15-1-20019,8:28,24.6,6," print #csv,"Krokus,23,250,15-1-20019,8:28,10.4,7," print #csv,"Krokus,24,250,15-1-20019,8:28,44.2,8," print #csv,"Krokus,25,250,15-1-20019,8:46,23.4,1," print #csv,"Krokus,26,250,15-1-20019,8:47,12.6,2," print #csv,"Krokus,27,250,15-1-20019,8:46,20.4,3," print #csv,"Krokus,28,250,15-1-20019,8:46,21.8,4," print #csv,"Krokus,29,250,15-1-20019,8:47,14.6,5," print #csv,"Krokus,30,250,15-1-20019,8:47,16.4,6," print #csv,"Krokus,31,250,15-1-20019,8:47,15.4,7," print #csv,"Krokus,32,250,15-1-20019,8:44,37.4,8," print #csv,"Krokus,33,250,15-1-20019,9:0,14.0,1," print #csv,"Krokus,34,250,15-1-20019,9:0,22.8,2," print #csv,"Krokus,35,250,15-1-20019,9:1,15.8,3," print #csv,"Krokus,36,250,15-1-20019,9:1,22.2,4," print #csv,"Krokus,37,250,15-1-20019,9:1,12.4,5," print #csv,"Krokus,38,250,15-1-20019,9:1,18.6,6," print #csv,"Krokus,39,250,15-1-20019,9:2,14.8,7," print #csv,"Krokus,40,250,15-1-20019,9:2,37.2,8," print #csv,"Krokus,41,250,15-1-20019,9:21,17.6,1," print #csv,"Krokus,42,250,15-1-20019,9:20,9.6,2," print #csv,"Krokus,43,250,15-1-20019,9:21,13.2,3," print #csv,"Krokus,44,250,15-1-20019,9:21,14.2,4," print #csv,"Krokus,45,250,15-1-20019,9:21,11.8,5," print #csv,"Krokus,46,250,15-1-20019,9:21,20.6,6," print #csv,"Krokus,47,250,15-1-20019,9:22,10.6,7," print #csv,"Krokus,48,250,15-1-20019,9:22,37.8,8," print #csv,"Krokus,49,250,15-1-20019,9:36,13.2,1," print #csv,"Krokus,50,250,15-1-20019,9:37,8.2,2," print #csv,"Krokus,51,250,15-1-20019,9:37,15.2,3," print #csv,"Krokus,52,250,15-1-20019,9:37,6.4,4," print #csv,"Krokus,53,250,15-1-20019,9:37,16.6,5," print #csv,"Krokus,54,250,15-1-20019,9:37,14.8,6," print #csv,"Krokus,55,250,15-1-20019,9:38,17.4,7," print #csv,"Krokus,56,250,15-1-20019,9:38,51.0,8," print #csv,"Krokus,57,250,15-1-20019,7:36,0 ,1," print #csv,"Krokus,58,250,15-1-20019,9:55,19.4,2," print #csv,"Krokus,59,250,15-1-20019,9:55,16.0,3," print #csv,"Krokus,60,250,15-1-20019,9:55,12.6,4," print #csv,"Krokus,61,250,15-1-20019,9:55,17.8,5," print #csv,"Krokus,62,250,15-1-20019,7:36,0 ,6," print #csv,"Krokus,63,250,15-1-20019,9:55,21.8,7," print #csv,"Krokus,64,250,15-1-20019,7:36,0 ,8," print #csv,"Krokus,65,250,15-1-20019,7:36,0 ,1," print #csv,"Krokus,66,250,15-1-20019,7:36,0 ,2," print #csv,"Krokus,67,250,15-1-20019,10:12,4.8,3," print #csv,"Krokus,68,250,15-1-20019,7:36,0 ,4," print #csv,"Krokus,69,250,15-1-20019,7:36,0 ,5," print #csv,"Krokus,70,250,15-1-20019,7:36,0 ,6," print #csv,"Krokus,71,250,15-1-20019,7:36,0 ,7," print #csv,"Krokus,72,250,15-1-20019,7:36,0 ,8," print #csv,"Krokus,73,250,15-1-20019,7:41,21.6,9," print #csv,"Krokus,74,250,15-1-20019,7:41,16.8,10," print #csv,"Krokus,75,250,15-1-20019,7:37,17.8,11," print #csv,"Krokus,76,250,15-1-20019,7:37,18.8,12," print #csv,"Krokus,77,250,15-1-20019,7:41,12.0,13," print #csv,"Krokus,78,250,15-1-20019,7:39,24.8,14," print #csv,"Krokus,79,250,15-1-20019,7:41,21.8,15," print #csv,"Krokus,80,250,15-1-20019,7:41,16.0,16," print #csv,"Krokus,81,250,15-1-20019,8:5,22.4,9," print #csv,"Krokus,82,250,15-1-20019,8:5,15.8,10," print #csv,"Krokus,83,250,15-1-20019,8:6,21.8,11," print #csv,"Krokus,84,250,15-1-20019,8:5,21.0,12," print #csv,"Krokus,85,250,15-1-20019,8:5,22.6,13," print #csv,"Krokus,86,250,15-1-20019,8:6,16.0,14," print #csv,"Krokus,87,250,15-1-20019,8:6,17.0,15," print #csv,"Krokus,88,250,15-1-20019,8:6,14.6,16," print #csv,"Krokus,89,250,15-1-20019,8:24,12.0,9," print #csv,"Krokus,90,250,15-1-20019,8:22,15.2,10," print #csv,"Krokus,91,250,15-1-20019,8:23,13.4,11," print #csv,"Krokus,92,250,15-1-20019,8:23,15.2,12," print #csv,"Krokus,93,250,15-1-20019,8:23,22.0,13," print #csv,"Krokus,94,250,15-1-20019,8:24,12.8,14," print #csv,"Krokus,95,250,15-1-20019,8:25,8.4,15," print #csv,"Krokus,96,250,15-1-20019,8:25,18.0,16," print #csv,"Krokus,97,250,15-1-20019,8:40,15.8,9," print #csv,"Krokus,98,250,15-1-20019,8:40,14.0,10," print #csv,"Krokus,99,250,15-1-20019,8:40,14.8,11," print #csv,"Krokus,100,250,15-1-20019,8:41,24.2,12," print #csv,"Krokus,101,250,15-1-20019,8:42,15.2,13," print #csv,"Krokus,102,250,15-1-20019,8:42,11.8,14," print #csv,"Krokus,103,250,15-1-20019,8:41,24.6,15," print #csv,"Krokus,104,250,15-1-20019,8:42,22.0,16," print #csv,"krokus,105,250,15-1-20019,9:5,17.0,9," print #csv,"Krokus,106,250,15-1-20019,9:6,17.2,10," print #csv,"Krokus,107,250,15-1-20019,9:6,12.6,11," print #csv,"Krokus,108,250,15-1-20019,9:6,22.4,12," print #csv,"Krokus,109,250,15-1-20019,9:5,14.6,13," print #csv,"Krokus,110,250,15-1-20019,9:5,20.6,14," print #csv,"Krokus,111,250,15-1-20019,9:6,19.4,15," print #csv,"Krokus,112,250,15-1-20019,9:6,13.0,16," print #csv,"Krokus,113,250,15-1-20019,9:23,5.0,9," print #csv,"Krokus,114,250,15-1-20019,9:24,14.0,10," print #csv,"Krokus,115,250,15-1-20019,9:21,9.4,11," print #csv,"Krokus,116,250,15-1-20019,9:24,25.2,12," print #csv,"Krokus,117,250,15-1-20019,9:25,11.0,13," print #csv,"Krokus,118,250,15-1-20019,9:24,21.8,14," print #csv,"Krokus,119,250,15-1-20019,9:25,6.6,15," print #csv,"Krokus,120,250,15-1-20019,9:25,16.2,16," print #csv,"Krokus,121,250,15-1-20019,9:40,11.4,9," print #csv,"Krokus,122,250,15-1-20019,9:41,11.2,10," print #csv,"Krokus,123,250,15-1-20019,9:41,17.8,11," print #csv,"Krokus,124,250,15-1-20019,9:38,12.0,12," print #csv,"Krokus,125,250,15-1-20019,9:41,15.4,13," print #csv,"Krokus,126,250,15-1-20019,9:41,26.4,14," print #csv,"Krokus,127,250,15-1-20019,9:42,22.4,15," print #csv,"Krokus,128,250,15-1-20019,9:42,16.6,16," print #csv,"Krokus,129,250,15-1-20019,7:36,0 ,9," print #csv,"Krokus,130,250,15-1-20019,9:53,14.0,10," print #csv,"Krokus,131,250,15-1-20019,9:53,9.4,11," print #csv,"Krokus,132,250,15-1-20019,9:51,13.8,12," print #csv,"Krokus,133,250,15-1-20019,10:1,2.4,13," print #csv,"Krokus,134,250,15-1-20019,9:53,15.6,14," print #csv,"Krokus,135,250,15-1-20019,7:36,0 ,15," print #csv,"Krokus,136,250,15-1-20019,7:36,0 ,16," print #csv,"Krokus,137,250,15-1-20019,10:6,14.8,9," print #csv,"Krokus,138,250,15-1-20019,10:6,17.2,10," print #csv,"Krokus,139,250,15-1-20019,10:6,14.0,11," print #csv,"Krokus,140,250,15-1-20019,7:36,0 ,12," print #csv,"Krokus,141,250,15-1-20019,7:36,0 ,13," print #csv,"Krokus,142,250,15-1-20019,7:36,0 ,14," print #csv,"Krokus,143,250,15-1-20019,7:36,0 ,15," print #csv,"Krokus,144,250,15-1-20019,7:36,0 ,16," close #csv
[inlees]
open "calibratie.txt" for input as #c open "melkteller.csv" for input as #4 open "melkteller1.txt" for output as #3
OPEN "links.txt" FOR output AS #5 OPEN "rechts.txt" FOR output AS #6 for a =1 to 75 print #5,"left" print #6,"right" 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 "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 "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 "melkteller.txt" for append as #fOut open "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)) < 10 then melkhoeveel$(j)= using( "#.#",milkAmount(j)/0.2*calibrationValue(milkmeterNumber(j))) 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."
|
|
|
Post by metro on Jan 21, 2019 19:21:59 GMT -5
G'day Jack, look at the 13th post (mine). not sure if any of that will help! The attached MELK.zip (in that post) should have all the code and the required Dll if my memory serves me correctly
metro
PS the easiest way to get to post 13 ... click the link above then press "CTRL+F" type in MELK then press enter (that works in firefox) MilkAnotherListView.bas was the last code I updated to edit or delete data
|
|
|
Post by knoware on Jan 21, 2019 20:48:44 GMT -5
If you are lazy like me you may want to use ionSQL to do the work for you. You create a database and table, load the csv file. Using the [GenProg] button it creates a LB program that lets you: 1. Add, Change, Delete records. 2. List in any sequence - ascending or descending 3. List pages with [Next] or [Prev] page or go directly to any page. 4. Drill down with a wild card (*) search on multiple fields as: -- xx* = field begins xx -- *xx = field ends with xx -- *xx* = field contains xx
I created a event talbe that looked like this:
CREATE TABLE event ( cowNum INTEGER(3), milkFile VARCHAR(6), filNum INTEGER(3), also INTEGER(3), eventDate DATE, milkTime TIME, milkAmt DECIMAL(5,1), milkMeter INTEGER(3) );
Just another way if you are interested... Dan
|
|
|
Post by metro on Jan 21, 2019 21:28:41 GMT -5
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Mar 9, 2019 6:49:00 GMT -5
Hi Metro and knoware, Thanks for that. But I think thats much to far for me for understanding. I am a farmer Haha. I wil try it if I will come out off it! But many thanks for helping! Jack
And to be honest, english is not my first langaue. And if it is technical its not easy to understand it all in one time. But we go one and will manage it. It will take some more time!
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Mar 9, 2019 6:56:36 GMT -5
I have this two files running next to each other.
First file received data (cownumber) from a bluetooth reader ands send that to the second file. There is de data collected which belongs to that cownumber and send it over UDP to an arduino with display where I can see the information. Now I want to make this two to one. By trying this I get the first problem by copying the function from the second file under the fuction in the first file. Is it not so simple to do?
Yhanks,
Jack
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 close #1 close #2 'OPEN "com6:9600,n,8,1,cd0,cs0,ds0,op0,rs,rb2048" for random as #stuur 'OPEN "c:\melkteller\uniform.txt" FOR INPUT AS #uni OPEN "com12:9600,n,8,1,CD0,CS0,DS0,OP0" FOR OUTPUT AS #stuur OPEN "com14:9600,n,8,1,CD0,CS0,DS0,OP0" FOR OUTPUT AS #stuur1 run "c:\melkteller\unidata.exe"
[begin] print "versie 1.1" print "rechts of links of stoppen" kant$=readADR$(ADR$) print kant$ kant$ = TRIM$(kant$) if kant$ = "linksvoor" then goto [linksvoor] end if if kant$ = "rechtsvoor" then goto [rechtsvoor] end if if kant$ = "linksachter" then goto [linksachter] end if if kant$ = "rechtsachter" then goto [rechtsachter] end if if kant$ = "stoppen" then print #stuur, "ST" goto [inlees] end if if kant$ > "1" then goto [begin] end if
[linksvoor] print "linksvoor" print #stuur, "LV" result1$=readADR$(ADR$) result1$ = TRIM$(result1$) 'for i = 1 to 130 'if result1$ = aa$(i) then if result1$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result1$ = "linksvoor" then goto [linksvoor] if result1$ = "linksachter" then goto [linksachter] print #stuur, result1$ print #stuur1, "192.168.2.201" 'end if 'next i print result1$ result2$=readADR$(ADR$) result2$ = TRIM$(result2$) 'for i = 1 to 130 'if result2$ = aa$(i) then if result2$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result2$ = "linksvoor" then goto [linksvoor] if result2$ = "linksachter" then goto [linksachter] print #stuur, result2$ print #stuur1, "192.168.2.202" 'end if 'next i print result2$ result3$=readADR$(ADR$) result3$ = TRIM$(result3$) 'for i = 1 to 130 'if result3$ = aa$(i) then if result3$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result3$ = "linksvoor" then goto [linksvoor] if result3$ = "linksachter" then goto [linksachter] print #stuur, result3$ print #stuur1, "192.168.2.203" 'end if 'next i print result3$ result4$=readADR$(ADR$) result4$ = TRIM$(result4$) 'for i = 1 to 130 'if result4$ = aa$(i) then if result4$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result4$ = "linksvoor" then goto [linksvoor] if result4$ = "linksachter" then goto [linksachter] print #stuur, result4$ print #stuur1, "192.168.2.204" 'end if 'next i print result4$ result5$=readADR$(ADR$) result5$ = TRIM$(result5$) 'for i = 1 to 130 'if result5$ = aa$(i) then if result5$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result5$ = "linksvoor" then goto [linksvoor] if result5$ = "linksachter" then goto [linksachter] print #stuur, result5$ print #stuur1, "192.168.2.205" 'end if 'next i print result5$ result6$=readADR$(ADR$) result6$ = TRIM$(result6$) 'for i = 1 to 130 'if result6$ = aa$(i) then if result6$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result6$ = "linksvoor" then goto [linksvoor] if result6$ = "linksachter" then goto [linksachter] print #stuur, result6$ print #stuur1, "192.168.2.206" ' end if 'next i print result6$ result7$=readADR$(ADR$) result7$ = TRIM$(result7$) 'for i = 1 to 130 'if result7$ = aa$(i) then if result7$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result7$ = "linksvoor" then goto [linksvoor] if result7$ = "linksachter" then goto [linksachter] print #stuur, result7$ print #stuur1, "192.168.2.207" 'end if 'next i print result7$ result8$=readADR$(ADR$) result8$ = TRIM$(result8$) 'for i = 1 to 130 'if result8$ = aa$(i) then if result8$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result8$ = "linksvoor" then goto [linksvoor] if result8$ = "linksachter" then goto [linksachter] print #stuur, result8$ print #stuur1, "192.168.2.208" 'end if 'next i OPEN "c:\melkteller\links.txt" FOR append AS #8 print result8$ print #8, result1$ print #8, result2$ print #8, result3$ print #8, result4$ print #8, result5$ print #8, result6$ print #8, result7$ print #8, result8$ close #8 goto [begin]
[linksachter] print "linksachter" print #stuur, "LA" result8$=readADR$(ADR$) result8$ = TRIM$(result8$) ' for i = 1 to 130 'if result8$ = aa$(i) then if result8$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result8$ = "linksvoor" then goto [linksvoor] if result8$ = "linksachter" then goto [linksachter] print #stuur, result8$ print #stuur1, "192.168.2.208" 'end if 'next i print result8$ result7$=readADR$(ADR$) result7$ = TRIM$(result7$) 'for i = 1 to 130 'if result7$ = aa$(i) then if result7$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result7$ = "linksvoor" then goto [linksvoor] if result7$ = "linksachter" then goto [linksachter] print #stuur, result7$ print #stuur1, "192.168.2.207" 'end if 'next i print result7$ result6$=readADR$(ADR$) result6$ = TRIM$(result6$) 'for i = 1 to 130 'if result6$ = aa$(i) then if result6$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result6$ = "linksvoor" then goto [linksvoor] if result6$ = "linksachter" then goto [linksachter] print #stuur, result6$ print #stuur1, "192.168.2.206" 'end if 'next i print result6$ result5$=readADR$(ADR$) result5$ = TRIM$(result5$) 'for i = 1 to 130 'if result5$ = aa$(i) then if result5$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result5$ = "linksvoor" then goto [linksvoor] if result5$ = "linksachter" then goto [linksachter] print #stuur, result5$ print #stuur1, "192.168.2.205" 'end if 'next i print result5$ result4$=readADR$(ADR$) result4$ = TRIM$(result4$) 'for i = 1 to 130 'if result4$ = aa$(i) then if result4$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result4$ = "linksvoor" then goto [linksvoor] if result4$ = "linksachter" then goto [linksachter] print #stuur, result4$ print #stuur1, "192.168.2.204" 'end if 'next i print result4$ result3$=readADR$(ADR$) result3$ = TRIM$(result3$) 'for i = 1 to 130 'if result3$ = aa$(i) then if result3$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result3$ = "linksvoor" then goto [linksvoor] if result3$ = "linksachter" then goto [linksachter] print #stuur, result3$ print #stuur1, "192.168.2.203" 'end if 'next i print result3$ result2$=readADR$(ADR$) result2$ = TRIM$(result2$) 'for i = 1 to 130 'if result2$ = aa$(i) then if result2$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result2$ = "linksvoor" then goto [linksvoor] if result2$ = "linksachter" then goto [linksachter] print #stuur, result2$ print #stuur1, "192.168.2.202" 'end if 'next i print result2$ result1$=readADR$(ADR$) result1$ = TRIM$(result1$) 'for i = 1 to 130 'if result1$ = aa$(i) then if result1$ = "resetdisplay" then print #stuur1, "192.168.2.201" if result1$ = "linksvoor" then goto [linksvoor] if result1$ = "linksachter" then goto [linksachter] print #stuur, result1$ print #stuur1, "192.168.2.201" 'end if 'next i OPEN "c:\melkteller\links.txt" FOR append AS #8 print result1$ print #8, result1$ print #8, result2$ print #8, result3$ print #8, result4$ print #8, result5$ print #8, result6$ print #8, result7$ print #8, result8$ close #8 goto [begin]
[rechtsvoor] print "rechtsvoor" print #stuur, "RV" resultR1$=readADR$(ADR$) resultR1$ = TRIM$(resultR1$) 'for i = 1 to 130 'if resultR1$ = aa$(i) then if resultR1$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR1$ = "rechtsvoor" then goto [rechtsvoor] if resultR1$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR1$ print #stuur1, "192.168.2.209" 'end if 'next i print resultR1$ resultR2$=readADR$(ADR$) resultR2$ = TRIM$(resultR2$) 'for i = 1 to 130 'if resultR2$ = aa$(i) then if resultR2$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR2$ = "rechtsvoor" then goto [rechtsvoor] if resultR2$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR2$ print #stuur1, "192.168.2.210" 'end if 'next i print resultR2$ resultR3$=readADR$(ADR$) resultR3$ = TRIM$(resultR3$) 'for i = 1 to 130 'if resultR3$ = aa$(i) then if resultR3$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR3$ = "rechtsvoor" then goto [rechtsvoor] if resultR3$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR3$ print #stuur1, "192.168.2.211" 'end if 'next i print resultR3$ resultR4$=readADR$(ADR$) resultR4$ = TRIM$(resultR4$) 'for i = 1 to 130 'if resultR4$ = aa$(i) then if resultR4$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR4$ = "rechtsvoor" then goto [rechtsvoor] if resultR4$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR4$ print #stuur1, "192.168.2.212" 'end if 'next i print resultR4$ resultR5$=readADR$(ADR$) resultR5$ = TRIM$(resultR5$) 'for i = 1 to 130 'if resultR5$ = aa$(i) then if resultR5$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR5$ = "rechtsvoor" then goto [rechtsvoor] if resultR5$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR5$ print #stuur1, "192.168.2.213" 'end if 'next i print resultR5$ resultR6$=readADR$(ADR$) resultR6$ = TRIM$(resultR6$) 'for i = 1 to 130 'if resultR6$ = aa$(i) then if resultR6$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR6$ = "rechtsvoor" then goto [rechtsvoor] if resultR6$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR6$ print #stuur1, "192.168.2.214" 'end if 'next i print resultR6$ resultR7$=readADR$(ADR$) resultR7$ = TRIM$(resultR7$) 'for i = 1 to 130 'if resultR7$ = aa$(i) then if resultR7$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR7$ = "rechtsvoor" then goto [rechtsvoor] if resultR7$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR7$ print #stuur1, "192.168.2.215" 'end if 'next i print resultR7$ resultR8$=readADR$(ADR$) resultR8$ = TRIM$(resultR8$) 'for i = 1 to 130 'if resultR8$ = aa$(i) then if resultR8$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR8$ = "rechtsvoor" then goto [rechtsvoor] if resultR8$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR8$ print #stuur1, "192.168.2.216" 'end if 'next i OPEN "c:\melkteller\rechts.txt" FOR append AS #9 print resultR8$ print #9, resultR1$ print #9, resultR2$ print #9, resultR3$ print #9, resultR4$ print #9, resultR5$ print #9, resultR6$ print #9, resultR7$ print #9, resultR8$ close #9 goto [begin]
[rechtsachter] print "rechtsachter" print #stuur, "RA" resultR8$=readADR$(ADR$) resultR8$ = TRIM$(resultR8$) 'for i = 1 to 130 'if resultR8$ = aa$(i) then if resultR8$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR8$ = "rechtsvoor" then goto [rechtsvoor] if resultR8$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR8$ print #stuur1, "192.168.2.216" 'end if 'next i print resultR8$ resultR7$=readADR$(ADR$) resultR7$ = TRIM$(resultR7$) 'for i = 1 to 130 'if resultR7$ = aa$(i) then if resultR7$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR7$ = "rechtsvoor" then goto [rechtsvoor] if resultR7$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR7$ print #stuur1, "192.168.2.215" 'end if 'next i print resultR7$ resultR6$=readADR$(ADR$) resultR6$ = TRIM$(resultR6$) 'for i = 1 to 130 'if resultR6$ = aa$(i) then if resultR6$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR6$ = "rechtsvoor" then goto [rechtsvoor] if resultR6$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR6$ print #stuur1, "192.168.2.214" 'end if 'next i print resultR6$ resultR5$=readADR$(ADR$) resultR5$ = TRIM$(resultR5$) 'for i = 1 to 130 'if resultR5$ = aa$(i) then if resultR5$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR5$ = "rechtsvoor" then goto [rechtsvoor] if resultR5$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR5$ print #stuur1, "192.168.2.213" 'end if 'next i print resultR5$ resultR4$=readADR$(ADR$) resultR4$ = TRIM$(resultR4$) 'for i = 1 to 130 'if resultR4$ = aa$(i) then if resultR4$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR4$ = "rechtsvoor" then goto [rechtsvoor] if resultR4$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR4$ print #stuur1, "192.168.2.212" 'end if 'next i print resultR4$ resultR3$=readADR$(ADR$) resultR3$ = TRIM$(resultR3$) 'for i = 1 to 130 'if resultR3$ = aa$(i) then if resultR3$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR3$ = "rechtsvoor" then goto [rechtsvoor] if resultR3$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR3$ print #stuur1, "192.168.2.211" 'end if 'next i print resultR3$ resultR2$=readADR$(ADR$) resultR2$ = TRIM$(resultR2$) 'for i = 1 to 130 'if resultR2$ = aa$(i) then if resultR2$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR2$ = "rechtsvoor" then goto [rechtsvoor] if resultR2$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR2$ print #stuur1, "192.168.2.210" 'end if 'next i print resultR2$ resultR1$=readADR$(ADR$) resultR1$ = TRIM$(resultR1$) 'for i = 1 to 130 'if resultR1$ = aa$(i) then if resultR1$ = "resetdisplay" then print #stuur1, "192.168.2.209" if resultR1$ = "rechtsvoor" then goto [rechtsvoor] if resultR1$ = "rechtsachter" then goto [rechtsachter] print #stuur, resultR1$ print #stuur1, "192.168.2.209" 'end if 'next i OPEN "c:\melkteller\rechts.txt" FOR append AS #9 print resultR1$ print #9, resultR1$ print #9, resultR2$ print #9, resultR3$ print #9, resultR4$ print #9, resultR5$ print #9, resultR6$ print #9, resultR7$ print #9, resultR8$ close #9 goto [begin]
[inlees] 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)) < 10 then melkhoeveel$(j)= using( "#.#",milkAmount(j)/0.2*calibrationValue(milkmeterNumber(j))) 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] ' save Log$ incase of bugs or problems Open "LogBook" for output as #lg print #lg,Log$ close #lg close #com close #stuur close #stuur1 '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
'run "c:\melkteller\herkenning\inlees.bat" 'TIMER 3000, [null] 'WAIT '[null] 'timer 0
open "WS2_32" for DLL as #winsock open "com13:9600,n,8,1," for input as #com open "com15:9600,n,8,1," for input as #com1
dim a$(3000), b$(3000), c$(3000), d$(3000), e$(3000), f$(3000), g$(3000) ' 14 fields dim h$(3000), i$(3000), j$(3000), k$(3000), l$(3000), m$(3000), n$(3000)
dim voera$(3000), voerb$(3000), voerc$(3000), voerd$(3000), voere$(3000), voerf$(3000), voerh$(3000), voerg$(3000) dim voeri$(3000), voerj$(3000), voerk$(3000), voerl$(3000), voerm$(3000), voern$(3000), voero$(3000), voerp$(3000)' 16 fields
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) '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) '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) i =i +1 wend close #voer goto [verstuur]
[verstuur]
koenr$=readADR$(ADR$) koenr$ = TRIM$(koenr$) 'input "koenummer:"; koenr$ print koenr$ 'input "ip nummer:"; ipnr$ if koenr$ = "LA" goto [resetlinks] if koenr$ = "LV" goto [resetlinks] if koenr$ = "RA" goto [resetrechts] if koenr$ = "RV" goto [resetrechts] if koenr$ = "ST" goto [end] ipnr$=readADR1$(ADR1$) 'koenr$ = TRIM$(koenr$) ipnr$ = TRIM$(ipnr$) print ipnr$ if ipnr$ = "LA" goto [resetlinks] if ipnr$ = "LV" goto [resetlinks] if ipnr$ = "RA" goto [resetrechts] if ipnr$ = "RV" goto [resetrechts] if ipnr$ = "ST" goto [end]
i =0 while koenr$ <> voera$( i) and i <3000 i =i +1 wend if i <3000 then print "Found in voera$"
j =0 while koenr$ <> a$( j) and j <3000 j =j +1 wend if j <3000 then print "Found in a$()"
if j$(j) = "Geinsemineerd" then j$(j) = "Geins" if j$(j) = "Bewust gust" then j$(j) = "Bew.gust" if i =3000 or j =3000 then print ok=UDPsend(ipnr$, 12080, ";"+koenr$+";;;;;;;;;;;;;;;;;;;;;") : goto [verstuur]
if val( voerd$(i)) <>0 then percentage =100 *(val( voerd$(i)) -val( voerc$(i)) ) /val( voerd$(i))
print percentage; " shown as a raw decimal number." print using( "###", percentage); "% with decimal parts suppressed."
opname = (val( voerd$( i)) -val( voerc$( i))) if j$(j) = "Geinsemineerd" then j$(j) = "Geins" if j$(j) = "Bewust gust" then j$(j) = "Bew.gust" percentage$ = Using("###", percentage)
m = 0 for m = 1 to 10 ok=UDPsend(ipnr$, 12080, ";"+a$(j)+";Vader: ;"+l$(j)+";Klfdt: ;"+k$(j)+"("+g$(j)+")("+c$(j)+");;;Status:;"+j$(j)+" ("+h$(j)+")("+i$(j)+");Voer; "+voerd$(i)+"/"+str$(opname)+" "+percentage$+"%;Mlk305:;"+m$(j)+" (LW"+n$(j)+");V/E: ;"+e$(j)+" "+f$(j)+";Cel: ;"+d$(j)+";;;Apart:;"+b$(j)+";;;;;") print ipnr$,";"+a$(j)+";Vader: ;"+l$(j)+";Klfdt: ;"+k$(j)+"("+g$(j)+")("+c$(j)+");;;Status:;"+j$(j)+" ("+h$(j)+")("+i$(j)+");Voer; "+voerd$(i)+"/"+str$(opname)+" "+percentage$+"%;Mlk305:;"+m$(j)+" (LW"+n$(j)+");V/E: ;"+e$(j)+" "+f$(j)+";Cel: ;"+d$(j)+";;;Apart:;"+b$(j)+";;;;;" next m else if j$(j) = "Geinsemineerd" then j$(j) = "Geins" if j$(j) = "Bewust gust" then j$(j) = "Bew.gust" m = 0 for m = 1 to 10 ok=UDPsend(ipnr$, 12080, ";"+a$(j)+";Vader: ;"+l$(j)+";Klfdt: ;"+k$(j)+"("+g$(j)+")("+c$(j)+");;;Status:;"+j$(j)+" ("+h$(j)+")("+i$(j)+");Voer; geen;Mlk305:;"+m$(j)+" (LW"+n$(j)+");V/E: ;"+e$(j)+" "+f$(j)+";Cel: ;"+d$(j)+";;;Apart:;"+b$(j)+";;;;;") print "Invalid operation- voerd$ =0" print ipnr$,";"+a$(j)+";Vader: ;"+l$(j)+";Klfdt: ;"+k$(j)+"("+g$(j)+")("+c$(j)+");;;Status:;"+j$(j)+" ("+h$(j)+")("+i$(j)+");Voer; geen;Mlk305:;"+m$(j)+" (LW"+n$(j)+");V/E: ;"+e$(j)+" "+f$(j)+";Cel: ;"+d$(j)+";;;Apart:;"+b$(j)+";;;;;" next m end if
print a$( j), voera$( i), l$( j), voerb$( i)
print koenr$; " was found in line "; i; " of voera$ array" print " and in line "; j; " of a$ array." print "Done" 'close #winsock 'close #com 'close #com1
goto [verstuur]
[resetlinks] m = 0 for m = 1 to 10 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, ";;;;;;;;;;;;;;;;;;;;;;") 'close #winsock 'close #com 'close #com1 next m goto [verstuur]
[resetrechts] m = 0 for m = 1 to 10 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, ";;;;;;;;;;;;;;;;;;;;;;") 'close #winsock 'close #com 'close #com1 next m goto [verstuur]
[end] close #winsock close #com close #com1 end
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 readADR$(board$) while lof(#com) < 1 ' the ADR always sends back 3 digits wend readADR$ = input$(#com,lof(#com)) end function
function readADR1$(board1$) while lof(#com1) < 13 ' the ADR always sends back 3 digits wend readADR1$ = input$(#com1,lof(#com1)) end function
|
|