#include "global.th" #include "sensors.th" #include "relay.th" #include "net.th" #include "encoder.th" //==================================================================== void d(string mess){ sys.debugprint(mess+chr(13)); int c = sock.num; sock.num = 2; if (sock.statesimple == PL_SSTS_EST){ sock.setdata(mess+chr(13)+chr(10)); sock.send(); } sock.num =c; } #include "config_work.th" #include "braker.th" void on_sys_init(){ pat.play("R-R---~",PL_PAT_CANINT); config_init(); net_init(); sensor_init(); relay_init(); brakers_init(); // encoder_init(); // fd.filenum = 2; // fd.open("config"); // fd.setpointer(1); // string data = fd.getdata(250); // sys.debugprint(data+chr(13)); // fd.close(); // config.STORE_LOCATON = FLASH; // config.IP= net.ip; // config.FLASH_SIZE = 1024; // config.FLASH_FILES = 10; // config.STORE_BRAKER = true; // config.BRAKERS[0].Enable = true; // config.BRAKERS[0].SensPort = 1; // config.BRAKERS[0].DropPort = 2; // config.BRAKERS[0].Relay = 1; // config.BRAKERS[0].Timeout = 300; // config_write(config); d(""); d("Запуск системы"); d(""); d(config.IP); d("sys.version: "+sys.version); // if (left(sys.serialnum,1)==chr(255)){ // sys.setserialnum("TEST SERIAL NUMBER SETTING 0123456789-abcdefghijklmnopqrstuvwxyz"); // } d("sys.serialnum: "+sys.serialnum); d(PLATFORM ); d("fd.availableflashspace / fd.totalsize: "+str(fd.availableflashspace)+"/"+str(fd.totalsize)); d("sys.totalbuffpages: "+ str(sys.totalbuffpages)); d("sys.freebuffpages: "+str(sys.freebuffpages)); d("config.IP="+config.IP); // if (rtc.running){ // unsigned int day,min; // unsigned char second; // rtc.getdata(day,min,second); // if (day == 0) // rtc.setdata(daycount(18,10,25),mincount(19,58),1); // } sys.onsystimerperiod = 1 ; net_start(); io.num=PL_IO_NUM_46; io.enabled=YES; io.num=PL_IO_NUM_47; io.enabled=YES; io.num=PL_IO_NUM_48; io.enabled=YES; pat.play("G-R-R---~",PL_PAT_CANINT); } void on_sys_timer() { for (int i=1; i<=3; i++){ braker_proc(i); } // sensors process for (int i=1; i <= SENSORS; i++){ if (pinChange(i)){ bool state = getPinStateS(i,true); //if (getEncEnabled(i,state)) send_sensor(i,state); } } #if PLATFORM_ID != SIMULATOR sock.num = 0; io.num=PL_IO_NUM_47; io.lineset(PL_IO_NUM_48,sock.statesimple != PL_SSTS_EST); io.state=LOW; io.state=HIGH; sock.num = 1; io.lineset(PL_IO_NUM_48,sock.statesimple != PL_SSTS_EST); io.state=LOW; io.state=HIGH; sock.num = 2; io.lineset(PL_IO_NUM_48,sock.statesimple != PL_SSTS_EST); io.state=LOW; io.state=HIGH; sock.num = 3; io.lineset(PL_IO_NUM_48,sock.statesimple != PL_SSTS_EST); io.state=LOW; io.state=HIGH; io.lineset(PL_IO_NUM_48,HIGH); io.state=LOW; io.state=HIGH; #endif }