From 7a5e1ea8e75632ff19c54976665a3200ab885317 Mon Sep 17 00:00:00 2001 From: Alex Warm Date: Wed, 14 Aug 2019 12:16:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20=D1=80=D0=B5=D0=B6?= =?UTF-8?q?=D0=B8=D0=BC=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=BA=D0=B8=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=B0=20?= =?UTF-8?q?1908141216?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KSM-Line-2.2.tpr | 2 +- braker.tc | 35 ++++++++++++++++++++++++++--------- global.th | 4 +++- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/KSM-Line-2.2.tpr b/KSM-Line-2.2.tpr index b610f2e..3805a27 100644 --- a/KSM-Line-2.2.tpr +++ b/KSM-Line-2.2.tpr @@ -5,7 +5,7 @@ src_lib_ver=2_01_00 name=KSM-Line-2.0 output=KSM-Line-2.0.tpc debug=off -defines= /dLCD_TYPE=SOLOMON_SSD1963 /dOBJECT_LCD=LCD_ENABLED /dOBJECT_FD=FD_ENABLED /dOBJECT_KP=KP_ENABLED /dOBJECT_WLN=WLN_ENABLED +defines=/dLCD_TYPE=SOLOMON_SSD1963 /dOBJECT_LCD=LCD_ENABLED /dOBJECT_FD=FD_ENABLED /dOBJECT_KP=KP_ENABLED /dOBJECT_WLN=WLN_ENABLED transport=udp_broadcast [address1] platform=SIMULATOR diff --git a/braker.tc b/braker.tc index 0b1f70c..c508fbb 100644 --- a/braker.tc +++ b/braker.tc @@ -28,9 +28,11 @@ void brakers_init(){ if (config.BRAKERS[num].Enable){ config.STORE_BRAKER = true; #if PLATFORM_ID != SIMULATOR - braker_add_port(config.BRAKERS[num].SensPort); - io.num = INPIN[config.BRAKERS[num].SensPort-1]; - io.enabled=false; + if (config.BRAKERS[num].SensPort>0){ + braker_add_port(config.BRAKERS[num].SensPort); + io.num = INPIN[config.BRAKERS[num].SensPort-1]; + io.enabled=false; + } if (config.BRAKERS[num].DropPort >0){ braker_add_port(config.BRAKERS[num].DropPort); io.num = INPIN[config.BRAKERS[num].DropPort-1]; @@ -54,6 +56,7 @@ void braker_init(unsigned char number, unsigned char sensor, unsigned char drop, config.BRAKERS[num].DropPort = drop; config.BRAKERS[num].Relay = relay; config.BRAKERS[num].Timeout = timeout; + config.BRAKERS[num].Mode = sensor == 0 ? 1 : 0; brakers[num].config = &config.BRAKERS[num]; brakers[num].State = false; brakers[num].OnTime = 0; @@ -61,9 +64,11 @@ void braker_init(unsigned char number, unsigned char sensor, unsigned char drop, if (config.BRAKERS[num].Enable){ config.STORE_BRAKER = true; #if PLATFORM_ID != SIMULATOR - braker_add_port(config.BRAKERS[num].SensPort); - io.num = INPIN[config.BRAKERS[num].SensPort-1]; - io.enabled=false; + if (config.BRAKERS[num].SensPort >0){ + braker_add_port(config.BRAKERS[num].SensPort); + io.num = INPIN[config.BRAKERS[num].SensPort-1]; + io.enabled=false; + } if (config.BRAKERS[num].DropPort >0){ braker_add_port(config.BRAKERS[num].DropPort); io.num = INPIN[config.BRAKERS[num].DropPort-1]; @@ -84,8 +89,20 @@ void braker_set(string cmd){ d("Неверный формат команды = '"+cmd+"'"); string type = left(cmd,1); unsigned char num = val(right(cmd,1)); - brakers[num-1].Fifo += type; - d("Бракиратор #"+str(num)+" сигнал ["+type+"]"); + if (brakers[num-1].config->Mode == 0){ + brakers[num-1].Fifo += type; + d("Бракиратор #"+str(num)+" сигнал ["+type+"]"); + } + else{ + if (type == "G"){ + relay_set(brakers[num].config->Relay,true); + brakers[num].State = true; + d("Бракиратор #"+str(num)+" включен по сигналу сервера"); + }else{ + d("Бракиратор #"+str(num)+" получил сигнал 'B'. Игнорируем."); + } + } + } @@ -110,7 +127,7 @@ void braker_proc(unsigned char number) } } }else{ // проверка на сработку - if (pinChange(brakers[num].config->SensPort) && getPinStateS(brakers[num].config->SensPort,true)){ + if (brakers[num].config->Mode==0 && pinChange(brakers[num].config->SensPort) && getPinStateS(brakers[num].config->SensPort,true)){ if (braker_get_current(num) == "B"){ relay_set(brakers[num].config->Relay,true); brakers[num].State = true; diff --git a/global.th b/global.th index 03fef44..a33a99c 100644 --- a/global.th +++ b/global.th @@ -9,7 +9,7 @@ #message "link global not defined" #endif -#define VERSION "2.0b_1905211755" +#define VERSION "2.0b_1908141216" #define MAX_FIFO_SIZE 20 #define BRAKER_COUNT 3 @@ -43,6 +43,7 @@ typedef struct BrakerConfig{ unsigned char DropPort; unsigned char Relay; unsigned long Timeout; + unsigned char Mode; }; typedef struct BounceConfig{ @@ -131,4 +132,5 @@ extern BrakerProcess brakers[BRAKER_COUNT]; +