Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2018-08-03 22:44:56 +02:00
54 changed files with 179101 additions and 6 deletions
+56
View File
@@ -0,0 +1,56 @@
[id]
idxMacchina = 2010
[web]
URLBASE = http://192.168.51.77/MP/IO/IOB/input/
URLALIVE = http://192.168.51.77/MP/IO/IOB
URLENABLED = http://192.168.51.77/MP/IO/IOB/enabled/
URLADV1 = ?valore=
URLREBO = http://192.168.51.77/MP/IO/sendReboot.aspx?idxMacchina=
[time]
SAMPLETIME = 0.05
TIMEOUTSHORT = 0.30
TIMEOUTLONG = 50
SENDURLTIME = 0.15
NMAXSEND = 5
[log]
LOGLEVEL = 10
LOGFILE = logfile.txt
LOGREBO = logReboot.txt
[comm]
port = /dev/ttyAMA0
[blink]
MAX_COUNTER_BLINK = 30
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
[invert]
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
[filter]
MAX_COUNTER_FILTER = 10
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
+56
View File
@@ -0,0 +1,56 @@
[id]
idxMacchina = 2010
[web]
URLBASE = http://192.168.51.77/MP/IO/IOB/input/
URLALIVE = http://192.168.51.77/MP/IO/IOB
URLENABLED = http://192.168.51.77/MP/IO/IOB/enabled/
URLADV1 = ?valore=
URLREBO = http://192.168.51.77/MP/IO/sendReboot.aspx?idxMacchina=
[time]
SAMPLETIME = 0.05
TIMEOUTSHORT = 0.30
TIMEOUTLONG = 50
SENDURLTIME = 0.15
NMAXSEND = 5
[log]
LOGLEVEL = 10
LOGFILE = logfile.txt
LOGREBO = logReboot.txt
[comm]
port = /dev/ttyAMA0
[blink]
MAX_COUNTER_BLINK = 30
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
[invert]
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
[filter]
MAX_COUNTER_FILTER = 10
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
File diff suppressed because it is too large Load Diff
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
/usr/bin/python /home/pi/steamware/readParallela.py
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
/usr/bin/python /home/steamware/readSeriale.py
+701
View File
@@ -0,0 +1,701 @@
20170207110000000#1#1912
20170207110001000#41#1913
20170207110001200#41#1914
20170207110017000#1#1915
20170207110018000#1#1916
20170207110019000#23#1917
20170207110020000#23#1918
20170207110033000#9#1919
20170207110033200#9#1920
20170207110034000#49#1921
20170207110034200#49#1922
20170207110034400#9#1923
20170207110034600#9#1924
20170207110036000#23#1925
20170207110036200#63#1926
20170207110037000#23#1927
20170207110037200#23#1928
20170207110038000#63#1929
20170207110038200#23#1930
20170207110038400#23#1931
20170207110041000#9#1932
20170207110041200#9#1933
20170207110042000#49#1934
20170207110042200#49#1935
20170207110043000#63#1936
20170207110043200#63#1937
20170207110045000#41#1938
20170207110046000#41#1939
20170207110135000#41#1940
20170207110226000#41#1941
20170207110316000#41#1942
20170207110322000#1#1943
20170207110323000#1#1944
20170207110324000#23#1945
20170207110325000#23#1946
20170207110347000#9#1947
20170207110348000#9#1948
20170207110348200#49#1949
20170207110348400#49#1950
20170207110348600#63#1951
20170207110349000#63#1952
20170207110351000#41#1953
20170207110352000#41#1954
20170207110416000#1#1955
20170207110417000#1#1956
20170207110418000#23#1957
20170207110419000#23#1958
20170207110435000#9#1959
20170207110435200#9#1960
20170207110436000#49#1961
20170207110436200#49#1962
20170207110436400#63#1963
20170207110437000#63#1964
20170207110439000#41#1965
20170207110439200#41#1966
20170207110515000#1#1967
20170207110515200#1#1968
20170207110517000#23#1969
20170207110517200#23#1970
20170207110607000#23#1971
20170207110657000#23#1972
20170207110747000#23#1973
20170207110837000#23#1974
20170207110927000#23#1975
20170207111017000#23#1976
20170207111107000#23#1977
20170207111157000#23#1978
20170207111247000#23#1979
20170207111338000#23#1980
20170207111428000#23#1981
20170207111518000#23#1982
20170207111608000#23#1983
20170207111618000#9#1984
20170207111618200#9#1985
20170207111619000#49#1986
20170207111619200#49#1987
20170207111619400#63#1988
20170207111620000#63#1989
20170207111622000#41#1990
20170207111623000#41#1991
20170207111625000#1#1992
20170207111625200#1#1993
20170207111627000#23#1994
20170207111627200#23#1995
20170207111643000#1#1996
20170207111643200#1#1997
20170207111659000#23#1998
20170207111659200#23#1999
20170207111704000#1#2000
20170207111704200#1#2001
20170207111720000#23#2002
20170207111720200#23#2003
20170207111724000#1#2004
20170207111725000#1#2005
20170207111745000#0#2006
20170207111745200#0#2007
20170207111802000#1#2008
20170207111802200#1#2009
20170207111852000#1#2010
20170207111942000#1#2011
20170207112032000#1#2012
20170207112035000#9#2013
20170207112035200#9#2014
20170207112036000#1#2015
20170207112036200#9#2016
20170207112036400#9#2017
20170207112037000#1#2018
20170207112037200#1#2019
20170207112037400#9#2020
20170207112038000#9#2021
20170207112040000#1#2022
20170207112040200#1#2023
20170207112041000#9#2024
20170207112041200#9#2025
20170207112054000#1#2026
20170207112054200#1#2027
20170207112059000#9#2028
20170207112059200#49#2029
20170207112059400#49#2030
20170207112100000#41#2031
20170207112100200#41#2032
20170207112103000#1#2033
20170207112103200#1#2034
20170207112114000#23#2035
20170207112114200#23#2036
20170207112118000#1#2037
20170207112118200#1#2038
20170207112125000#23#2039
20170207112125200#23#2040
20170207112215000#23#2041
20170207112231000#9#2042
20170207112231200#9#2043
20170207112231400#49#2044
20170207112232000#49#2045
20170207112232200#63#2046
20170207112232400#63#2047
20170207112235000#41#2048
20170207112235200#41#2049
20170207112310000#1#2050
20170207112311000#1#2051
20170207112312000#23#2052
20170207112313000#23#2053
20170207112314000#3#2054
20170207112314200#3#2055
20170207112314400#23#2056
20170207112314600#23#2057
20170207112318000#3#2058
20170207112318200#3#2059
20170207112408000#3#2060
20170207112458000#3#2061
20170207112548000#3#2062
20170207112638000#3#2063
20170207112728000#3#2064
20170207112818000#3#2065
20170207112908000#3#2066
20170207112958000#3#2067
20170207113048000#3#2068
20170207113049000#9#2069
20170207113050000#9#2070
20170207113140000#9#2071
20170207113230000#9#2072
20170207113320000#9#2073
20170207113410000#9#2074
20170207113500000#9#2075
20170207113550000#9#2076
20170207113640000#9#2077
20170207113730000#9#2078
20170207113820000#9#2079
20170207113910000#9#2080
20170207114000000#9#2081
20170207114050000#9#2082
20170207114140000#9#2083
20170207114231000#9#2084
20170207114321000#9#2085
20170207114411000#9#2086
20170207114501000#9#2087
20170207114551000#9#2088
20170207114641000#9#2089
20170207114731000#9#2090
20170207114821000#9#2091
20170207114911000#9#2092
20170207115001000#9#2093
20170207115051000#9#2094
20170207115141000#9#2095
20170207115231000#9#2096
20170207115322000#9#2097
20170207115412000#9#2098
20170207115502000#9#2099
20170207115552000#9#2100
20170207115642000#9#2101
20170207115732000#9#2102
20170207115822000#9#2103
20170207115912000#49#2104
20170207115912200#49#2105
20170207120002000#49#2106
20170207120052000#49#2107
20170207120142000#49#2108
20170207120216000#9#2109
20170207120217000#9#2110
20170207120218000#3#2111
20170207120219000#3#2112
20170207120308000#3#2113
20170207120359000#3#2114
20170207120449000#3#2115
20170207120539000#3#2116
20170207120629000#3#2117
20170207120719000#3#2118
20170207120809000#3#2119
20170207120859000#3#2120
20170207120946000#7#2121
20170207120947000#9#2122
20170207120947200#9#2123
20170207120957000#49#2124
20170207120957200#9#2125
20170207120957400#9#2126
20170207120958000#49#2127
20170207120958200#49#2128
20170207121048000#49#2129
20170207121138000#49#2130
20170207121143000#9#2131
20170207121143200#9#2132
20170207121144000#3#2133
20170207121144200#3#2134
20170207121234000#3#2135
20170207121324000#3#2136
20170207121414000#3#2137
20170207121504000#3#2138
20170207121554000#3#2139
20170207121644000#3#2140
20170207121735000#3#2141
20170207121825000#3#2142
20170207121913000#9#2143
20170207121913200#9#2144
20170207122003000#9#2145
20170207122053000#9#2146
20170207122141000#49#2147
20170207122141200#49#2148
20170207122231000#49#2149
20170207122254000#9#2150
20170207122254200#9#2151
20170207122255000#3#2152
20170207122255200#3#2153
20170207122345000#3#2154
20170207122435000#3#2155
20170207122525000#3#2156
20170207122616000#3#2157
20170207122706000#3#2158
20170207122756000#3#2159
20170207122846000#3#2160
20170207122936000#3#2161
20170207123023000#7#2162
20170207123023200#9#2163
20170207123024000#9#2164
20170207123113000#9#2165
20170207123124000#49#2166
20170207123124200#49#2167
20170207123214000#49#2168
20170207123239000#9#2169
20170207123239200#49#2170
20170207123240000#9#2171
20170207123240200#9#2172
20170207123241000#3#2173
20170207123241200#3#2174
20170207123331000#3#2175
20170207123421000#3#2176
20170207123511000#3#2177
20170207123601000#3#2178
20170207123652000#3#2179
20170207123742000#3#2180
20170207123832000#3#2181
20170207123922000#3#2182
20170207124008000#7#2183
20170207124009000#9#2184
20170207124009200#9#2185
20170207124054000#49#2186
20170207124054200#49#2187
20170207124144000#49#2188
20170207124200000#9#2189
20170207124200200#9#2190
20170207124250000#9#2191
20170207124340000#9#2192
20170207124430000#9#2193
20170207124520000#9#2194
20170207124610000#9#2195
20170207124700000#9#2196
20170207124724000#23#2197
20170207124724200#23#2198
20170207124725000#3#2199
20170207124725200#3#2200
20170207124815000#3#2201
20170207124905000#3#2202
20170207124955000#3#2203
20170207125045000#3#2204
20170207125135000#3#2205
20170207125225000#3#2206
20170207125315000#3#2207
20170207125405000#3#2208
20170207125453000#9#2209
20170207125453200#9#2210
20170207125519000#49#2211
20170207125519200#49#2212
20170207125609000#49#2213
20170207125641000#9#2214
20170207125641200#9#2215
20170207125643000#3#2216
20170207125643200#3#2217
20170207125733000#3#2218
20170207125823000#3#2219
20170207125913000#3#2220
20170207130003000#3#2221
20170207130053000#3#2222
20170207130143000#3#2223
20170207130233000#3#2224
20170207130323000#3#2225
20170207130411000#7#2226
20170207130411200#9#2227
20170207130412000#9#2228
20170207130423000#49#2229
20170207130423200#49#2230
20170207130513000#49#2231
20170207130535000#9#2232
20170207130535200#9#2233
20170207130537000#3#2234
20170207130537200#3#2235
20170207130627000#3#2236
20170207130717000#3#2237
20170207130807000#3#2238
20170207130857000#3#2239
20170207130948000#3#2240
20170207131038000#3#2241
20170207131128000#3#2242
20170207131218000#3#2243
20170207131305000#7#2244
20170207131305200#9#2245
20170207131305400#9#2246
20170207131355000#9#2247
20170207131356000#49#2248
20170207131357000#49#2249
20170207131446000#49#2250
20170207131459000#9#2251
20170207131459200#9#2252
20170207131500000#3#2253
20170207131500200#3#2254
20170207131550000#3#2255
20170207131640000#3#2256
20170207131730000#3#2257
20170207131821000#3#2258
20170207131911000#3#2259
20170207132001000#3#2260
20170207132051000#3#2261
20170207132141000#3#2262
20170207132228000#9#2263
20170207132228200#9#2264
20170207132303000#49#2265
20170207132304000#49#2266
20170207132353000#49#2267
20170207132421000#9#2268
20170207132421200#9#2269
20170207132423000#3#2270
20170207132423200#3#2271
20170207132513000#3#2272
20170207132603000#3#2273
20170207132653000#3#2274
20170207132743000#3#2275
20170207132833000#3#2276
20170207132923000#3#2277
20170207133013000#3#2278
20170207133103000#3#2279
20170207133151000#7#2280
20170207133152000#9#2281
20170207133152200#9#2282
20170207133205000#49#2283
20170207133206000#49#2284
20170207133255000#49#2285
20170207133311000#9#2286
20170207133312000#9#2287
20170207133313000#3#2288
20170207133313200#3#2289
20170207133403000#3#2290
20170207133453000#3#2291
20170207133543000#3#2292
20170207133633000#3#2293
20170207133723000#3#2294
20170207133813000#3#2295
20170207133903000#3#2296
20170207133954000#3#2297
20170207134040000#7#2298
20170207134040200#9#2299
20170207134040400#9#2300
20170207134130000#9#2301
20170207134156000#49#2302
20170207134156200#49#2303
20170207134246000#49#2304
20170207134314000#9#2305
20170207134314200#9#2306
20170207134316000#3#2307
20170207134316200#3#2308
20170207134406000#3#2309
20170207134456000#3#2310
20170207134546000#3#2311
20170207134636000#3#2312
20170207134726000#3#2313
20170207134816000#3#2314
20170207134907000#3#2315
20170207134957000#3#2316
20170207135045000#9#2317
20170207135045200#9#2318
20170207135059000#49#2319
20170207135100000#49#2320
20170207135149000#49#2321
20170207135212000#9#2322
20170207135212200#9#2323
20170207135214000#3#2324
20170207135214200#3#2325
20170207135304000#3#2326
20170207135354000#3#2327
20170207135444000#3#2328
20170207135534000#3#2329
20170207135624000#3#2330
20170207135715000#3#2331
20170207135805000#3#2332
20170207135855000#3#2333
20170207135942000#9#2334
20170207135942200#9#2335
20170207140009000#49#2336
20170207140009200#49#2337
20170207140059000#49#2338
20170207140139000#9#2339
20170207140139200#9#2340
20170207140140000#3#2341
20170207140140200#3#2342
20170207140230000#3#2343
20170207140320000#3#2344
20170207140410000#3#2345
20170207140500000#3#2346
20170207140550000#3#2347
20170207140640000#3#2348
20170207140730000#3#2349
20170207140821000#3#2350
20170207140908000#9#2351
20170207140908200#9#2352
20170207140919000#49#2353
20170207140919200#49#2354
20170207141009000#49#2355
20170207141024000#9#2356
20170207141025000#9#2357
20170207141026000#3#2358
20170207141026200#3#2359
20170207141116000#3#2360
20170207141206000#3#2361
20170207141256000#3#2362
20170207141346000#3#2363
20170207141436000#3#2364
20170207141526000#3#2365
20170207141616000#3#2366
20170207141706000#3#2367
20170207141753000#9#2368
20170207141753200#9#2369
20170207141758000#49#2370
20170207141758200#49#2371
20170207141848000#49#2372
20170207141915000#9#2373
20170207141915200#9#2374
20170207141916000#3#2375
20170207141916200#3#2376
20170207142006000#3#2377
20170207142056000#3#2378
20170207142146000#3#2379
20170207142236000#3#2380
20170207142327000#3#2381
20170207142417000#3#2382
20170207142507000#3#2383
20170207142557000#3#2384
20170207142642000#7#2385
20170207142643000#9#2386
20170207142643200#9#2387
20170207142722000#49#2388
20170207142722200#49#2389
20170207142812000#49#2390
20170207142847000#9#2391
20170207142847200#9#2392
20170207142848000#3#2393
20170207142849000#3#2394
20170207142938000#3#2395
20170207143029000#3#2396
20170207143119000#3#2397
20170207143209000#3#2398
20170207143259000#3#2399
20170207143349000#3#2400
20170207143439000#3#2401
20170207143529000#3#2402
20170207143616000#9#2403
20170207143616200#9#2404
20170207143637000#49#2405
20170207143637200#9#2406
20170207143638000#9#2407
20170207143638200#49#2408
20170207143638400#49#2409
20170207143638600#9#2410
20170207143638800#9#2411
20170207143639000#49#2412
20170207143639200#49#2413
20170207143729000#49#2414
20170207143805000#9#2415
20170207143806000#9#2416
20170207143807000#3#2417
20170207143807200#3#2418
20170207143857000#3#2419
20170207143947000#3#2420
20170207144037000#3#2421
20170207144127000#3#2422
20170207144217000#3#2423
20170207144308000#3#2424
20170207144358000#3#2425
20170207144448000#3#2426
20170207144534000#9#2427
20170207144535000#9#2428
20170207144546000#49#2429
20170207144546200#49#2430
20170207144636000#49#2431
20170207144714000#9#2432
20170207144714200#9#2433
20170207144716000#3#2434
20170207144716200#3#2435
20170207144806000#3#2436
20170207144856000#3#2437
20170207144946000#3#2438
20170207145036000#3#2439
20170207145126000#3#2440
20170207145217000#3#2441
20170207145307000#3#2442
20170207145357000#3#2443
20170207145444000#9#2444
20170207145444200#9#2445
20170207145534000#9#2446
20170207145624000#9#2447
20170207145714000#9#2448
20170207145804000#9#2449
20170207145852000#49#2450
20170207145852200#49#2451
20170207145942000#49#2452
20170207145959000#9#2453
20170207145959200#9#2454
20170207150000000#3#2455
20170207150001000#3#2456
20170207150051000#3#2457
20170207150141000#3#2458
20170207150231000#3#2459
20170207150321000#3#2460
20170207150411000#3#2461
20170207150501000#3#2462
20170207150551000#3#2463
20170207150641000#3#2464
20170207150728000#7#2465
20170207150728200#9#2466
20170207150728400#9#2467
20170207150818000#9#2468
20170207150844000#49#2469
20170207150844200#49#2470
20170207150934000#49#2471
20170207151009000#9#2472
20170207151009200#9#2473
20170207151011000#3#2474
20170207151011200#3#2475
20170207151101000#3#2476
20170207151151000#3#2477
20170207151241000#3#2478
20170207151331000#3#2479
20170207151421000#3#2480
20170207151511000#3#2481
20170207151601000#3#2482
20170207151651000#3#2483
20170207151738000#7#2484
20170207151739000#9#2485
20170207151739200#9#2486
20170207151822000#49#2487
20170207151823000#49#2488
20170207151912000#49#2489
20170207151942000#9#2490
20170207151943000#49#2491
20170207151943200#9#2492
20170207151943400#9#2493
20170207151946000#3#2494
20170207151946200#3#2495
20170207152036000#3#2496
20170207152126000#3#2497
20170207152216000#3#2498
20170207152306000#3#2499
20170207152356000#3#2500
20170207152446000#3#2501
20170207152536000#3#2502
20170207152626000#3#2503
20170207152713000#7#2504
20170207152713200#9#2505
20170207152713400#9#2506
20170207152747000#49#2507
20170207152747200#49#2508
20170207152837000#49#2509
20170207152917000#9#2510
20170207152918000#9#2511
20170207152920000#3#2512
20170207152920200#3#2513
20170207153010000#3#2514
20170207153100000#3#2515
20170207153150000#3#2516
20170207153240000#3#2517
20170207153330000#3#2518
20170207153420000#3#2519
20170207153510000#3#2520
20170207153600000#3#2521
20170207153647000#7#2522
20170207153647200#9#2523
20170207153647400#9#2524
20170207153650000#49#2525
20170207153650200#49#2526
20170207153740000#49#2527
20170207153750000#9#2528
20170207153750200#9#2529
20170207153751000#3#2530
20170207153751200#3#2531
20170207153841000#3#2532
20170207153931000#3#2533
20170207154022000#3#2534
20170207154112000#3#2535
20170207154202000#3#2536
20170207154252000#3#2537
20170207154342000#3#2538
20170207154432000#3#2539
20170207154519000#9#2540
20170207154519200#9#2541
20170207154548000#49#2542
20170207154549000#49#2543
20170207154638000#49#2544
20170207154714000#9#2545
20170207154714200#9#2546
20170207154719000#3#2547
20170207154719200#3#2548
20170207154809000#3#2549
20170207154859000#3#2550
20170207154949000#3#2551
20170207155039000#3#2552
20170207155130000#3#2553
20170207155220000#3#2554
20170207155310000#3#2555
20170207155400000#3#2556
20170207155446000#9#2557
20170207155446200#9#2558
20170207155519000#49#2559
20170207155520000#49#2560
20170207155610000#49#2561
20170207155620000#9#2562
20170207155620200#9#2563
20170207155621000#3#2564
20170207155621200#3#2565
20170207155711000#3#2566
20170207155801000#3#2567
20170207155851000#3#2568
20170207155941000#3#2569
20170207160031000#3#2570
20170207160121000#3#2571
20170207160212000#3#2572
20170207160302000#3#2573
20170207160348000#7#2574
20170207160349000#9#2575
20170207160349200#9#2576
20170207160427000#49#2577
20170207160427200#49#2578
20170207160517000#49#2579
20170207160548000#9#2580
20170207160548200#9#2581
20170207160550000#3#2582
20170207160550200#3#2583
20170207160640000#3#2584
20170207160730000#3#2585
20170207160821000#3#2586
20170207160911000#3#2587
20170207161001000#3#2588
20170207161051000#3#2589
20170207161141000#3#2590
20170207161231000#3#2591
20170207161318000#7#2592
20170207161318200#9#2593
20170207161319000#9#2594
20170207161408000#9#2595
20170207161459000#9#2596
20170207161549000#9#2597
20170207161639000#9#2598
20170207161729000#9#2599
20170207161819000#9#2600
20170207161826000#49#2601
20170207161826200#49#2602
20170207161827000#9#2603
20170207161827200#9#2604
20170207161827400#49#2605
20170207161827600#49#2606
20170207161836000#41#2607
20170207161836200#41#2608
20170207161926000#41#2609
20170207162016000#41#2610
20170207162106000#41#2611
20170207162156000#41#2612
File diff suppressed because it is too large Load Diff
+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# readFile v. 0.1
# - single instance timer
# - invio multiplo x send eventi accodati
#---------------------------------------------------------------
import time
from datetime import datetime
import urllib
import ConfigParser
import os, sys
import logging
import logging.handlers
import Queue
import argparse
#--------------------------------------------------------------
# gestione parser argomenti in input
parser = argparse.ArgumentParser()
parser.add_argument("memFile")
parser.add_argument("logFile")
args = parser.parse_args()
#definizione variabili BASE
stepQueuePut=25000
stepQueueGet=250
NMAXSEND=500000 # limite invio file x fare prove...
idxMacchina = "2000"
#--------------------------------------------------------------
# Gestione coda (condivisa) x registrazione eventi ed invio URL
#print "Creazione coda illimitata"
Coda = Queue.Queue(0)
#---------------------------------------------------------------
#Funzione di scrittura su coda con try-except
def accoda(valore):
try:
Coda.put(valore)
except Queue.Full:
logPro.error( "Queue full" + dtEve + '#' + value + '#' + cont )
except:
logPro.error( "NETWORK:Errore http-no com rete-timeout" + url )
#--------------------------------------------------------------
# svuotaCoda x invio dati al server
def svuota_coda():
global NMAXSEND
try:
if not Coda.empty():
# invio SOLO i primi NMAXSEND eventi... SE minore del num eventi...
if NMAXSEND > Coda.qsize():
NMAXSEND = Coda.qsize()
i = 0
with open(args.logFile,"w") as outf:
while i <= NMAXSEND:
if not Coda.empty():
# formatto dataOra corrente
dtCurr = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3]
#prendo primo elemento dalla coda
resp = Coda.get()
# recupero valori da elemento coda!
dtEve = resp.split("#")[0]
value = resp.split("#")[1]
cnt = resp.split("#")[2]
url = URLBASE + idxMacchina + URLADV1 + value
url = url + '&dtCurr=' + dtCurr + '&dtEve=' + dtEve + '&cnt=' + cnt
# CHIAMO URL
response3 = urllib.urlopen ( url )
answ3 = response3.read()
# registro chiamata + risposta
outf.write(url + " --> " + answ3 + "\n")
# incremento e controllo se mostrare output
i += 1
if (i % stepQueueGet) == 0:
print "Inviati %d valori..." % i
print "Inviati %d valori..." % i
except:
print "Errore in svuotamento coda!"
#---------------------------------------------------------------
# MAIN
try:
config = ConfigParser.RawConfigParser()
config.read ( 'IOB.cfg' )
# NMAXSEND = config.getint ( 'time' , 'NMAXSEND' )
idxMacchina = config.get ( 'id' , 'idxMacchina' )
URLBASE = config.get ( 'web' , 'URLBASE' )
URLADV1 = config.get ( 'web' , 'URLADV1' )
LOGFILE = config.get ( 'log' , 'LOGFILE' )
LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' )
except:
print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg'
sys.exit(1)
#---------------------------------------------------------------
dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3]
print "Inizio elaborazione: %s" % dtCurr
# Leggo il file!
i = 0
with open(args.memFile, 'r') as inf, open(args.logFile,"w") as outf:
data = inf.readlines()
print "Trovate %d da processare..." % len(data)
# leggo e metto in QUEUE...
for line in data:
accoda(line)
i += 1
if (i % stepQueuePut) == 0:
print "Accodati %d valori..." % i
print "Completata lettura file! %d righe accodate da trasmettere" % Coda.qsize()
dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3]
print "Inizio invio: %s" % dtCurr
# chiamo procedura x svuotare coda...
svuota_coda()
dtCurr = datetime.utcnow().strftime('%H:%M:%S.%f')[:-3]
print "Completato invio: %s" % dtCurr
@@ -1,10 +1,12 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# readParallela v. 2.0
# readParallela v. 2.2
# - single instance timer
# - invio multiplo x send eventi accodati
# - gestione segnali BLINKING
# - gestione INVERSIONE segnali cv 10-VII-2018
# - gestione FILTRAGGIO segnali brevi cv 23-VII-2018
#---------------------------------------------------------------
# levare locking
@@ -39,7 +41,7 @@ MAXRETRY = 3
# numero campioni filtraggio segnale ballerino
MAX_COUNTER_BLINK = 10
PROGRAM_NAME ="ReadPar IOB-pi v.2.0"
PROGRAM_NAME ="ReadPar IOB-pi v.2.2"
# DA FILE CONF
idxMacchina = "1001"
@@ -89,9 +91,16 @@ timer_busy = False
i_counters = array ( 'i',[0,0,0,0,0,0,0,0])
B_blinking = array ( 'B',[0,0,0,0,0,0,0,0])
B_previous = array ( 'B',[0,0,0,0,0,0,0,0])
B_input = array ( 'B',[0,0,0,0,0,0,0,0])
B_input = array ( 'B',[0,0,0,0,0,0,0,0])
B_output = array ( 'B',[0,0,0,0,0,0,0,0])
B_inverting = array ( 'B',[0,0,0,0,0,0,0,0])
B_filter = array ( 'B',[0,0,0,0,0,0,0,0])
B_filter_prev = array ( 'B',[0,0,0,0,0,0,0,0])
B_temp = array ( 'B',[0,0,0,0,0,0,0,0])
i_filter_counters = array ( 'i',[0,0,0,0,0,0,0,0])
#--------------------------------------------------------------
# Gestione coda (condivisa) x registrazione eventi ed invio URL
#print "Creazione coda illimitata"
@@ -165,6 +174,71 @@ def readParallelaFiltrata():
#ciclo per ogni segnale
for i in xrange(8) :
# print (i)
# v2.1 gestione inversione bit ingresso
if ( B_inverting[i] == 1 ) :
if ( B_input[i] == 0 ) :
B_input[i] = 1
else :
B_input[i] = 0
# v2.2 gestione filtro segnali brevi
if ( B_filter[i] == 1 ) :
# fronte 0 -> 1
if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 0 ) :
if ( i_filter_counters[i] == 0 ) :
# vero fronte 0 -> 1
i_filter_counters[i] = MAX_COUNTER_FILTER
B_temp[i] = 0 # tengo l' ingresso a 0
#logPro.info("START spike 0->1 on bit " + `i` )
else :
# fine disturbo breve di uno stato 1
i_filter_counters[i] = 0
B_temp[i] = 1 # tengo l' ingresso a 1
logPro.info("END spike 0->1 on bit " + `i` )
# stabile 1 -> 1
if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 1 ) :
if ( i_filter_counters[i] == 0 ) :
# segnale stabile a 1
B_temp[i] = 1 # tengo l' ingresso a 1
else :
# poco dopo il fronte
i_filter_counters[i] = i_filter_counters[i] - 1
B_temp[i] = 0 # tengo l' ingresso a 0
# fronte 1 -> 0
if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 1 ) :
if ( i_filter_counters[i] == 0 ) :
# vero fronte 1 -> 0
i_filter_counters[i] = MAX_COUNTER_FILTER
B_temp[i] = 1 # tengo l' ingresso a 1
#logPro.info("START spike 1->0 on bit " + `i` )
else :
# fine disturbo breve di uno stato 0
i_filter_counters[i] = 0
B_temp[i] = 0 # tengo l' ingresso a 0
logPro.info("END spike 1->0 on bit " + `i` )
# stabile 0 -> 0
if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 0 ) :
if ( i_filter_counters[i] == 0 ) :
# segnale stabile a 0
B_temp[i] = 0 # tengo l' ingresso a 0
else :
# poco dopo il fronte
i_filter_counters[i] = i_filter_counters[i] - 1
B_temp[i] = 1 # tengo l' ingresso a 1
B_filter_prev [i] = B_input[i]
B_input[i] = B_temp[i]
# fine gestione filtro segnali brevi
# se non blinking, copia ingresso
if ( B_blinking[i] == 0 ) :
B_output[i] = B_input[i]
@@ -443,9 +517,33 @@ try:
B_blinking[5] = config.getint ( 'blink' , 'bit5' )
B_blinking[6] = config.getint ( 'blink' , 'bit6' )
B_blinking[7] = config.getint ( 'blink' , 'bit7' )
MAX_COUNTER_BLINK = config.getint ( 'blink' , 'MAX_COUNTER_BLINK' )
# cv 2.1 se bit = 1 allora inverto segnale in ingresso...
B_inverting[0] = config.getint ( 'invert' , 'bit0' )
B_inverting[1] = config.getint ( 'invert' , 'bit1' )
B_inverting[2] = config.getint ( 'invert' , 'bit2' )
B_inverting[3] = config.getint ( 'invert' , 'bit3' )
B_inverting[4] = config.getint ( 'invert' , 'bit4' )
B_inverting[5] = config.getint ( 'invert' , 'bit5' )
B_inverting[6] = config.getint ( 'invert' , 'bit6' )
B_inverting[7] = config.getint ( 'invert' , 'bit7' )
# cv 2.2 se bit = 1 allora filtro segnali brevi ...
B_filter[0] = config.getint ( 'filter' , 'bit0' )
B_filter[1] = config.getint ( 'filter' , 'bit1' )
B_filter[2] = config.getint ( 'filter' , 'bit2' )
B_filter[3] = config.getint ( 'filter' , 'bit3' )
B_filter[4] = config.getint ( 'filter' , 'bit4' )
B_filter[5] = config.getint ( 'filter' , 'bit5' )
B_filter[6] = config.getint ( 'filter' , 'bit6' )
B_filter[7] = config.getint ( 'filter' , 'bit7' )
MAX_COUNTER_FILTER = config.getint ( 'filter' , 'MAX_COUNTER_FILTER' )
except:
print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg'
Binary file not shown.
Binary file not shown.
+56
View File
@@ -0,0 +1,56 @@
[id]
idxMacchina = 0001
[web]
URLBASE = http://10.74.82.219/MP/IO/IOB/input/
URLALIVE = http://10.74.82.219/MP/IO/IOB
URLENABLED = http://10.74.82.219/MP/IO/IOB/enabled/
URLADV1 = ?valore=
URLREBO = http://10.74.82.219/MP/IO/sendReboot.aspx?idxMacchina=
[time]
SAMPLETIME = 0.05
TIMEOUTSHORT = 0.30
TIMEOUTLONG = 50
SENDURLTIME = 0.15
NMAXSEND = 5
[log]
LOGLEVEL = 10
LOGFILE = logfile.txt
LOGREBO = logReboot.txt
[comm]
port = /dev/ttyAMA0
[blink]
MAX_COUNTER_BLINK = 30
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
[invert]
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
[filter]
MAX_COUNTER_FILTER = 10
bit0 = 0
bit1 = 1
bit2 = 0
bit3 = 0
bit4 = 0
bit5 = 0
bit6 = 0
bit7 = 0
@@ -1,12 +1,12 @@
[id]
idxMacchina = 0001
idxMacchina = 1005
[web]
URLBASE = http://10.74.82.219/MP/IO/IOB/input/
URLALIVE = http://10.74.82.219/MP/IO/IOB
URLENABLED = http://10.74.82.219/MP/IO/IOB/enabled/
URLADV1 = ?valore=
URLREBO = http://10.74.82.219/MP/IO/sendReboot.aspx?idxMacchina=
URLREBO = http://10.74.82.219/MPIO/sendReboot.aspx?idxMacchina=
[time]
SAMPLETIME = 0.05
+41
View File
@@ -0,0 +1,41 @@
### BEGIN INIT INFO
# Provides: MapoIOB: script Steamware per avvio driver IOB
# Required-Start: $remote_fs $syslog ramlog
# Required-Stop: $remote_fs $syslog ramlog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Steamware's MapoIOB driver
# Description: Steamware's MapoIOB driver, versione lettura porta parallela
### END INIT INFO
#! /bin/sh
# /etc/init.d/MapoIOB
export HOME
case "$1" in
start)
echo "Starting readParallela"
cd /home/pi/steamware
/usr/bin/python ./readParallela.py 2>&1 &
;;
stop)
echo "Stopping readParallela"
RS_PID=`ps auxwww | grep readParallela.py | head -1 | awk '{print $2}'`
kill -9 $RS_PID
cd /home/pi/steamware
rm .lockfile
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
killall python
$0 start
;;
*)
echo "Usage: /etc/init.d/MapoIOB {start|stop|restart}"
exit 1
;;
esac
exit 0
+28
View File
@@ -0,0 +1,28 @@
/var/log/MapoIOB.log {
size 8M
copytruncate
create 700 pi pi
dateext
rotate 100
compress
maxage 366
missingok
}
/var/log/logReboot.txt {
size 1M
copytruncate
create 700 pi pi
dateext
rotate 30
compress
missingok
}
/var/log/logTemp.txt {
size 1M
copytruncate
create 700 pi pi
dateext
rotate 30
compress
missingok
}
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# controlla se il logfile è correntemente scritto (quindi MapoIOB è alive) altrimenti riavvia!
DATE=`date +%Y-%m-%d`
cd /var/log
if [ -f MapoIOB.log ]
then
# controllo SE sia stato acceduto da meno di 2 minuti (=alive da log...)
trovato=`find . -name 'MapoIOB*' -cmin -1`
if [[ $trovato != './MapoIOB.log' ]]
then
/etc/init.d/MapoIOB restart
echo $date + "riavvio!"
fi
else
# in questo caso AVVIO il processo MapoIOB
/etc/init.d/MapoIOB start
echo $date + "file non trovato, avvio!"
fi
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
DATE=`date +%Y-%m-%d_%T`
# log inizio pulizia
echo $DATE " - INIZIO pulizia processi python" >> clean.log
# effettua pulizia processi: killa tutti i processi python
killall python
# avvia MapoIob
/etc/init.d/MapoIOB start
# log fatto!
DATE=`date +%Y-%m-%d_%T`
echo $DATE " - FINE pulizia processi python + riavvio MapoIOB" >> clean.log
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# readFile v. 0.1
# - single instance timer
# - invio multiplo x send eventi accodati
#---------------------------------------------------------------
import os, sys
import argparse
#--------------------------------------------------------------
# gestione parser argomenti in input
parser = argparse.ArgumentParser()
parser.add_argument("inFile")
parser.add_argument("outFile")
args = parser.parse_args()
#with open('logfile.txt', 'r') as inf, open('persMem.dat',"w") as outf:
with open(args.inFile, 'r') as inf, open(args.outFile,"w") as outf:
data = inf.readlines()
lastDt = ""
lastMs = 0
stepMs = 200
for line in data:
words = line.split()
if words[2] == 'queue':
# recupero dataOra
newDt = words[0].replace("-","") + words[1].replace(":","")
# verifico se data/ora identica...
if (lastDt == newDt):
# --> aggiungo stepMs
lastMs += stepMs
else:
lastMs = 0
lastDt = newDt
newDt = newDt + '{:03d}'.format(lastMs) #str(lastMs)
#print words[0].replace("-","") + words[1].replace(":","") + " | " + newDt + "\n"
# print words
# outf.write(words[0].replace("-","") + words[1].replace(":","") + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n')
outf.write(newDt + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n')
+1
View File
@@ -0,0 +1 @@
* * * * * /bin/bash /home/pi/steamware/checkAlive.sh >> /home/pi/stdout 2>> /home/pi/stderr
+51
View File
@@ -0,0 +1,51 @@
#|/bin/bash
#installa il necessario per RPI-3-IOB partendo dal contenuto della folder /home/pi/steamware
#step 1: creo file di log nuovi
rm /var/log/log*.txt
rm /var/log/MapoIOB*
rm /home/pi/steamware/log*.txt
touch /var/log/logReboot.txt
touch /var/log/logTemp.txt
touch /var/log/MapoIOB.log
ln -sf /var/log/logReboot.txt /home/pi/steamware/logReboot.txt
ln -sf /var/log/logTemp.txt /home/pi/steamware/logTemp.txt
ln -sf /var/log/MapoIOB.log /home/pi/steamware/logfile.txt
chown pi:pi /home/pi -R
chmod 666 /var/log/log*.txt
chmod 666 /var/log/MapoIOB.log
#step 2: copio files in /usr/local/bin
cd /home/pi/steamware
chmod +x *.sh
cp *.sh /usr/local/bin/
#step 3: copio files x logrotate...
cd /home/pi/steamware
cp MapoIOB_logrot /etc/logrotate.d/
# step 4: copio target systemd in avvio...
cp -f sendRebootIOB /etc/init.d/sendRebootIOB
cp -f sendRebootIOB.service /etc/systemd/system/sendRebootIOB.service
echo ""
echo "-----------------------------------------------"
echo "Completare registrazione servizio avvio: digitare i seguenti comandi"
echo "systemctl enable sendRebootIOB"
echo "systemctl daemon-reload"
echo "systemctl status sendRebootIOB"
echo "-----------------------------------------------"
echo ""
echo ""
echo ""
echo "-----------------------------------------------"
echo "Infine creare voce crontab che salvi temperatura CPU/GPU ogni 20 minuti..."
echo "crontab -e"
echo "*/20 * * * * /usr/local/bin/saveTemp.sh"
echo "-----------------------------------------------"
+706
View File
@@ -0,0 +1,706 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# readParallela v. 2.2
# - single instance timer
# - invio multiplo x send eventi accodati
# - gestione segnali BLINKING
# - gestione INVERSIONE segnali cv 10-VII-2018
# - gestione FILTRAGGIO segnali brevi cv 23-VII-2018
#---------------------------------------------------------------
# levare locking
# timer semplificata
# GPIO global
import time
import sys
from datetime import datetime
import urllib
import ConfigParser
import os, sys
import logging
import logging.handlers
import threading
import Queue
from array import *
#--------------------------------------------------------------
# COSTANTI
MSGLEN = 9
TIMEOUTSERIALE = 10
MAXRETRY = 3
# numero campioni filtraggio segnale ballerino
MAX_COUNTER_BLINK = 10
PROGRAM_NAME ="ReadPar IOB-pi v.2.2"
# DA FILE CONF
idxMacchina = "1001"
SAMPLETIME = 0.1
TIMEOUTSHORT = (SAMPLETIME*20)
TIMEOUTLONG = (SAMPLETIME*600)
SENDURLTIME = 0.08
NMAXSEND = 5 # numero massimo di invii per singolo ciclo di svuotamento
# VAR
to_enable = False
to_short = TIMEOUTSHORT
to_long = TIMEOUTLONG
to_serial = TIMEOUTSERIALE
to_retry = MAXRETRY
errormsglen = 0
# VAR
out_0 = 24
out_1 = 26
in_0 = 11
in_1 = 12
in_2 = 13
in_3 = 15
in_4 = 16
in_5 = 18
in_6 = 22
in_7 = 7
# contatore: serve x match tra accoda ed invia x possibile controllo a posteriori... ogni volta che accodo incremento di 1, va da 0 a 9999
cont = '0'
# variabile stato online/offline della macchina
onLine = '1'
# variabile stato seinding/waiting x la parte invio URL
sending = '0'
# variabile stato timer thread busy
timer_busy = False
#
# array per ingressi filtrati
i_counters = array ( 'i',[0,0,0,0,0,0,0,0])
B_blinking = array ( 'B',[0,0,0,0,0,0,0,0])
B_previous = array ( 'B',[0,0,0,0,0,0,0,0])
B_input = array ( 'B',[0,0,0,0,0,0,0,0])
B_output = array ( 'B',[0,0,0,0,0,0,0,0])
B_inverting = array ( 'B',[0,0,0,0,0,0,0,0])
B_filter = array ( 'B',[0,0,0,0,0,0,0,0])
B_filter_prev = array ( 'B',[0,0,0,0,0,0,0,0])
B_temp = array ( 'B',[0,0,0,0,0,0,0,0])
i_filter_counters = array ( 'i',[0,0,0,0,0,0,0,0])
#--------------------------------------------------------------
# Gestione coda (condivisa) x registrazione eventi ed invio URL
#print "Creazione coda illimitata"
Coda = Queue.Queue(0)
#queueLock = threading.Lock()
#---------------------------------------------------------------
# lettura parallela
# ritorna il byte letto pulito ( due char hex )
def readParallelaFiltrata():
global in_0
global in_1
global in_2
global in_3
global in_4
global in_5
global in_6
global in_7
global GPIO
current = ''
try:
if GPIO.input(in_0):
B_input[0] = 0
else:
B_input[0] = 1
if GPIO.input(in_1):
B_input[1] = 0
else:
B_input[1] = 1
if GPIO.input(in_2):
B_input[2] = 0
else:
B_input[2] = 1
if GPIO.input(in_3):
B_input[3] = 0
else:
B_input[3] = 1
if GPIO.input(in_4):
B_input[4] = 0
else:
B_input[4] = 1
if GPIO.input(in_5):
B_input[5] = 0
else:
B_input[5] = 1
if GPIO.input(in_6):
B_input[6] = 0
else:
B_input[6] = 1
if GPIO.input(in_7):
B_input[7] = 0
else:
B_input[7] = 1
#ciclo per ogni segnale
for i in xrange(8) :
# print (i)
# v2.1 gestione inversione bit ingresso
if ( B_inverting[i] == 1 ) :
if ( B_input[i] == 0 ) :
B_input[i] = 1
else :
B_input[i] = 0
# v2.2 gestione filtro segnali brevi
if ( B_filter[i] == 1 ) :
# fronte 0 -> 1
if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 0 ) :
if ( i_filter_counters[i] == 0 ) :
# vero fronte 0 -> 1
i_filter_counters[i] = MAX_COUNTER_FILTER
B_temp[i] = 0 # tengo l' ingresso a 0
#logPro.info("START spike 0->1 on bit " + `i` )
else :
# fine disturbo breve di uno stato 1
i_filter_counters[i] = 0
B_temp[i] = 1 # tengo l' ingresso a 1
logPro.info("END spike 0->1 on bit " + `i` )
# stabile 1 -> 1
if ( B_input[i] == 1 ) and ( B_filter_prev [i] == 1 ) :
if ( i_filter_counters[i] == 0 ) :
# segnale stabile a 1
B_temp[i] = 1 # tengo l' ingresso a 1
else :
# poco dopo il fronte
i_filter_counters[i] = i_filter_counters[i] - 1
B_temp[i] = 0 # tengo l' ingresso a 0
# fronte 1 -> 0
if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 1 ) :
if ( i_filter_counters[i] == 0 ) :
# vero fronte 1 -> 0
i_filter_counters[i] = MAX_COUNTER_FILTER
B_temp[i] = 1 # tengo l' ingresso a 1
#logPro.info("START spike 1->0 on bit " + `i` )
else :
# fine disturbo breve di uno stato 0
i_filter_counters[i] = 0
B_temp[i] = 0 # tengo l' ingresso a 0
logPro.info("END spike 1->0 on bit " + `i` )
# stabile 0 -> 0
if ( B_input[i] == 0 ) and ( B_filter_prev [i] == 0 ) :
if ( i_filter_counters[i] == 0 ) :
# segnale stabile a 0
B_temp[i] = 0 # tengo l' ingresso a 0
else :
# poco dopo il fronte
i_filter_counters[i] = i_filter_counters[i] - 1
B_temp[i] = 1 # tengo l' ingresso a 1
B_filter_prev [i] = B_input[i]
B_input[i] = B_temp[i]
# fine gestione filtro segnali brevi
# se non blinking, copia ingresso
if ( B_blinking[i] == 0 ) :
B_output[i] = B_input[i]
else:
# gestione segnale blinking
# se fronte del segnale
if ( B_previous[i] != B_input[i] ) :
B_previous[i] = B_input[i]
# se fronte di salita
if ( B_input[i] == 1 ) :
# subito uscita = 1
B_output[i] = 1
i_counters[i] = MAX_COUNTER_BLINK
#else :
# # loggo che ho rilevato un blink...
# logPro.info("Blink down on bit " + `i`)
else:
# no , segnale eguale a prima
# se input a 0
if ( B_input[i] == 0 ) :
# E CONTEGGIO IN CORSO
if ( i_counters[i] > 0 ) :
i_counters[i] = i_counters[i] -1
if ( i_counters[i] == 0 ) :
B_output[i] = 0
logPro.info("END Blink on bit " + `i` )
#Rimettiamo insieme i bit
new_value = 0
if ( B_output[0] == 1 ) :
new_value = new_value + 1
if ( B_output[1] == 1 ) :
new_value = new_value + 2
if ( B_output[2] == 1 ) :
new_value = new_value + 4
if ( B_output[3] == 1 ) :
new_value = new_value + 8
if ( B_output[4] == 1 ) :
new_value = new_value + 16
if ( B_output[5] == 1 ) :
new_value = new_value + 32
if ( B_output[6] == 1 ) :
new_value = new_value + 64
if ( B_output[7] == 1 ) :
new_value = new_value + 128
current = hex( new_value ).replace ( "0x" , "" ).upper()
except:
pass
return current
#---------------------------------------------------------------
#Funzione di scrittura su coda con try-except
def accoda():
try:
dtEve = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3]
Coda.put(dtEve + '#' + value + '#' + cont)
except Queue.Full:
logPro.error( "Queue full" + `dtEve` + '#' + `value` + '#' + `cont` )
except:
logPro.error( "NETWORK:Errore http-no com rete-timeout" + url )
# print "Url aforte" , url
#--------------------------------------------------------------
# svuotaCoda x invio dati al server
def svuota_coda():
global onLine
global sending
global timer_busy
global NMAXSEND
#print "start timer "
if ( timer_busy == False ):
timer_busy = True
#print "start timer ok "
try:
if not Coda.empty():
#print "coda da svuotare!"
response = urllib.urlopen(URLALIVE)
answ = response.read()
if answ == 'OK':
#print "OK alive"
response2 = urllib.urlopen(URLENABLED + idxMacchina)
answ2 = response2.read()
if answ2 == 'OK':
# aggiorno stato ad online
if onLine == '0':
logPro.info("IOB ONLINE!")
#print("IOB ONLINE")
onLine = '1' # imposto comunque online
else:
if onLine == '1':
logPro.error("IOB offline")
#print("IOB offline")
onLine = '0'
else:
if onLine == '1':
logPro.error("Server offline")
#print("Server offline")
onLine = '0'
# ora verifico SE si possa inviare (ovvero sia online server e NON ci siano altri send attivi...)
if onLine == '1':
if sending == '0':
#segnalo che sono in sending!
sending = '1'
# SAM 2016.12.23: modifica x invio FINO A nMaxSend ELEMENTI ad ogni ciclo di svuotamento
i = NMAXSEND
while i >= 0:
if not Coda.empty():
# formatto dataOra corrente
dtCurr = datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3]
#prendo primo elemento dalla coda
resp = Coda.get()
# recupero valori da elemento coda!
dtEve = resp.split("#")[0]
value = resp.split("#")[1]
cnt = resp.split("#")[2]
url = URLBASE + idxMacchina + URLADV1 + value
url = url + '&dtCurr=' + dtCurr + '&dtEve=' + dtEve + '&cnt=' + cnt
# CHIAMO URL
response3 = urllib.urlopen ( url )
answ3 = response3.read()
#print(url)
# log valore inviato!
logSnd.info( value + ' ['+ cnt +']' + ' R:' + answ3 )
#print "Valore smaltito dalla coda"
# tolgo 1 al contatore
i -= 1
# completato invio, riporto sending a zero!
sending = '0'
else:
logPro.info("WAIT active send to complete")
else:
pass
else:
pass
except:
if onLine == '1':
logPro.error("Server Non raggiungibile")
#print "Non raggiungibile"
onLine = '0'
# in ogni caso
timer_busy = False
#print "end timer ok"
#print "end timer "
#---------------------------------------------------------------
# funzione timer thread
#---------------------------------------------------------------
def do_every (interval, worker_func, iterations = 0):
if iterations != 1:
threading.Timer (
interval,
do_every, [interval, worker_func, 0 if iterations == 0 else iterations-1]
).start ();
worker_func ();
#---------------------------------------------------------------
# gestione contatore
#---------------------------------------------------------------
def contatore():
try:
global cont
ctr = int(cont)
ctr +=1
ctr = ctr % 10000 # round robin 10000 eventi x track
cont = str(ctr)
except:
print("errore incremento contatore")
#---------------------------------------------------------------
# avvia porta parallela
#---------------------------------------------------------------
def avviaParallela():
global in_0
global in_1
global in_2
global in_3
global in_4
global in_5
global in_6
global in_7
global GPIO
try:
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
#GPIO.setup(out_0, GPIO.OUT) # output 0
#GPIO.setup(out_1, GPIO.OUT) # output 1
GPIO.setup(in_0, GPIO.IN) # input 0
GPIO.setup(in_1, GPIO.IN) # input 1
GPIO.setup(in_2, GPIO.IN) # input 2
GPIO.setup(in_3, GPIO.IN) # input 3
GPIO.setup(in_4, GPIO.IN) # input 4
GPIO.setup(in_5, GPIO.IN) # input 5
GPIO.setup(in_6, GPIO.IN) # input 6
GPIO.setup(in_7, GPIO.IN) # input 7
except:
print( "\n\n" + PROGRAM_NAME + " - Error 3 on RPi.GPIO ! \n\n")
sys.exit(1)
print( "\n\n" + PROGRAM_NAME + " - init ok \n\n")
#---------------------------------------------------------------
#---------------------------------------------------------------
# MAIN
try:
config = ConfigParser.RawConfigParser()
config.read ( 'IOB.cfg' )
SAMPLETIME = config.getfloat ( 'time' , 'SAMPLETIME' )
TIMEOUTSHORT = config.getfloat ( 'time' , 'TIMEOUTSHORT' )
TIMEOUTLONG = config.getfloat ( 'time' , 'TIMEOUTLONG' )
SENDURLTIME = config.getfloat ( 'time' , 'SENDURLTIME' )
NMAXSEND = config.getint ( 'time' , 'NMAXSEND' )
idxMacchina = config.get ( 'id' , 'idxMacchina' )
URLBASE = config.get ( 'web' , 'URLBASE' )
URLENABLED = config.get('web' , 'URLENABLED')
URLALIVE = config.get ('web' , 'URLALIVE')
URLADV1 = config.get ( 'web' , 'URLADV1' )
LOGFILE = config.get ( 'log' , 'LOGFILE' )
LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' )
B_blinking[0] = config.getint ( 'blink' , 'bit0' )
B_blinking[1] = config.getint ( 'blink' , 'bit1' )
B_blinking[2] = config.getint ( 'blink' , 'bit2' )
B_blinking[3] = config.getint ( 'blink' , 'bit3' )
B_blinking[4] = config.getint ( 'blink' , 'bit4' )
B_blinking[5] = config.getint ( 'blink' , 'bit5' )
B_blinking[6] = config.getint ( 'blink' , 'bit6' )
B_blinking[7] = config.getint ( 'blink' , 'bit7' )
MAX_COUNTER_BLINK = config.getint ( 'blink' , 'MAX_COUNTER_BLINK' )
# cv 2.1 se bit = 1 allora inverto segnale in ingresso...
B_inverting[0] = config.getint ( 'invert' , 'bit0' )
B_inverting[1] = config.getint ( 'invert' , 'bit1' )
B_inverting[2] = config.getint ( 'invert' , 'bit2' )
B_inverting[3] = config.getint ( 'invert' , 'bit3' )
B_inverting[4] = config.getint ( 'invert' , 'bit4' )
B_inverting[5] = config.getint ( 'invert' , 'bit5' )
B_inverting[6] = config.getint ( 'invert' , 'bit6' )
B_inverting[7] = config.getint ( 'invert' , 'bit7' )
# cv 2.2 se bit = 1 allora filtro segnali brevi ...
B_filter[0] = config.getint ( 'filter' , 'bit0' )
B_filter[1] = config.getint ( 'filter' , 'bit1' )
B_filter[2] = config.getint ( 'filter' , 'bit2' )
B_filter[3] = config.getint ( 'filter' , 'bit3' )
B_filter[4] = config.getint ( 'filter' , 'bit4' )
B_filter[5] = config.getint ( 'filter' , 'bit5' )
B_filter[6] = config.getint ( 'filter' , 'bit6' )
B_filter[7] = config.getint ( 'filter' , 'bit7' )
MAX_COUNTER_FILTER = config.getint ( 'filter' , 'MAX_COUNTER_FILTER' )
except:
print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg'
sys.exit(1)
#--------------------------------------------
# oggetto Logger
#--------------------------------------------
try:
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
filename=LOGFILE,
filemode='a'
)
# aggiungo 2 logger specifici x queue e send...
logQue = logging.getLogger('queue')
logSnd = logging.getLogger('sendUrl')
logPro = logging.getLogger('program')
except:
# manda mail o simili - FARE!!!
print "LOG: Impossibile creare file log con nome "
print (LOGFILE)
#--------------------------------------------
print "\n\n" + PROGRAM_NAME + "\n\n"
global startstatus
startstatus = 1
if startstatus == 1:
logPro.info("Avvio Programma" + PROGRAM_NAME)
## Verifica l'OS e di conseguenza carica il file relativo con metodo di lockfile appropriato + check singola istanza
if os.name == 'posix':
import unix
else:
import win
logPro.info( "Start " + PROGRAM_NAME )
# lettura file configurazione
# [id]
# idxMacchina = 2001
# [time]
# SAMPLETIME = 0.1
# TIMEOUTSHORT = 200
# TIMEOUTLONG = 6000
print ( ' idxMacchina = %s' % ( idxMacchina ) )
print ( ' SAMPLETIME = %4.2f' % ( SAMPLETIME ) )
print ( ' TIMEOUTSHORT = %4.2f' % ( TIMEOUTSHORT ) )
print ( ' TIMEOUTLONG = %4.2f' % ( TIMEOUTLONG ) )
print ( ' SENDURLTIME = %4.2f' % ( SENDURLTIME ) )
print ( ' URLBASE = %s' % ( URLBASE ) )
print ( ' URLADV1 = %s' % ( URLADV1 ) )
print ( ' LOGFILE = %s' % ( LOGFILE ) )
print ( ' LOGLEVEL = %s' % ( LOGLEVEL ) )
# -sys.stdout.write ( 'idxMacchina ?' + idxMacchina + '\n')
to_short = TIMEOUTSHORT
to_long = TIMEOUTLONG
#--------------------------------------------------------------
# apertura parallela
try:
import RPi.GPIO as GPIO
except RuntimeError:
print( "\n\n" + PROGRAM_NAME + " - Error 1 - you need superuser privileges")
except:
print( "\n\n" + PROGRAM_NAME + " - Error 2 - you need superuser privileges. USE 'sudo' to run your script\n\n")
sys.exit(1)
avviaParallela()
#--------------------------------------------------------------
# MARCO: qui inserire avvio thread di "svuotaCoda"
# avviaSvuotaCoda
#print "Avvia svuota coda"
do_every ( SENDURLTIME , svuota_coda );
#---------------------------------------------------------------
# ciclo forever and ever
old = ''
#print "Avvio ciclo"
logPro.info("Avvio loop principale")
while 1:
try:
time.sleep (SAMPLETIME)
except:
logPro.info("First_SLEEP: errore attesa sampletime")
# lettura dati da IOB
value = readParallelaFiltrata()
if ( value != '' ) :
if value != old :
#loggo e invio dati
try:
logQue.info( value + ' ['+ cont +']')
errormsglen = 0
accoda()
contatore()
except:
logPro.error("URLBROWSER: errore registrazione valore e accoda")
pass
#enable e reset timer
to_enable = True
to_short = TIMEOUTSHORT
to_long = TIMEOUTLONG
old = value
# gestione timeout breve
if ( to_enable ) :
to_short = to_short - SAMPLETIME
if to_short <= 0:
#loggo e invio dati
try:
logQue.info( '>' + value + ' ['+ cont +']')
errormsglen = 0
accoda()
contatore()
except:
logPro.error("URLBROWSER: errore registrazione valore e accoda TO_short")
pass
to_short = TIMEOUTSHORT
to_enable = False # dopo un colpo il timer breve viene disabilitato
to_long = TIMEOUTLONG
# gestione timeout lungo
to_long = to_long - SAMPLETIME
if to_long <= 0:
#loggo e invio dati
try:
logQue.info( '>>' + value + ' ['+ cont +']')
errormsglen = 0
accoda()
contatore()
except:
logPro.error("URLBROWSER: errore registrazione valore e accoda TO_long")
pass
to_long = TIMEOUTLONG
+363
View File
@@ -0,0 +1,363 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#---------------------------------------------------------------
import serial
import time
import sys
import datetime
import urllib
import ConfigParser
import os, sys
#---------------------------------------------------------------
# COSTANTI
MSGLEN = 9
TIMEOUTSERIALE = 10
MAXRETRY = 3
# DA FILE CONF
idxMacchina = "2001"
SAMPLETIME = 0.1
TIMEOUTSHORT = (SAMPLETIME*20)
TIMEOUTLONG = (SAMPLETIME*600)
# VAR
to_enable = False
to_short = TIMEOUTSHORT
to_long = TIMEOUTLONG
to_serial = TIMEOUTSERIALE
to_retry = MAXRETRY
errormsglen = 0
#---------------------------------------------------------------
# classe logger
class Logger:
def __init__(self, filename):
try:
self.filename = filename
except:
logga("LOGGER: errore try su self.filename")
sys.exit(1)
def __call__(self, string):
try:
file = open(self.filename, 'a')
file.write('[' + time.strftime("%Y-%m-%d %H:%M:%S") + '] ')
file.write(string + '\n')
file.close()
except:
logga("LOGGER: errore try su scrittura")
sys.exit(1)
#---------------------------------------------------------------
# lettura buffer seriale e pulizia caratteri non stampabili
# ritorna '' se non c'è un messaggio buono o il messaggio pulito ( due bytes hex )
# il messaggio ha il formato xx<ACK>i00 00<CR><LF>xxx
def readSeriale():
global to_serial
global to_retry
global errormsglen
ret = ''
current = ''
i = 0
# ritorna '' se non ci sono abbastanza caratteri
try:
if ser.inWaiting() < MSGLEN :
#
# to_serial = to_serial - 1 # se non mi risponde, faccio un ' altra richiesta....
# if to_serial <= 0:
# try:
# requestData ()
# except:
# logga("SERIALE: errore su requestData")
# sys.exit(1)
# to_serial = TIMEOUTSERIALE # ripristino timer
# to_retry = to_retry - 1 # contatore retry
# if to_retry <= 0:
# logga ( 'IOB not responding' )
# return ret
logga("SERIALE: errore msglen < 9 char - Errore no. " + str(errormsglen))
errormsglen = errormsglen +1
avviaSeriale()
time.sleep(.2)
if errormsglen > 30:
sys.exit(1)
except:
if startstatus == 0:
logga ("Porta SERIALE non disponibile - ser.inWaiting error - exit... - Errore no. " + str(errormsglen))
errormsglen = errormsglen +1
avviaSeriale()
time.sleep(.2)
if errormsglen > 30:
sys.exit(1)
# finchè c'è robba .. leggi e tieni i buoni
to_serial = TIMEOUTSERIALE
to_retry = MAXRETRY
try:
while ser.inWaiting() > 0 :
try:
c = ser.read(1)
except:
logga("SERIALE: errore su try ser.read")
sys.exit(1)
# filtra caratteri non stampabili
if c > ' ' :
current += c
#sys.stdout.write(current + '<<<<\n')
# ora il messaggio ha il formato xxxxxi00 00xxx : cerco la 'i' iniziale
try:
while i < len(current) and current[i] != 'i':
i = i + 1
except:
logga("SERIALE: errore su ricerca i iniziale")
sys.exit(1)
# se non ho trovato la 'i' restituisco ''
if i == len(current)-1:
return ret
else:
current = current[i+1:i+3]
# richiesta dati ad IOB
requestData()
#sys.stdout.write ( current + '\n')
except:
if startstatus == 0:
logga ('Porta SERIALE non disponibile - ser.inWaiting e filtraggio error...exit')
sys.exit(1)
return current
#---------------------------------------------------------------
# richiesta dati ad IOB : scrittura su seriale
def requestData ():
try :
ser.write ("$i" + '\r\n')
ser.flush()
except :
if startstatus == 0:
logga ( "SERIAL: Errore di scrittura/flush")
#---------------------------------------------------------------
#Funzione di scrittura su url con try-except
def chiamaUrl():
try:
url = URLBASE + idxMacchina + URLADV1 + value
urllib.urlopen ( url )
except:
logga ( "NETWORK:Errore http-no com rete-timeout" + url )
#---------------------------------------------------------------
# Funzione che verifica possibilità di creare log e include testo corrente
def logga(message) :
try:
log(message)
except :
pass
#---------------------------------------------------------------
def avviaSeriale():
global ser
try:
ser = serial.Serial(
port = comm_port ,
baudrate = 9600 ,
parity = serial.PARITY_NONE ,
stopbits = serial.STOPBITS_ONE ,
bytesize = serial.EIGHTBITS
)
startstatus = 0
except serial.serialutil.SerialException , e :
try:
if startstatus == 0:
logga ( "SERIAL:Errore apertura seriale - " + comm_port)
except:
pass
sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e )
if errormsglen > 30:
sys.exit (1)
#---------------------------------------------------------------
#---------------------------------------------------------------
# MAIN
try:
config = ConfigParser.RawConfigParser()
config.read ( 'readSeriale.cfg' )
SAMPLETIME = config.getfloat ( 'time' , 'SAMPLETIME' )
TIMEOUTSHORT = config.getfloat ( 'time' , 'TIMEOUTSHORT' )
TIMEOUTLONG = config.getfloat ( 'time' , 'TIMEOUTLONG' )
idxMacchina = config.get ( 'id' , 'idxMacchina' )
comm_port = config.get ( 'comm' , 'port' )
URLBASE = config.get ( 'web' , 'URLBASE' )
URLADV1 = config.get ( 'web' , 'URLADV1' )
LOGFILE = config.get ( 'log' , 'LOGFILE' )
LOGLEVEL = config.get ( 'log' , 'LOGLEVEL' )
except:
sys.exit(1)
# oggetto Logger
try:
log = Logger(LOGFILE)
except:
# manda mail o simili - FARE!!!
print "LOG: Impossibile creare file log con nome "
print (LOGFILE)
print '\n\n Read seriale IOB v.0.2 !!!!\n'
global startstatus
startstatus = 1
if startstatus == 1:
logga("Avvio Programma")
# Verifica l'OS e di conseguenza carica il file relativo con metodo di lockfile appropriato + check singola istanza
if os.name == 'posix':
import unix
else:
import win
logga ( "Start Read seriale IOB v.0.2")
# lettura file configurazione
# [comm]
# port = /dev/ttyS0
# [id]
# idxMacchina = 2001
# [time]
# SAMPLETIME = 0.1
# TIMEOUTSHORT = 200
# TIMEOUTLONG = 6000
print ( ' comm_port = %s' % ( comm_port ) )
print ( ' idxMacchina = %s' % ( idxMacchina ) )
print ( ' SAMPLETIME = %4.2f' % ( SAMPLETIME ) )
print ( ' TIMEOUTSHORT = %4.2f' % ( TIMEOUTSHORT ) )
print ( ' TIMEOUTLONG = %4.2f' % ( TIMEOUTLONG ) )
print ( ' URLBASE = %s' % ( URLBASE ) )
print ( ' URLADV1 = %s' % ( URLADV1 ) )
print ( ' LOGFILE = %s' % ( LOGFILE ) )
print ( ' LOGLEVEL = %s' % ( LOGLEVEL ) )
# -sys.stdout.write ( 'idxMacchina ?' + idxMacchina + '\n')
to_short = TIMEOUTSHORT
to_long = TIMEOUTLONG
#--------------------------------------------------------------
#---------------------------------------------------------------
# apertura seriale
avviaSeriale()
#try:
# ser = serial.Serial(
# port = comm_port ,
# baudrate = 9600 ,
# parity = serial.PARITY_NONE ,
# stopbits = serial.STOPBITS_ONE ,
# bytesize = serial.EIGHTBITS
# )
# print "Initialized!"
#except serial.serialutil.SerialException , e :
# try:
# logga ( "SERIAL:Errore apertura seriale - " + comm_port)
# except:
# pass
# sys.stdout.write ( '\nErrore apertura seriale\n\n%s\n\n' % e )
# sys.exit (1)
#---------------------------------------------------------------
# ciclo forever and ever
old = ''
# richiesta dati ad IOB
try:
requestData()
except:
logga("SERIALE: errore sul try di requestData")
sys.exit(1)
while 1:
try:
time.sleep (SAMPLETIME)
except:
logga("SERIALE_SLEEP: errore attesa sampletime")
# lettura dati da IOB
try:
value = readSeriale()
except:
if startstatus == 0:
logga("errore PRIMA LETTURA SERIALE")
sys.exit(1)
if ( value != '' ) :
if value != old :
#loggo e invio dati
try:
logga ( value )
errormsglen = 0
chiamaUrl()
except:
logga("URLBROWSER: errore registrazione valore e chiamaUrl")
pass
#enable e reset timer
to_enable = True
to_short = TIMEOUTSHORT
to_long = TIMEOUTLONG
old = value
# gestione timeout breve
if ( to_enable ) :
to_short = to_short - SAMPLETIME
if to_short <= 0:
#loggo e invio dati
try:
logga ( '>' + value )
errormsglen = 0
chiamaUrl()
except:
pass
to_short = TIMEOUTSHORT
to_enable = False # dopo un colpo il timer breve viene disabilitato
to_long = TIMEOUTLONG
# gestione timeout lungo
to_long = to_long - SAMPLETIME
if to_long <= 0:
#loggo e invio dati
try:
logga ( '>>' + value )
errormsglen = 0
chiamaUrl()
except:
pass
to_long = TIMEOUTLONG
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
#salva la temperatura CPU e GPU su chiamata...
# imposto logfile...
logFile="/var/log/logTemp.txt"
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))
gpuTemp=`vcgencmd measure_temp`
loadAvg=`cat /proc/loadavg`
echo "$(date) | CPU: temp=$cpuTemp1.$cpuTempM ºC | GPU: $gpuTemp | LoadAvg: $loadAvg" >> $logFile
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# sendReboot v. 1.8
#---------------------------------------------------------------
import time
import sys
from datetime import datetime
import urllib
import ConfigParser
import os, sys
import logging
import time
#---------------------------------------------------------------
# COSTANTI
PROGRAM_NAME = "SendReboot IOB-pi v.1.8"
# DA FILE CONF
idxMacchina = "99"
# registro se ho fatto chiamata
global numTry
numTry = 1
#---------------------------------------------------------------
#Funzione di scrittura su url con try-except
#---------------------------------------------------------------
def chiamaUrl(numTry):
try:
urllib.urlopen ( url )
numTry = numTry + 10
except Exception, e:
print e
logging.info ( e )
print "Url aforte" , url
return numTry
#---------------------------------------------------------------
# Funzione di recupero mac address per poterlo inviare a MPIO
#---------------------------------------------------------------
def getMAC(interface):
# Return the MAC address of interface
try:
str = open('/sys/class/net/' + interface + '/address').read()
except:
str = "00:00:00:00:00:00"
return str[0:17]
#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------
try:
config = ConfigParser.RawConfigParser()
config.read ( 'IOB.cfg' )
idxMacchina = config.get ( 'id' , 'idxMacchina' )
URLREBO = config.get ( 'web' , 'URLREBO' )
LOGFILE = config.get ( 'log' , 'LOGREBO' )
except:
print "\n\n" + PROGRAM_NAME + ' - Error 4 - in config file ' 'IOB.cfg'
sys.exit(1)
#--------------------------------------------
# oggetto Logger
#--------------------------------------------
try:
# log = Logger(LOGFILE)
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-8s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
filename=LOGFILE,
filemode='a')
except:
# manda mail o simili - FARE!!!
print "LOG: Impossibile creare file log con nome "
print (LOGFILE)
#--------------------------------------------
print "\n\n" + PROGRAM_NAME + "\n\n"
global startstatus
startstatus = 1
if startstatus == 1:
logging.info("Avvio Programma " + PROGRAM_NAME)
# lettura file configurazione
print ( ' idxMacchina = %s' % ( idxMacchina ) )
print ( ' URLREBO = %s' % ( URLREBO ) )
print ( ' LOGFILE = %s' % ( LOGFILE ) )
# lettura mac address
myMac = getMAC('eth0')
print ( ' MAC Address = %s' % ( myMac ) )
# configuro URL da inviare
url = URLREBO + idxMacchina + "&mac=" + myMac
# modifica: cerco se ho inviato segnale altrimenti ritento invio...
while (numTry < 11):
logging.info("Tentativo invio URL: " + `numTry` )
numTry = chiamaUrl(numTry)
time.sleep(3)
numTry = numTry + 1
# registro che ho inviato!
logging.info("Inviato segnale di reboot!: " + url )
+33
View File
@@ -0,0 +1,33 @@
#!/bin/sh -
#
### BEGIN INIT INFO
# Provides: sendReboot
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Steamware's IOB reboot signal
# Description: Steamware's sendReboot segnalazione reboot dispositivo
### END INIT INFO
#! /bin/sh
# /etc/init.d/sendReboot
export HOME
case "$1" in
start)
cd /home/pi/steamware
echo "Starting sendReboot"
/usr/bin/python ./sendReboot.py 2>&1 &
echo "Verifica Rete e file IOB"
/usr/local/bin/setIobConf.sh
;;
*)
echo "Usage: /etc/init.d/sendReboot {start}"
exit 1
;;
esac
exit 0
+22
View File
@@ -0,0 +1,22 @@
[Unit]
SourcePath=/etc/init.d/sendRebootIOB
Description=LSB: Steamware's IOB reboot signal
Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target
Wants=network-online.target
After=network.target network-online.target auditd.service
Conflicts=shutdown.target
[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
SysVStartPriority=2
ExecStart=/etc/init.d/sendRebootIOB start
ExecStop=/etc/init.d/sendRebootIOB stop
[Install]
WantedBy=multi-user.target
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# verifico se sia rete donati o rete steamware o offline...
netStatus=`cat /sys/class/net/eth0/operstate`
iaddr=`ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1`
cd /home/pi/steamware
if [[ $netStatus != "up" ]]
then
echo "Siamo Offline, pagina demo!"
elif [[ $iaddr == "10.74.82"* ]]
then
cp IOB.cfg.steamware IOB.cfg -f
echo "Siamo in Steamware!"
elif [[ $iaddr == "192.168.51"* ]]
then
cp IOB.cfg.donati IOB.cfg -f
echo "Siamo a Passirano!"
else
echo "Siamo altrove, pagina demo!"
fi
echo "$iaddr"
chown pi:pi *
+31
View File
@@ -0,0 +1,31 @@
import fcntl
import os
import logging
#---------------------------------------------------------------
# meccanismo di file lock per evitare multiple instances
# The function will try to lock the file specified , if it success, return True, else return False.
# The nice thing is that the lock will be dropped when the program terminates.
# >>>Use :
# if not lockFile(".lock.pod"):
# sys.exit(0)
def lockFile ( lockfile ) :
fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY )
try:
# Request exclusive (EX) non-blocking (NB) advisory lock.
fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB )
except IOError:
return False
return True
if not lockFile ( ".lockfile" ) :
print '\n noi non siamo soli ...\n'
logging.error( "LOCK: Piu istanze aperte")
#sys.exit ( 0 )
#- print '\n running alone ...\n'
+32
View File
@@ -0,0 +1,32 @@
import win32api
print " Running on WINDOWS\n"
import os
#---------------------------------------------------------------
# meccanismo di file lock per evitare multiple instances
# The function will try to lock the file specified , if it success, return True, else return False.
# The nice thing is that the lock will be dropped when the program terminates.
# >>>Use :
# if not lockFile(".lock.pod"):
# sys.exit(0)
def lockFile ( lockfile ) :
try:
fd = os.open ( lockfile , os.O_CREAT | os.O_TRUNC | os.O_WRONLY )
except:
logga("Errore nel file WIN.PY per FD")
try:
# Request exclusive (EX) non-blocking (NB) advisory lock.
#fcntl.lockf ( fd , fcntl.LOCK_EX | fcntl.LOCK_NB )
print " Dummy Method! Completa Lockfile\n"
except IOError:
return False
return True
try:
if not lockFile ( ".lockfile" ) :
print '\n noi non siamo soli ...\n'
logga ( "LOCK: Piu istanze aperte")
sys.exit ( 0 )
except:
logga("if not lockfile NON RIUSCITO in file WIN.PY")
sys.exit(1)
+193
View File
@@ -0,0 +1,193 @@
IdxFamigliaIngresso;IdxMicroStato;ValoreIngresso;IdxTipoEvento;next_IdxMicroStato
29;0;0;14;1
29;0;1;24;6
29;0;2;14;1
29;0;3;24;6
29;0;4;14;1
29;0;5;24;6
29;0;6;14;1
29;0;7;24;6
29;0;8;14;1
29;0;9;24;6
29;0;10;14;1
29;0;11;24;6
29;0;12;14;1
29;0;13;24;6
29;0;14;14;1
29;0;15;24;6
29;0;16;14;1
29;0;17;16;3
29;0;18;14;1
29;0;19;15;2
29;0;20;14;1
29;0;21;22;4
29;0;22;14;1
29;0;23;22;4
29;0;24;14;1
29;0;25;18;5
29;0;26;14;1
29;0;27;18;5
29;0;28;14;1
29;0;29;18;5
29;0;30;14;1
29;0;31;18;5
29;1;1;24;6
29;1;3;24;6
29;1;5;24;6
29;1;7;24;6
29;1;9;24;6
29;1;11;24;6
29;1;13;24;6
29;1;15;24;6
29;1;17;16;3
29;1;19;15;2
29;1;21;22;4
29;1;23;22;4
29;1;25;18;5
29;1;27;18;5
29;1;29;18;5
29;1;31;18;5
29;2;0;14;1
29;2;1;24;6
29;2;2;14;1
29;2;3;24;6
29;2;4;14;1
29;2;5;24;6
29;2;6;14;1
29;2;7;24;6
29;2;8;14;1
29;2;9;24;6
29;2;10;14;1
29;2;11;24;6
29;2;12;14;1
29;2;13;24;6
29;2;14;14;1
29;2;15;24;6
29;2;16;14;1
29;2;17;16;3
29;2;18;14;1
29;2;20;14;1
29;2;21;22;4
29;2;22;14;1
29;2;23;22;4
29;2;24;14;1
29;2;25;18;5
29;2;26;14;1
29;2;27;18;5
29;2;28;14;1
29;2;29;18;5
29;2;30;14;1
29;2;31;18;5
29;3;0;14;1
29;3;1;24;6
29;3;2;14;1
29;3;3;24;6
29;3;4;14;1
29;3;5;24;6
29;3;6;14;1
29;3;7;24;6
29;3;8;14;1
29;3;9;24;6
29;3;10;14;1
29;3;11;24;6
29;3;12;14;1
29;3;13;24;6
29;3;14;14;1
29;3;15;24;6
29;3;16;14;1
29;3;18;14;1
29;3;19;15;2
29;3;20;14;1
29;3;21;22;4
29;3;22;14;1
29;3;23;22;4
29;3;24;14;1
29;3;25;18;5
29;3;26;14;1
29;3;27;18;5
29;3;28;14;1
29;3;29;18;5
29;3;30;14;1
29;3;31;18;5
29;4;0;14;1
29;4;1;24;6
29;4;2;14;1
29;4;3;24;6
29;4;4;14;1
29;4;5;24;6
29;4;6;14;1
29;4;7;24;6
29;4;8;14;1
29;4;9;24;6
29;4;10;14;1
29;4;11;24;6
29;4;12;14;1
29;4;13;24;6
29;4;14;14;1
29;4;15;24;6
29;4;16;14;1
29;4;17;16;3
29;4;18;14;1
29;4;19;15;2
29;4;20;14;1
29;4;22;14;1
29;4;24;14;1
29;4;25;18;5
29;4;26;14;1
29;4;27;18;5
29;4;28;14;1
29;4;29;18;5
29;4;30;14;1
29;4;31;18;5
29;5;0;14;1
29;5;1;24;6
29;5;2;14;1
29;5;3;24;6
29;5;4;14;1
29;5;5;24;6
29;5;6;14;1
29;5;7;24;6
29;5;8;14;1
29;5;9;24;6
29;5;10;14;1
29;5;11;24;6
29;5;12;14;1
29;5;13;24;6
29;5;14;14;1
29;5;15;24;6
29;5;16;14;1
29;5;17;16;3
29;5;18;14;1
29;5;19;15;2
29;5;20;14;1
29;5;21;22;4
29;5;22;14;1
29;5;23;22;4
29;5;24;14;1
29;5;26;14;1
29;5;28;14;1
29;5;30;14;1
29;6;0;14;1
29;6;2;14;1
29;6;4;14;1
29;6;6;14;1
29;6;8;14;1
29;6;10;14;1
29;6;12;14;1
29;6;14;14;1
29;6;16;14;1
29;6;17;16;3
29;6;18;14;1
29;6;19;15;2
29;6;20;14;1
29;6;21;22;4
29;6;22;14;1
29;6;23;22;4
29;6;24;14;1
29;6;25;18;5
29;6;26;14;1
29;6;27;18;5
29;6;28;14;1
29;6;29;18;5
29;6;30;14;1
29;6;31;18;5
1 IdxFamigliaIngresso IdxMicroStato ValoreIngresso IdxTipoEvento next_IdxMicroStato
2 29 0 0 14 1
3 29 0 1 24 6
4 29 0 2 14 1
5 29 0 3 24 6
6 29 0 4 14 1
7 29 0 5 24 6
8 29 0 6 14 1
9 29 0 7 24 6
10 29 0 8 14 1
11 29 0 9 24 6
12 29 0 10 14 1
13 29 0 11 24 6
14 29 0 12 14 1
15 29 0 13 24 6
16 29 0 14 14 1
17 29 0 15 24 6
18 29 0 16 14 1
19 29 0 17 16 3
20 29 0 18 14 1
21 29 0 19 15 2
22 29 0 20 14 1
23 29 0 21 22 4
24 29 0 22 14 1
25 29 0 23 22 4
26 29 0 24 14 1
27 29 0 25 18 5
28 29 0 26 14 1
29 29 0 27 18 5
30 29 0 28 14 1
31 29 0 29 18 5
32 29 0 30 14 1
33 29 0 31 18 5
34 29 1 1 24 6
35 29 1 3 24 6
36 29 1 5 24 6
37 29 1 7 24 6
38 29 1 9 24 6
39 29 1 11 24 6
40 29 1 13 24 6
41 29 1 15 24 6
42 29 1 17 16 3
43 29 1 19 15 2
44 29 1 21 22 4
45 29 1 23 22 4
46 29 1 25 18 5
47 29 1 27 18 5
48 29 1 29 18 5
49 29 1 31 18 5
50 29 2 0 14 1
51 29 2 1 24 6
52 29 2 2 14 1
53 29 2 3 24 6
54 29 2 4 14 1
55 29 2 5 24 6
56 29 2 6 14 1
57 29 2 7 24 6
58 29 2 8 14 1
59 29 2 9 24 6
60 29 2 10 14 1
61 29 2 11 24 6
62 29 2 12 14 1
63 29 2 13 24 6
64 29 2 14 14 1
65 29 2 15 24 6
66 29 2 16 14 1
67 29 2 17 16 3
68 29 2 18 14 1
69 29 2 20 14 1
70 29 2 21 22 4
71 29 2 22 14 1
72 29 2 23 22 4
73 29 2 24 14 1
74 29 2 25 18 5
75 29 2 26 14 1
76 29 2 27 18 5
77 29 2 28 14 1
78 29 2 29 18 5
79 29 2 30 14 1
80 29 2 31 18 5
81 29 3 0 14 1
82 29 3 1 24 6
83 29 3 2 14 1
84 29 3 3 24 6
85 29 3 4 14 1
86 29 3 5 24 6
87 29 3 6 14 1
88 29 3 7 24 6
89 29 3 8 14 1
90 29 3 9 24 6
91 29 3 10 14 1
92 29 3 11 24 6
93 29 3 12 14 1
94 29 3 13 24 6
95 29 3 14 14 1
96 29 3 15 24 6
97 29 3 16 14 1
98 29 3 18 14 1
99 29 3 19 15 2
100 29 3 20 14 1
101 29 3 21 22 4
102 29 3 22 14 1
103 29 3 23 22 4
104 29 3 24 14 1
105 29 3 25 18 5
106 29 3 26 14 1
107 29 3 27 18 5
108 29 3 28 14 1
109 29 3 29 18 5
110 29 3 30 14 1
111 29 3 31 18 5
112 29 4 0 14 1
113 29 4 1 24 6
114 29 4 2 14 1
115 29 4 3 24 6
116 29 4 4 14 1
117 29 4 5 24 6
118 29 4 6 14 1
119 29 4 7 24 6
120 29 4 8 14 1
121 29 4 9 24 6
122 29 4 10 14 1
123 29 4 11 24 6
124 29 4 12 14 1
125 29 4 13 24 6
126 29 4 14 14 1
127 29 4 15 24 6
128 29 4 16 14 1
129 29 4 17 16 3
130 29 4 18 14 1
131 29 4 19 15 2
132 29 4 20 14 1
133 29 4 22 14 1
134 29 4 24 14 1
135 29 4 25 18 5
136 29 4 26 14 1
137 29 4 27 18 5
138 29 4 28 14 1
139 29 4 29 18 5
140 29 4 30 14 1
141 29 4 31 18 5
142 29 5 0 14 1
143 29 5 1 24 6
144 29 5 2 14 1
145 29 5 3 24 6
146 29 5 4 14 1
147 29 5 5 24 6
148 29 5 6 14 1
149 29 5 7 24 6
150 29 5 8 14 1
151 29 5 9 24 6
152 29 5 10 14 1
153 29 5 11 24 6
154 29 5 12 14 1
155 29 5 13 24 6
156 29 5 14 14 1
157 29 5 15 24 6
158 29 5 16 14 1
159 29 5 17 16 3
160 29 5 18 14 1
161 29 5 19 15 2
162 29 5 20 14 1
163 29 5 21 22 4
164 29 5 22 14 1
165 29 5 23 22 4
166 29 5 24 14 1
167 29 5 26 14 1
168 29 5 28 14 1
169 29 5 30 14 1
170 29 6 0 14 1
171 29 6 2 14 1
172 29 6 4 14 1
173 29 6 6 14 1
174 29 6 8 14 1
175 29 6 10 14 1
176 29 6 12 14 1
177 29 6 14 14 1
178 29 6 16 14 1
179 29 6 17 16 3
180 29 6 18 14 1
181 29 6 19 15 2
182 29 6 20 14 1
183 29 6 21 22 4
184 29 6 22 14 1
185 29 6 23 22 4
186 29 6 24 14 1
187 29 6 25 18 5
188 29 6 26 14 1
189 29 6 27 18 5
190 29 6 28 14 1
191 29 6 29 18 5
192 29 6 30 14 1
193 29 6 31 18 5
+83
View File
@@ -0,0 +1,83 @@
#
# Donati Macchina EMCO LM1200
#
# partenza da DMG 1035
# v.1 - aggiunto segnale porta CHIUSA = AUTOMATICO bit4 (bit4 è sensore HW montato)
# v.2 - gestione verde lampeggiante: IOB-PI gestisce il RUN come segnale INVERSO + blink
#
#
$DEFINITIONS
$NAME : EMCO_LM1200
$IDX : 29
$N_STATES : 7
$N_BITS : 5
#definizione bit : obbligatorio iniziare da 0
$BIT : 0 : power_on
$BIT : 1 : not_run
$BIT : 2 : end_cycle
$BIT : 3 : alarm
$BIT : 4 : door_closed
#definizione stati : obbligatorio iniziare da 0
$STATE : 0 : ST_Init
$STATE : 1 : ST_Power_off
$STATE : 2 : ST_Machine_ready
$STATE : 3 : ST_Run
$STATE : 4 : ST_Cycle_end
$STATE : 5 : ST_Alarm
$STATE : 6 : ST_Manual
#definizione eventi : obbligatorio iniziare da 0
$EVENT : 00 : EV_00
$EVENT : 01 : EV_01
$EVENT : 02 : EV_02
$EVENT : 03 : EV_03
$EVENT : 04 : EV_04
$EVENT : 05 : EV_05
$EVENT : 06 : EV_06
$EVENT : 07 : EV_07
$EVENT : 08 : EV_08
$EVENT : 09 : EV_09
$EVENT : 10 : EV_10
$EVENT : 11 : EV_11
$EVENT : 12 : EV_12
$EVENT : 13 : HW - init
$EVENT : 14 : HW - power off
$EVENT : 15 : HW - power on
$EVENT : 16 : HW - machining
$EVENT : 17 : HW - end machining
$EVENT : 18 : HW - error
$EVENT : 19 : Barcode - cambio operatore
$EVENT : 20 : Contapezzi
$EVENT : 21 : HW - start pallet
$EVENT : 22 : HW - end pallet
$EVENT : 23 : HW rottura nastro abrasivo
$EVENT : 24 : HW manuale
$EVENT : 25 : HW nastro scarico pieno
$EVENT : 26 : Barcode - Manca Riforn. MPD
$EVENT : 27 : Timer - timeout tempo ciclo
$EVENT : 28 : Timer - timeout TURNO by tempo ciclo
$EVENT : 29 : HW - magazzino grezzi vuoto
$EVENT : 30 : HW - emergenza
$RULES
# state : input : next state : event
ALL_STATES : NOT power_on : ST_Power_off : HW - power off
ALL_STATES : NOT door_closed : ST_Manual : HW manuale
ALL_STATES : alarm : ST_Alarm : HW - error
ALL_STATES : end_cycle : ST_Cycle_end : HW - end pallet
ALL_STATES : NOT not_run : ST_Run : HW - machining
ALL_STATES : power_on : ST_Machine_ready : HW - power on
#--------------------------------------------------------------------------
$DO
+193
View File
@@ -0,0 +1,193 @@
IdxFamigliaIngresso;IdxMicroStato;ValoreIngresso;IdxTipoEvento;next_IdxMicroStato
30;0;0;14;1
30;0;1;16;3
30;0;2;14;1
30;0;3;15;2
30;0;4;14;1
30;0;5;22;4
30;0;6;14;1
30;0;7;22;4
30;0;8;14;1
30;0;9;18;5
30;0;10;14;1
30;0;11;18;5
30;0;12;14;1
30;0;13;22;4
30;0;14;14;1
30;0;15;22;4
30;0;16;14;1
30;0;17;24;6
30;0;18;14;1
30;0;19;24;6
30;0;20;14;1
30;0;21;22;4
30;0;22;14;1
30;0;23;22;4
30;0;24;14;1
30;0;25;24;6
30;0;26;14;1
30;0;27;24;6
30;0;28;14;1
30;0;29;22;4
30;0;30;14;1
30;0;31;22;4
30;1;1;16;3
30;1;3;15;2
30;1;5;22;4
30;1;7;22;4
30;1;9;18;5
30;1;11;18;5
30;1;13;22;4
30;1;15;22;4
30;1;17;24;6
30;1;19;24;6
30;1;21;22;4
30;1;23;22;4
30;1;25;24;6
30;1;27;24;6
30;1;29;22;4
30;1;31;22;4
30;2;0;14;1
30;2;1;16;3
30;2;2;14;1
30;2;4;14;1
30;2;5;22;4
30;2;6;14;1
30;2;7;22;4
30;2;8;14;1
30;2;9;18;5
30;2;10;14;1
30;2;11;18;5
30;2;12;14;1
30;2;13;22;4
30;2;14;14;1
30;2;15;22;4
30;2;16;14;1
30;2;17;24;6
30;2;18;14;1
30;2;19;24;6
30;2;20;14;1
30;2;21;22;4
30;2;22;14;1
30;2;23;22;4
30;2;24;14;1
30;2;25;24;6
30;2;26;14;1
30;2;27;24;6
30;2;28;14;1
30;2;29;22;4
30;2;30;14;1
30;2;31;22;4
30;3;0;14;1
30;3;2;14;1
30;3;3;15;2
30;3;4;14;1
30;3;5;22;4
30;3;6;14;1
30;3;7;22;4
30;3;8;14;1
30;3;9;18;5
30;3;10;14;1
30;3;11;18;5
30;3;12;14;1
30;3;13;22;4
30;3;14;14;1
30;3;15;22;4
30;3;16;14;1
30;3;17;24;6
30;3;18;14;1
30;3;19;24;6
30;3;20;14;1
30;3;21;22;4
30;3;22;14;1
30;3;23;22;4
30;3;24;14;1
30;3;25;24;6
30;3;26;14;1
30;3;27;24;6
30;3;28;14;1
30;3;29;22;4
30;3;30;14;1
30;3;31;22;4
30;4;0;14;1
30;4;1;16;3
30;4;2;14;1
30;4;3;15;2
30;4;4;14;1
30;4;6;14;1
30;4;8;14;1
30;4;9;18;5
30;4;10;14;1
30;4;11;18;5
30;4;12;14;1
30;4;14;14;1
30;4;16;14;1
30;4;17;24;6
30;4;18;14;1
30;4;19;24;6
30;4;20;14;1
30;4;22;14;1
30;4;24;14;1
30;4;25;24;6
30;4;26;14;1
30;4;27;24;6
30;4;28;14;1
30;4;30;14;1
30;5;0;14;1
30;5;1;16;3
30;5;2;14;1
30;5;3;15;2
30;5;4;14;1
30;5;5;22;4
30;5;6;14;1
30;5;7;22;4
30;5;8;14;1
30;5;10;14;1
30;5;12;14;1
30;5;13;22;4
30;5;14;14;1
30;5;15;22;4
30;5;16;14;1
30;5;17;24;6
30;5;18;14;1
30;5;19;24;6
30;5;20;14;1
30;5;21;22;4
30;5;22;14;1
30;5;23;22;4
30;5;24;14;1
30;5;25;24;6
30;5;26;14;1
30;5;27;24;6
30;5;28;14;1
30;5;29;22;4
30;5;30;14;1
30;5;31;22;4
30;6;0;14;1
30;6;1;16;3
30;6;2;14;1
30;6;3;15;2
30;6;4;14;1
30;6;5;22;4
30;6;6;14;1
30;6;7;22;4
30;6;8;14;1
30;6;9;18;5
30;6;10;14;1
30;6;11;18;5
30;6;12;14;1
30;6;13;22;4
30;6;14;14;1
30;6;15;22;4
30;6;16;14;1
30;6;18;14;1
30;6;20;14;1
30;6;21;22;4
30;6;22;14;1
30;6;23;22;4
30;6;24;14;1
30;6;26;14;1
30;6;28;14;1
30;6;29;22;4
30;6;30;14;1
30;6;31;22;4
1 IdxFamigliaIngresso IdxMicroStato ValoreIngresso IdxTipoEvento next_IdxMicroStato
2 30 0 0 14 1
3 30 0 1 16 3
4 30 0 2 14 1
5 30 0 3 15 2
6 30 0 4 14 1
7 30 0 5 22 4
8 30 0 6 14 1
9 30 0 7 22 4
10 30 0 8 14 1
11 30 0 9 18 5
12 30 0 10 14 1
13 30 0 11 18 5
14 30 0 12 14 1
15 30 0 13 22 4
16 30 0 14 14 1
17 30 0 15 22 4
18 30 0 16 14 1
19 30 0 17 24 6
20 30 0 18 14 1
21 30 0 19 24 6
22 30 0 20 14 1
23 30 0 21 22 4
24 30 0 22 14 1
25 30 0 23 22 4
26 30 0 24 14 1
27 30 0 25 24 6
28 30 0 26 14 1
29 30 0 27 24 6
30 30 0 28 14 1
31 30 0 29 22 4
32 30 0 30 14 1
33 30 0 31 22 4
34 30 1 1 16 3
35 30 1 3 15 2
36 30 1 5 22 4
37 30 1 7 22 4
38 30 1 9 18 5
39 30 1 11 18 5
40 30 1 13 22 4
41 30 1 15 22 4
42 30 1 17 24 6
43 30 1 19 24 6
44 30 1 21 22 4
45 30 1 23 22 4
46 30 1 25 24 6
47 30 1 27 24 6
48 30 1 29 22 4
49 30 1 31 22 4
50 30 2 0 14 1
51 30 2 1 16 3
52 30 2 2 14 1
53 30 2 4 14 1
54 30 2 5 22 4
55 30 2 6 14 1
56 30 2 7 22 4
57 30 2 8 14 1
58 30 2 9 18 5
59 30 2 10 14 1
60 30 2 11 18 5
61 30 2 12 14 1
62 30 2 13 22 4
63 30 2 14 14 1
64 30 2 15 22 4
65 30 2 16 14 1
66 30 2 17 24 6
67 30 2 18 14 1
68 30 2 19 24 6
69 30 2 20 14 1
70 30 2 21 22 4
71 30 2 22 14 1
72 30 2 23 22 4
73 30 2 24 14 1
74 30 2 25 24 6
75 30 2 26 14 1
76 30 2 27 24 6
77 30 2 28 14 1
78 30 2 29 22 4
79 30 2 30 14 1
80 30 2 31 22 4
81 30 3 0 14 1
82 30 3 2 14 1
83 30 3 3 15 2
84 30 3 4 14 1
85 30 3 5 22 4
86 30 3 6 14 1
87 30 3 7 22 4
88 30 3 8 14 1
89 30 3 9 18 5
90 30 3 10 14 1
91 30 3 11 18 5
92 30 3 12 14 1
93 30 3 13 22 4
94 30 3 14 14 1
95 30 3 15 22 4
96 30 3 16 14 1
97 30 3 17 24 6
98 30 3 18 14 1
99 30 3 19 24 6
100 30 3 20 14 1
101 30 3 21 22 4
102 30 3 22 14 1
103 30 3 23 22 4
104 30 3 24 14 1
105 30 3 25 24 6
106 30 3 26 14 1
107 30 3 27 24 6
108 30 3 28 14 1
109 30 3 29 22 4
110 30 3 30 14 1
111 30 3 31 22 4
112 30 4 0 14 1
113 30 4 1 16 3
114 30 4 2 14 1
115 30 4 3 15 2
116 30 4 4 14 1
117 30 4 6 14 1
118 30 4 8 14 1
119 30 4 9 18 5
120 30 4 10 14 1
121 30 4 11 18 5
122 30 4 12 14 1
123 30 4 14 14 1
124 30 4 16 14 1
125 30 4 17 24 6
126 30 4 18 14 1
127 30 4 19 24 6
128 30 4 20 14 1
129 30 4 22 14 1
130 30 4 24 14 1
131 30 4 25 24 6
132 30 4 26 14 1
133 30 4 27 24 6
134 30 4 28 14 1
135 30 4 30 14 1
136 30 5 0 14 1
137 30 5 1 16 3
138 30 5 2 14 1
139 30 5 3 15 2
140 30 5 4 14 1
141 30 5 5 22 4
142 30 5 6 14 1
143 30 5 7 22 4
144 30 5 8 14 1
145 30 5 10 14 1
146 30 5 12 14 1
147 30 5 13 22 4
148 30 5 14 14 1
149 30 5 15 22 4
150 30 5 16 14 1
151 30 5 17 24 6
152 30 5 18 14 1
153 30 5 19 24 6
154 30 5 20 14 1
155 30 5 21 22 4
156 30 5 22 14 1
157 30 5 23 22 4
158 30 5 24 14 1
159 30 5 25 24 6
160 30 5 26 14 1
161 30 5 27 24 6
162 30 5 28 14 1
163 30 5 29 22 4
164 30 5 30 14 1
165 30 5 31 22 4
166 30 6 0 14 1
167 30 6 1 16 3
168 30 6 2 14 1
169 30 6 3 15 2
170 30 6 4 14 1
171 30 6 5 22 4
172 30 6 6 14 1
173 30 6 7 22 4
174 30 6 8 14 1
175 30 6 9 18 5
176 30 6 10 14 1
177 30 6 11 18 5
178 30 6 12 14 1
179 30 6 13 22 4
180 30 6 14 14 1
181 30 6 15 22 4
182 30 6 16 14 1
183 30 6 18 14 1
184 30 6 20 14 1
185 30 6 21 22 4
186 30 6 22 14 1
187 30 6 23 22 4
188 30 6 24 14 1
189 30 6 26 14 1
190 30 6 28 14 1
191 30 6 29 22 4
192 30 6 30 14 1
193 30 6 31 22 4
+82
View File
@@ -0,0 +1,82 @@
#
# Donati Macchina SCATOLE INTEC
#
# partenza da EMCO LM1200
# v.1 - gestione verde lampeggiante: IOB-PI gestisce il RUN come segnale INVERSO + blink + filt (per sicurezza?)
#
#
$DEFINITIONS
$NAME : SCATOLE_INTEC
$IDX : 30
$N_STATES : 7
$N_BITS : 5
#definizione bit : obbligatorio iniziare da 0
$BIT : 0 : power_on
$BIT : 1 : not_run
$BIT : 2 : end_cycle
$BIT : 3 : alarm
$BIT : 4 : luce_arancio
#definizione stati : obbligatorio iniziare da 0
$STATE : 0 : ST_Init
$STATE : 1 : ST_Power_off
$STATE : 2 : ST_Machine_ready
$STATE : 3 : ST_Run
$STATE : 4 : ST_Cycle_end
$STATE : 5 : ST_Alarm
$STATE : 6 : ST_Manual
#definizione eventi : obbligatorio iniziare da 0
$EVENT : 00 : EV_00
$EVENT : 01 : EV_01
$EVENT : 02 : EV_02
$EVENT : 03 : EV_03
$EVENT : 04 : EV_04
$EVENT : 05 : EV_05
$EVENT : 06 : EV_06
$EVENT : 07 : EV_07
$EVENT : 08 : EV_08
$EVENT : 09 : EV_09
$EVENT : 10 : EV_10
$EVENT : 11 : EV_11
$EVENT : 12 : EV_12
$EVENT : 13 : HW - init
$EVENT : 14 : HW - power off
$EVENT : 15 : HW - power on
$EVENT : 16 : HW - machining
$EVENT : 17 : HW - end machining
$EVENT : 18 : HW - error
$EVENT : 19 : Barcode - cambio operatore
$EVENT : 20 : Contapezzi
$EVENT : 21 : HW - start pallet
$EVENT : 22 : HW - end pallet
$EVENT : 23 : HW rottura nastro abrasivo
$EVENT : 24 : HW manuale
$EVENT : 25 : HW nastro scarico pieno
$EVENT : 26 : Barcode - Manca Riforn. MPD
$EVENT : 27 : Timer - timeout tempo ciclo
$EVENT : 28 : Timer - timeout TURNO by tempo ciclo
$EVENT : 29 : HW - magazzino grezzi vuoto
$EVENT : 30 : HW - emergenza
$RULES
# state : input : next state : event
ALL_STATES : NOT power_on : ST_Power_off : HW - power off
ALL_STATES : end_cycle : ST_Cycle_end : HW - end pallet
ALL_STATES : luce_arancio : ST_Manual : HW manuale
ALL_STATES : alarm : ST_Alarm : HW - error
ALL_STATES : NOT not_run : ST_Run : HW - machining
ALL_STATES : power_on : ST_Machine_ready : HW - power on
#--------------------------------------------------------------------------
$DO
+193
View File
@@ -0,0 +1,193 @@
IdxFamigliaIngresso;IdxMicroStato;ValoreIngresso;IdxTipoEvento;next_IdxMicroStato
31;0;0;14;1
31;0;1;24;6
31;0;2;14;1
31;0;3;24;6
31;0;4;14;1
31;0;5;22;4
31;0;6;14;1
31;0;7;22;4
31;0;8;14;1
31;0;9;24;6
31;0;10;14;1
31;0;11;24;6
31;0;12;14;1
31;0;13;22;4
31;0;14;14;1
31;0;15;22;4
31;0;16;14;1
31;0;17;15;2
31;0;18;14;1
31;0;19;16;3
31;0;20;14;1
31;0;21;22;4
31;0;22;14;1
31;0;23;22;4
31;0;24;14;1
31;0;25;18;5
31;0;26;14;1
31;0;27;18;5
31;0;28;14;1
31;0;29;22;4
31;0;30;14;1
31;0;31;22;4
31;1;1;24;6
31;1;3;24;6
31;1;5;22;4
31;1;7;22;4
31;1;9;24;6
31;1;11;24;6
31;1;13;22;4
31;1;15;22;4
31;1;17;15;2
31;1;19;16;3
31;1;21;22;4
31;1;23;22;4
31;1;25;18;5
31;1;27;18;5
31;1;29;22;4
31;1;31;22;4
31;2;0;14;1
31;2;1;24;6
31;2;2;14;1
31;2;3;24;6
31;2;4;14;1
31;2;5;22;4
31;2;6;14;1
31;2;7;22;4
31;2;8;14;1
31;2;9;24;6
31;2;10;14;1
31;2;11;24;6
31;2;12;14;1
31;2;13;22;4
31;2;14;14;1
31;2;15;22;4
31;2;16;14;1
31;2;18;14;1
31;2;19;16;3
31;2;20;14;1
31;2;21;22;4
31;2;22;14;1
31;2;23;22;4
31;2;24;14;1
31;2;25;18;5
31;2;26;14;1
31;2;27;18;5
31;2;28;14;1
31;2;29;22;4
31;2;30;14;1
31;2;31;22;4
31;3;0;14;1
31;3;1;24;6
31;3;2;14;1
31;3;3;24;6
31;3;4;14;1
31;3;5;22;4
31;3;6;14;1
31;3;7;22;4
31;3;8;14;1
31;3;9;24;6
31;3;10;14;1
31;3;11;24;6
31;3;12;14;1
31;3;13;22;4
31;3;14;14;1
31;3;15;22;4
31;3;16;14;1
31;3;17;15;2
31;3;18;14;1
31;3;20;14;1
31;3;21;22;4
31;3;22;14;1
31;3;23;22;4
31;3;24;14;1
31;3;25;18;5
31;3;26;14;1
31;3;27;18;5
31;3;28;14;1
31;3;29;22;4
31;3;30;14;1
31;3;31;22;4
31;4;0;14;1
31;4;1;24;6
31;4;2;14;1
31;4;3;24;6
31;4;4;14;1
31;4;6;14;1
31;4;8;14;1
31;4;9;24;6
31;4;10;14;1
31;4;11;24;6
31;4;12;14;1
31;4;14;14;1
31;4;16;14;1
31;4;17;15;2
31;4;18;14;1
31;4;19;16;3
31;4;20;14;1
31;4;22;14;1
31;4;24;14;1
31;4;25;18;5
31;4;26;14;1
31;4;27;18;5
31;4;28;14;1
31;4;30;14;1
31;5;0;14;1
31;5;1;24;6
31;5;2;14;1
31;5;3;24;6
31;5;4;14;1
31;5;5;22;4
31;5;6;14;1
31;5;7;22;4
31;5;8;14;1
31;5;9;24;6
31;5;10;14;1
31;5;11;24;6
31;5;12;14;1
31;5;13;22;4
31;5;14;14;1
31;5;15;22;4
31;5;16;14;1
31;5;17;15;2
31;5;18;14;1
31;5;19;16;3
31;5;20;14;1
31;5;21;22;4
31;5;22;14;1
31;5;23;22;4
31;5;24;14;1
31;5;26;14;1
31;5;28;14;1
31;5;29;22;4
31;5;30;14;1
31;5;31;22;4
31;6;0;14;1
31;6;2;14;1
31;6;4;14;1
31;6;5;22;4
31;6;6;14;1
31;6;7;22;4
31;6;8;14;1
31;6;10;14;1
31;6;12;14;1
31;6;13;22;4
31;6;14;14;1
31;6;15;22;4
31;6;16;14;1
31;6;17;15;2
31;6;18;14;1
31;6;19;16;3
31;6;20;14;1
31;6;21;22;4
31;6;22;14;1
31;6;23;22;4
31;6;24;14;1
31;6;25;18;5
31;6;26;14;1
31;6;27;18;5
31;6;28;14;1
31;6;29;22;4
31;6;30;14;1
31;6;31;22;4
1 IdxFamigliaIngresso IdxMicroStato ValoreIngresso IdxTipoEvento next_IdxMicroStato
2 31 0 0 14 1
3 31 0 1 24 6
4 31 0 2 14 1
5 31 0 3 24 6
6 31 0 4 14 1
7 31 0 5 22 4
8 31 0 6 14 1
9 31 0 7 22 4
10 31 0 8 14 1
11 31 0 9 24 6
12 31 0 10 14 1
13 31 0 11 24 6
14 31 0 12 14 1
15 31 0 13 22 4
16 31 0 14 14 1
17 31 0 15 22 4
18 31 0 16 14 1
19 31 0 17 15 2
20 31 0 18 14 1
21 31 0 19 16 3
22 31 0 20 14 1
23 31 0 21 22 4
24 31 0 22 14 1
25 31 0 23 22 4
26 31 0 24 14 1
27 31 0 25 18 5
28 31 0 26 14 1
29 31 0 27 18 5
30 31 0 28 14 1
31 31 0 29 22 4
32 31 0 30 14 1
33 31 0 31 22 4
34 31 1 1 24 6
35 31 1 3 24 6
36 31 1 5 22 4
37 31 1 7 22 4
38 31 1 9 24 6
39 31 1 11 24 6
40 31 1 13 22 4
41 31 1 15 22 4
42 31 1 17 15 2
43 31 1 19 16 3
44 31 1 21 22 4
45 31 1 23 22 4
46 31 1 25 18 5
47 31 1 27 18 5
48 31 1 29 22 4
49 31 1 31 22 4
50 31 2 0 14 1
51 31 2 1 24 6
52 31 2 2 14 1
53 31 2 3 24 6
54 31 2 4 14 1
55 31 2 5 22 4
56 31 2 6 14 1
57 31 2 7 22 4
58 31 2 8 14 1
59 31 2 9 24 6
60 31 2 10 14 1
61 31 2 11 24 6
62 31 2 12 14 1
63 31 2 13 22 4
64 31 2 14 14 1
65 31 2 15 22 4
66 31 2 16 14 1
67 31 2 18 14 1
68 31 2 19 16 3
69 31 2 20 14 1
70 31 2 21 22 4
71 31 2 22 14 1
72 31 2 23 22 4
73 31 2 24 14 1
74 31 2 25 18 5
75 31 2 26 14 1
76 31 2 27 18 5
77 31 2 28 14 1
78 31 2 29 22 4
79 31 2 30 14 1
80 31 2 31 22 4
81 31 3 0 14 1
82 31 3 1 24 6
83 31 3 2 14 1
84 31 3 3 24 6
85 31 3 4 14 1
86 31 3 5 22 4
87 31 3 6 14 1
88 31 3 7 22 4
89 31 3 8 14 1
90 31 3 9 24 6
91 31 3 10 14 1
92 31 3 11 24 6
93 31 3 12 14 1
94 31 3 13 22 4
95 31 3 14 14 1
96 31 3 15 22 4
97 31 3 16 14 1
98 31 3 17 15 2
99 31 3 18 14 1
100 31 3 20 14 1
101 31 3 21 22 4
102 31 3 22 14 1
103 31 3 23 22 4
104 31 3 24 14 1
105 31 3 25 18 5
106 31 3 26 14 1
107 31 3 27 18 5
108 31 3 28 14 1
109 31 3 29 22 4
110 31 3 30 14 1
111 31 3 31 22 4
112 31 4 0 14 1
113 31 4 1 24 6
114 31 4 2 14 1
115 31 4 3 24 6
116 31 4 4 14 1
117 31 4 6 14 1
118 31 4 8 14 1
119 31 4 9 24 6
120 31 4 10 14 1
121 31 4 11 24 6
122 31 4 12 14 1
123 31 4 14 14 1
124 31 4 16 14 1
125 31 4 17 15 2
126 31 4 18 14 1
127 31 4 19 16 3
128 31 4 20 14 1
129 31 4 22 14 1
130 31 4 24 14 1
131 31 4 25 18 5
132 31 4 26 14 1
133 31 4 27 18 5
134 31 4 28 14 1
135 31 4 30 14 1
136 31 5 0 14 1
137 31 5 1 24 6
138 31 5 2 14 1
139 31 5 3 24 6
140 31 5 4 14 1
141 31 5 5 22 4
142 31 5 6 14 1
143 31 5 7 22 4
144 31 5 8 14 1
145 31 5 9 24 6
146 31 5 10 14 1
147 31 5 11 24 6
148 31 5 12 14 1
149 31 5 13 22 4
150 31 5 14 14 1
151 31 5 15 22 4
152 31 5 16 14 1
153 31 5 17 15 2
154 31 5 18 14 1
155 31 5 19 16 3
156 31 5 20 14 1
157 31 5 21 22 4
158 31 5 22 14 1
159 31 5 23 22 4
160 31 5 24 14 1
161 31 5 26 14 1
162 31 5 28 14 1
163 31 5 29 22 4
164 31 5 30 14 1
165 31 5 31 22 4
166 31 6 0 14 1
167 31 6 2 14 1
168 31 6 4 14 1
169 31 6 5 22 4
170 31 6 6 14 1
171 31 6 7 22 4
172 31 6 8 14 1
173 31 6 10 14 1
174 31 6 12 14 1
175 31 6 13 22 4
176 31 6 14 14 1
177 31 6 15 22 4
178 31 6 16 14 1
179 31 6 17 15 2
180 31 6 18 14 1
181 31 6 19 16 3
182 31 6 20 14 1
183 31 6 21 22 4
184 31 6 22 14 1
185 31 6 23 22 4
186 31 6 24 14 1
187 31 6 25 18 5
188 31 6 26 14 1
189 31 6 27 18 5
190 31 6 28 14 1
191 31 6 29 22 4
192 31 6 30 14 1
193 31 6 31 22 4
+82
View File
@@ -0,0 +1,82 @@
#
# Donati Macchina SCATOLE ROBOTSERVICE
#
# partenza da EMCO LM1200
# v.1 - solito ma contapezzi prioritario
#
#
$DEFINITIONS
$NAME : SCATOLE_ROBOTSERVICE
$IDX : 31
$N_STATES : 7
$N_BITS : 5
#definizione bit : obbligatorio iniziare da 0
$BIT : 0 : power_on
$BIT : 1 : run
$BIT : 2 : end_cycle
$BIT : 3 : alarm
$BIT : 4 : door_closed
#definizione stati : obbligatorio iniziare da 0
$STATE : 0 : ST_Init
$STATE : 1 : ST_Power_off
$STATE : 2 : ST_Machine_ready
$STATE : 3 : ST_Run
$STATE : 4 : ST_Cycle_end
$STATE : 5 : ST_Alarm
$STATE : 6 : ST_Manual
#definizione eventi : obbligatorio iniziare da 0
$EVENT : 00 : EV_00
$EVENT : 01 : EV_01
$EVENT : 02 : EV_02
$EVENT : 03 : EV_03
$EVENT : 04 : EV_04
$EVENT : 05 : EV_05
$EVENT : 06 : EV_06
$EVENT : 07 : EV_07
$EVENT : 08 : EV_08
$EVENT : 09 : EV_09
$EVENT : 10 : EV_10
$EVENT : 11 : EV_11
$EVENT : 12 : EV_12
$EVENT : 13 : HW - init
$EVENT : 14 : HW - power off
$EVENT : 15 : HW - power on
$EVENT : 16 : HW - machining
$EVENT : 17 : HW - end machining
$EVENT : 18 : HW - error
$EVENT : 19 : Barcode - cambio operatore
$EVENT : 20 : Contapezzi
$EVENT : 21 : HW - start pallet
$EVENT : 22 : HW - end pallet
$EVENT : 23 : HW rottura nastro abrasivo
$EVENT : 24 : HW manuale
$EVENT : 25 : HW nastro scarico pieno
$EVENT : 26 : Barcode - Manca Riforn. MPD
$EVENT : 27 : Timer - timeout tempo ciclo
$EVENT : 28 : Timer - timeout TURNO by tempo ciclo
$EVENT : 29 : HW - magazzino grezzi vuoto
$EVENT : 30 : HW - emergenza
$RULES
# state : input : next state : event
ALL_STATES : NOT power_on : ST_Power_off : HW - power off
ALL_STATES : end_cycle : ST_Cycle_end : HW - end pallet
ALL_STATES : NOT door_closed : ST_Manual : HW manuale
ALL_STATES : alarm : ST_Alarm : HW - error
ALL_STATES : run : ST_Run : HW - machining
ALL_STATES : power_on : ST_Machine_ready : HW - power on
#--------------------------------------------------------------------------
$DO
+3
View File
@@ -0,0 +1,3 @@
scatole 1--> 4 e COMBI D --> contapezzi prioritario come la EMCO LM600
segnale 13 --> MANUALE / GIALLO ("attesa prenotazione magazzino") da verificare come verrà preso
POTREBBE servire timer (x scatole) x beccare QUANDO NON PRODUCE e quindi a 150% / 200% del T.C. DEVE scattare...