Browse Source

添加stsc, inspur配置

guohui 2 years ago
parent
commit
aa45aea9fa
9 changed files with 307 additions and 100 deletions
  1. 5 0
      cust_data/cfg/cfg_general.h
  2. 116 0
      cust_data/cfg/cfg_inspur.h
  3. 114 0
      cust_data/cfg/cfg_stsc.h
  4. 3 0
      pro/src/app.c
  5. 2 1
      pro/src/file.c
  6. 3 1
      pro/src/mqtt.c
  7. 52 82
      pro/src/paras.c
  8. 1 5
      pro/src/paras.h
  9. 11 11
      pub

+ 5 - 0
cust_data/cfg/cfg_general.h

@@ -39,6 +39,11 @@
 #endif
 
 
+#ifdef PRJ_GENERAL
+    #define SMTP_SEND_BUILTIN
+#endif
+
+
 #ifdef PRJ_XIAN_GOM037
     #define SMTP_SEND_BUILTIN
     

+ 116 - 0
cust_data/cfg/cfg_inspur.h

@@ -0,0 +1,116 @@
+#ifndef __CONFIG_Hx__
+#define __CONFIG_Hx__
+
+
+#define VERSION                         "V0.0.1"
+
+
+#define PROD_ID                         1
+#define PROD_TYPE                       1
+#define PROD_POWER_TYPE                 1
+
+
+#define LANGUAGE                        0
+#define SMPLE_TIME                      100         //ms
+#define SAVE_TIME                       1000        //ms
+#define CASCADE_CNT                     5
+
+#define MAX_CHN_COUNT                   16
+#define PHASE_GROUP_CNT                 8
+#define CHANNEL_DELAY_SEC               8
+
+#define USE_SMTP
+
+/////////////customer demannd//////////////////////
+//#define PRJ_XIAN_GOM037
+//#define PRJ_USA_SL
+//#define PRJ_ANDERSON
+//#define PRJ_HYPERTEC
+//#define PRJ_RUSSIA_ITK
+//#define PRJ_GENERAL
+#define PRJ_INSPUR
+//#define PRJ_TEST
+
+
+#ifdef PRJ_TEST
+    #define SMTP_SEND_BUILTIN
+    
+    #undef MAX_CHN_COUNT
+    #define MAX_CHN_COUNT               24
+#endif
+
+
+#ifdef PRJ_GENERAL
+    #define SMTP_SEND_BUILTIN
+#endif
+
+#ifdef PRJ_INSPUR
+    #define SMTP_SEND_BUILTIN
+#endif
+
+
+#ifdef PRJ_XIAN_GOM037
+    #define SMTP_SEND_BUILTIN
+    
+    #define GOM037_PDU_GC10_08K_80H        //ac_in1_out1_40a_p8_5ch_nologo_cn
+    //#define GOM037PDU_GC20_04K_125H        //ac_in1_out1_40a_p4_5ch_nologo_cn
+  
+
+    #ifdef GOM037PDU_GC20_04K_125H
+        #undef CHANNEL_DELAY_SEC
+        #define CHANNEL_DELAY_SEC        5
+    #endif
+#endif
+
+#ifdef PRJ_USA_SL
+    #define SMTP_SEND_BUILTIN
+    
+    #define PDU_GC40_03K_125H           //ac_in3_out3_40a_p8_12ch_nologo_en
+
+    //#define PDU_GC60_04K_125H         //ac_in3_out1_40a_p4_24ch_nologo_en
+#endif
+
+
+#ifdef PRJ_RUSSIA_ITK
+    #define SMTP_SEND_BUILTIN
+#endif
+
+
+#ifdef PRJ_ANDERSON
+    //#define USE_MQTT
+    //#define MQTT_SERVER_BUILTIN
+
+    #define SMTP_SEND_BUILTIN
+
+    #define USE_NETSWITCH
+
+    #define SW_STATIC_PORT_START
+    #define SW_PORT_INDEX_START         0
+    #define SW_PORT_INDEX_END           21
+
+    //#define SW_STATIC_IP
+    #ifdef SW_STATIC_IP
+        #define SW_HOST_IP              "192.168.234.1"
+        #define SW_PDU_IP               "192.168.234.132"
+    #endif
+    
+    #undef MAX_CHN_COUNT
+    #define MAX_CHN_COUNT               24
+#endif
+
+
+#ifdef PRJ_HYPERTEC
+    //ac_in3_out1_36ch_nologo_en_hypertec
+    #define SMTP_SEND_BUILTIN
+    
+    #undef PHASE_GROUP_CNT
+    #undef CHANNEL_DELAY_SEC
+
+    #define PHASE_GROUP_CNT             6
+    #define CHANNEL_DELAY_SEC           6
+#endif
+
+
+#endif
+
+

+ 114 - 0
cust_data/cfg/cfg_stsc.h

@@ -0,0 +1,114 @@
+#ifndef __CONFIG_Hx__
+#define __CONFIG_Hx__
+
+
+#define VERSION                         "V0.0.1"
+
+
+#define PROD_ID                         1
+#define PROD_TYPE                       1
+#define PROD_POWER_TYPE                 1
+
+
+#define LANGUAGE                        0
+#define SMPLE_TIME                      100         //ms
+#define SAVE_TIME                       1000        //ms
+#define CASCADE_CNT                     5
+
+#define MAX_CHN_COUNT                   16
+#define PHASE_GROUP_CNT                 8
+#define CHANNEL_DELAY_SEC               8
+
+#define USE_SMTP
+
+/////////////customer demannd//////////////////////
+//#define PRJ_XIAN_GOM037
+//#define PRJ_USA_SL
+//#define PRJ_ANDERSON
+//#define PRJ_HYPERTEC
+//#define PRJ_RUSSIA_ITK
+#define PRJ_STSC
+//#define PRJ_GENERAL
+//#define PRJ_TEST
+
+
+#ifdef PRJ_TEST
+    #define SMTP_SEND_BUILTIN
+    
+    #undef MAX_CHN_COUNT
+    #define MAX_CHN_COUNT               24
+#endif
+
+#ifdef PRJ_STSC
+    #define SMTP_SEND_BUILTIN
+    
+    #undef MAX_CHN_COUNT
+    #define MAX_CHN_COUNT               24
+#endif
+
+
+#ifdef PRJ_XIAN_GOM037
+    #define SMTP_SEND_BUILTIN
+    
+    #define GOM037_PDU_GC10_08K_80H        //ac_in1_out1_40a_p8_5ch_nologo_cn
+    //#define GOM037PDU_GC20_04K_125H        //ac_in1_out1_40a_p4_5ch_nologo_cn
+  
+
+    #ifdef GOM037PDU_GC20_04K_125H
+        #undef CHANNEL_DELAY_SEC
+        #define CHANNEL_DELAY_SEC        5
+    #endif
+#endif
+
+#ifdef PRJ_USA_SL
+    #define SMTP_SEND_BUILTIN
+    
+    #define PDU_GC40_03K_125H           //ac_in3_out3_40a_p8_12ch_nologo_en
+
+    //#define PDU_GC60_04K_125H         //ac_in3_out1_40a_p4_24ch_nologo_en
+#endif
+
+
+#ifdef PRJ_RUSSIA_ITK
+    #define SMTP_SEND_BUILTIN
+#endif
+
+
+#ifdef PRJ_ANDERSON
+    //#define USE_MQTT
+    //#define MQTT_SERVER_BUILTIN
+
+    #define SMTP_SEND_BUILTIN
+
+    #define USE_NETSWITCH
+
+    #define SW_STATIC_PORT_START
+    #define SW_PORT_INDEX_START         0
+    #define SW_PORT_INDEX_END           21
+
+    //#define SW_STATIC_IP
+    #ifdef SW_STATIC_IP
+        #define SW_HOST_IP              "192.168.234.1"
+        #define SW_PDU_IP               "192.168.234.132"
+    #endif
+    
+    #undef MAX_CHN_COUNT
+    #define MAX_CHN_COUNT               24
+#endif
+
+
+#ifdef PRJ_HYPERTEC
+    //ac_in3_out1_36ch_nologo_en_hypertec
+    #define SMTP_SEND_BUILTIN
+    
+    #undef PHASE_GROUP_CNT
+    #undef CHANNEL_DELAY_SEC
+
+    #define PHASE_GROUP_CNT             6
+    #define CHANNEL_DELAY_SEC           6
+#endif
+
+
+#endif
+
+

+ 3 - 0
pro/src/app.c

@@ -506,6 +506,8 @@ void* power_thread(void* arg)
                             log_d("ch%d insert data error.\n",_globalPowerMangerTemp->product_ch_id);
                         }
                     }
+                    
+                #ifndef PRJ_INSPUR
                     //插入数据库
                      if (_globalPowerWarningInfo.w_voltage_up!=_globalPowerMangerTemp->_PowerWarninginfo.w_voltage_up)
                     {
@@ -537,6 +539,7 @@ void* power_thread(void* arg)
                         /*高耗电 */
                         if(_globalPowerWarningInfo.w_consumption)dev_Alarm_send_message(_globalDeviceManager,_globalPowerMangerTemp,WARNING_P_UP);
                     }
+                #endif
 
                     //else
                    //log_i("%s ch%d insert data ok status:%d.\n",_globalPowerInfo.samp_time,_globalPowerMangerTemp->product_ch_id,_globalPowerInfo.product_status);

+ 2 - 1
pro/src/file.c

@@ -1,9 +1,10 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "file.h"
+#include "elog.h"
 
 
-#if 0
+#if 1
 #define LOGE  log_e
 #define LOGW  log_w
 #define LOGD  log_d

+ 3 - 1
pro/src/mqtt.c

@@ -887,7 +887,9 @@ static uint32_t get_serv(char *json)
 static int set_serv(uint32_t flag)
 {
     if(BGET(flag,SERV_NTP)) {
-        //
+        if(!thread_is_running(THREAD_ID_NTP)) {
+            
+        }
     }
     else {
 

+ 52 - 82
pro/src/paras.c

@@ -5,6 +5,8 @@
 #include "lock.h"
 #include "paras.h"
 #include "cascade.h"
+#include "dictionary.h"
+#include "iniparser.h"
 
 
 #if 1
@@ -25,37 +27,34 @@ enum {
 extern GlobalDeviceInfo DFLT_PARAS;
 
 typedef struct {
-    int  flag;
+    dictionary *dic;
     
 }paras_handle_t;
 static paras_handle_t  paraHandle={0};
 
 
-
+#if 0
 static int do_check(void *para)
 {
     return 0;
 }
 #if 1
 
-#include "dictionary.h"
-#include "iniparser.h"
-
 typedef struct {
-    int             product_id                  ;//产品ID 
-    char            product_number[16]          ;//产品编号    
-    char            product_name[32]            ;//产品名称
-    char            product_status[32]          ;//产品状态
-    unsigned char   product_type                ;//产品类型
-    unsigned char   product_pwr_type            ;//电源类型
-    char            product_version[8]          ;//软件版本
-    unsigned char   product_language            ;//多国语言
-    unsigned char   product_count               ;//级联设备数
-    unsigned short  product_samp_time           ;//采集周期 单位ms
-    unsigned short  product_save_time           ;//采集周期 单位ms
+    uint32_t    id                  ;//产品ID 
+    uint8_t     number[16]          ;//产品编号    
+    uint8_t     name[32]            ;//产品名称
+    uint8_t     status[32]          ;//产品状态
+    uint8_t     type                ;//产品类型
+    uint8_t     pwr_type            ;//电源类型
+    uint8_t     version[8]          ;//软件版本
+    uint8_t     language            ;//多国语言
+    uint8_t     count               ;//级联设备数
+    uint8_t     samp_time           ;//采集周期 单位ms
+    uint8_t     save_time           ;//采集周期 单位ms
 }prod_info_t;
 
-static int ini_rw_prod(int rw, dictionary *dic, GlobalDeviceInfo *info)
+static int ini_rw_dev(dictionary *dic, int rw, GlobalDeviceInfo *info)
 {
     int r=-1,ok=1;
     char *p=NULL;
@@ -244,7 +243,7 @@ static int ini_rw_prod(int rw, dictionary *dic, GlobalDeviceInfo *info)
     
     return 0;
 }
-static int ini_rw_modbus(int rw, dictionary *dic, GlobalDeviceInfo *info)
+static int ini_rw_modbus(dictionary *dic, int rw, GlobalDeviceInfo *info)
 {
     int r=-1;
     char temp[100];
@@ -318,25 +317,18 @@ static int ini_rw_modbus(int rw, dictionary *dic, GlobalDeviceInfo *info)
 
     return 0;
 }
-static int ini_rw_network(int rw, dictionary *dic, GlobalDeviceInfo *info)
-{
-    int r=-1;
-    char *p=NULL;
-    char temp[100];
-    char *token=NULL;
 
-    return 0;
-}
-static int ini_reset(void)
+static int ini_reset(paras_handle_t *h)
 {
     int r;
     dictionary *dic=NULL;
     char *ininame=INI_FILE_NAME;
-    char temp[200];
     FILE *fp=NULL;
+
+    
     GlobalDeviceInfo *info=&DFLT_PARAS;
 
-    sys_get_path(temp, ininame);
+    
     fp = fopen(temp, "w");
     if (fp==NULL) {
         LOGE("ini_reset, create %s failed\n", ininame);
@@ -355,46 +347,47 @@ static int ini_reset(void)
     fprintf(fp, "savetime  = %d\n", info->product_save_time);
     fclose(fp);
 
+    if(h->dic) {
+        iniparser_freedict(h->dic);
+    }
+    //h->dic = ini_load(h, info);
+
     return 0;
 }
-static int ini_load(GlobalDeviceInfo *info)
+static dictionary* ini_load(char *path, GlobalDeviceInfo *info)
 {
     int r=-1;
-    char *p=NULL;
-    char *ininame=INI_FILE_NAME;
+    char temp[200];
     
-    dictionary *dic=iniparser_load(ininame);
+    dictionary *dic=iniparser_load(path);
     if(dic == NULL){
-        ini_reset();
-        dic = iniparser_load(ininame);
+        
+        sys_get_path(temp, ininame);
+
+        ini_reset(h);
+        dic = iniparser_load(path);
         if(dic == NULL) {
             LOGE("___ iniparser_load failed\n");
-            return -1;
+            //return -1;
         }
     }
     
-    r = ini_rw_prod(INI_READ, dic, info);
+    r = ini_rw_dev(dic, INI_READ, info);
     if(r) {
-        LOGE("___ini_r_prod failed\n");
+        LOGE("___ini_r_dev failed\n");
+        return NULL;
     }
-    iniparser_freedict(dic);
 
-    return r;
+    return dic;
 }
-static int ini_save(GlobalDeviceInfo *info)
+static int ini_save(paras_handle_t *h, GlobalDeviceInfo *info)
 {
     int r=-1;
     char *p=NULL;
     char temp[200];
     char *ininame=INI_FILE_NAME;
     
-    dictionary *dic=iniparser_load(ininame);
-    if(dic == NULL){
-        LOGE("___ %s load failed\n", ininame);
-        return -1;
-    }
-    
-    r = ini_rw_prod(INI_WRITE, dic, info);
+    //r = ini_rw_dev(h, INI_WRITE, info);
     if(r) {
         LOGE("___ini_r_prod failed\n");
         goto quit;
@@ -406,11 +399,10 @@ static int ini_save(GlobalDeviceInfo *info)
         LOGE("___%s open failed\n", ininame);
         goto quit;
     }
-    iniparser_dump_ini(dic, fp);
-    fclose(fp);
+    iniparser_dump_ini(h->dic, fp);
+    fclose(fp); r = 0;
 
 quit:
-    iniparser_freedict(dic);
     return r;
 }
 #endif
@@ -424,19 +416,21 @@ static GlobalDeviceInfo *get_dm(void)
 
 int paras_init(void)
 {
+    int r=0;
     GlobalDeviceInfo *info=get_dm();
     paras_handle_t  *h=&paraHandle;
     
     lock_s_hold(LOCK_ID_PARAS);
-    ini_load(info);
+    h->dic = ini_load(INI_FILE_NAME, info);
     lock_s_release(LOCK_ID_PARAS);
     
-    return 0;
+    return r;
 }
 
 
 int paras_deinit(void)
 {
+    int r;
     paras_handle_t *h=&paraHandle;
     
     lock_s_hold(LOCK_ID_PARAS);
@@ -447,14 +441,14 @@ int paras_deinit(void)
 }
 
 
-int paras_load(void)
+int paras_load(char *path)
 {
     int r=0;
     GlobalDeviceInfo *info=get_dm();
     paras_handle_t *h=&paraHandle;
     
     lock_s_hold(LOCK_ID_PARAS);
-    r = ini_load(info);
+    //r = ini_load(path, info);
     lock_s_release(LOCK_ID_PARAS);
     
     return r;
@@ -468,8 +462,7 @@ int paras_reset(void)
     paras_handle_t *h=&paraHandle;
     
     lock_s_hold(LOCK_ID_PARAS);
-    ini_reset();
-    r = ini_load(info);
+    //ini_reset(h);
     lock_s_release(LOCK_ID_PARAS);
     
     return r;
@@ -483,37 +476,14 @@ int paras_save(void)
     paras_handle_t *h=&paraHandle;
     
     lock_s_hold(LOCK_ID_PARAS);
-    //r = ini_save(info);
+    r = ini_save(h, info);
     lock_s_release(LOCK_ID_PARAS);
     
     return r;
 }
 
 
-int paras_read(int type, void *data)
-{
-    int r=0;
-    paras_handle_t  *h=&paraHandle;
-    
-    lock_s_hold(LOCK_ID_PARAS);
-    
-    lock_s_release(LOCK_ID_PARAS);
-    
-    return r;
-}
-
-
-int paras_write(int type, void *data)
-{
-    int r=0;
-    paras_handle_t  *h=&paraHandle;
-    
-    lock_s_hold(LOCK_ID_PARAS);
-    
-    lock_s_release(LOCK_ID_PARAS);
-    
-    return r;
-}
+#endif
 
 
 

+ 1 - 5
pro/src/paras.h

@@ -28,14 +28,10 @@ enum {
 int paras_init(void);
 int paras_deinit(void);
 
-int paras_load(void);
+int paras_load(char *path);
 int paras_reset(void);
 int paras_save(void);
 
-int paras_read(int type, void *data);
-int paras_write(int type, void *data);
-
-
 
 #ifdef __cplusplus
 }

+ 11 - 11
pub

@@ -19,7 +19,9 @@
 #PRJS="PRJ_USASL_AC_I3_O1 PRJ_USASL_AC_I3_O3"
 #PRJS="PRJ_TEST"
 #PRJS="PRJ_ANDERSON"
-PRJS="PRJ_XIAN_P4 PRJ_XIAN_P8 PRJ_ITK_AC_I1_O1 PRJ_ITK_AC_I3_O1 PRJ_STSC_I3_O3"
+#PRJS="PRJ_STSC_I3_O3"
+PRJS="PRJ_INSPUR"
+#PRJS="PRJ_ITK_AC_I1_O1 PRJ_ITK_AC_I3_O1 PRJ_XIAN_P4 PRJ_XIAN_P8"
 
 fulldir=$(realpath $0)
 curdir=$(dirname $fulldir)
@@ -53,16 +55,14 @@ function do_copy()
         cp -f $custdir/logo/logo_neuter.png $curdir/output/t113i/root/run/app/image/logo.png
     elif [ "$PRJ" = "PRJ_ITK_AC_I1_O1" ]; then
         name=ac_in1_out1_russia_itk
-        #cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
-        cp -rf $custdir/web816/general  $curdir/output/t113i/root/run/web
+        cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
         cp -rf $custdir/cfg/cfg_russia_itk.h  $curdir/pro/config/cfg.h
 
         cp -f $custdir/db/ac_i1_o1_russian.db $curdir/output/t113i/root/run/app/pdu_dat.db
         cp -f $custdir/logo/logo_itk.png $curdir/output/t113i/root/run/app/image/logo.png
     elif [ "$PRJ" = "PRJ_ITK_AC_I3_O1" ]; then
         name=ac_in3_out1_russia_itk
-        #cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
-        cp -rf $custdir/web816/general  $curdir/output/t113i/root/run/web
+        cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
         cp -rf $custdir/cfg/cfg_russia_itk.h  $curdir/pro/config/cfg.h
 
         cp -f $custdir/db/ac_i3_o1_russian.db $curdir/output/t113i/root/run/app/pdu_dat.db
@@ -134,23 +134,23 @@ function do_copy()
         cp -f $custdir/db/ac_i3_o1_english.db $curdir/output/t113i/root/run/app/pdu_dat.db
         cp -f $custdir/logo/logo_hypertec.png $curdir/output/t113i/root/run/app/image/logo.png
     elif [ "$PRJ" = "PRJ_INSPUR" ]; then
-        name=dc_in1_out1_hypertec
+        name=dc_in1_out1_inspur
         cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
-        cp -rf $custdir/cfg/cfg_general.h  $curdir/pro/config/cfg.h
+        cp -rf $custdir/cfg/cfg_inspur.h  $curdir/pro/config/cfg.h
         
         cp -f $custdir/db/dc_i_dc_o_chinese.db $curdir/output/t113i/root/run/app/pdu_dat.db
         cp -f $custdir/logo/logo_neuter.png $curdir/output/t113i/root/run/app/image/logo.png
     elif [ "$PRJ" = "PRJ_TEST" ]; then
-        name=dc_in3_out1_test
+        name=ac_in3_out1_test
         cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
         cp -rf $custdir/cfg/cfg_test.h  $curdir/pro/config/cfg.h
         
-        cp -f $custdir/db/ac_i3_o1_chinese.db $curdir/output/t113i/root/run/app/pdu_dat.db
+        cp -f $custdir/db/ac_i3_o1_english.db $curdir/output/t113i/root/run/app/pdu_dat.db
         cp -f $custdir/logo/logo_neuter.png $curdir/output/t113i/root/run/app/image/logo.png
     elif [ "$PRJ" = "PRJ_STSC_I3_O3" ]; then
-        name=dc_in3_out3_stsc
+        name=ac_in3_out3_stsc
         cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
-        cp -rf $custdir/cfg/cfg_general.h  $curdir/pro/config/cfg.h
+        cp -rf $custdir/cfg/cfg_stsc.h  $curdir/pro/config/cfg.h
         
         cp -f $custdir/db/ac_i3_o3_english.db $curdir/output/t113i/root/run/app/pdu_dat.db
         cp -f $custdir/logo/logo_neuter.png $curdir/output/t113i/root/run/app/image/logo.png