Selaa lähdekoodia

1、更新打包脚本
2、更新web解析,增加参数解析

guohui 1 vuosi sitten
vanhempi
commit
35b3c31421

+ 8 - 1
cust_data/web/unique/i18n/i18n_deguo.js

@@ -463,7 +463,14 @@ const i18n_deguo= {
   "zc":"normal",
   "stwdcgq":"Doppelkopf-Temperatursensor",
   "ylcgq":"Drucksensor",
-  "RS485adress":"RS485-Adresse"
+  "RS485adress":"RS485-Adresse",
+  "wifiwl":"WIFI Netzwerk",
+  "fourgwl":"4G-Netz",
+  "fourgwlsz":"4G-Netzwerkeinstellungen",
+  "qy":"Aktivieren",
+  "xhqd":"Signalintensität",
+  "yys":"Betreiber",
+  "tel":"Telefonnummer:"
 
 
 }

+ 8 - 1
cust_data/web/unique/i18n/i18n_eguo.js

@@ -464,5 +464,12 @@ const i18n_eguo={
   "zc":"Нормально.",
   "stwdcgq":"Двухголовый датчик температуры",
   "ylcgq":"Датчик давления",
-  "RS485adress":"RS485 Адрес"
+  "RS485adress":"RS485 Адрес",
+  "wifiwl":"Сеть WiFi",
+  "fourgwl":"Сеть 4G",
+  "fourgwlsz":"Настройки сети 4G",
+  "qy":"Включить",
+  "xhqd":"Сила сигнала",
+  "yys":"Оператор",
+  "tel":"Номер телефона"
 }

+ 8 - 1
cust_data/web/unique/i18n/i18n_faguo.js

@@ -463,7 +463,14 @@ const i18n_faguo={
   "zc":"Normale",
   "stwdcgq":"Capteur de température à double tête",
   "ylcgq":"Capteur de pression",
-  "RS485adress":"Adresse RS485"
+  "RS485adress":"Adresse RS485",
+  "wifiwl":"Réseau WiFi",
+  "fourgwl":"Réseau 4G",
+  "fourgwlsz":"Configuration du réseau 4G",
+  "qy":"Activer",
+  "xhqd":"Force du signal",
+  "yys":"Opérateur",
+  "tel":"Numéro de téléphone"
 
 
 

+ 8 - 1
cust_data/web/unique/i18n/i18n_putaoya.js

@@ -463,7 +463,14 @@ const i18n_putaoya={
   "zc":"normal",
   "stwdcgq":"Sensor de temperatura de cabeça dupla",
   "ylcgq":"Sensor de pressão",
-  "RS485adress":"Endereço RS485"
+  "RS485adress":"Endereço RS485",
+  "wifiwl":"Rede WIFI",
+  "fourgwl":"Rede 4G",
+  "fourgwlsz":"Configuração da rede 4G",
+  "qy":"Activar",
+  "xhqd":"intensidade do sinal",
+  "yys":"Operador",
+  "tel":"Número de telefone:"
 
 
 

+ 8 - 1
cust_data/web/unique/i18n/i18n_riben.js

@@ -463,7 +463,14 @@ const i18n_riben={
   "zc":"通常",
   "stwdcgq":"双頭温度センサ",
   "ylcgq":"あつりょくセンサ",
-  "RS485adress":"RS 485アドレス"
+  "RS485adress":"RS 485アドレス",
+  "wifiwl":"WIFIネットワーク",
+  "fourgwl":"4 Gネットワーク",
+  "fourgwlsz":"4 Gネットワーク設定",
+  "qy":"有効化",
+  "xhqd":"しんごうきょうど",
+  "yys":"オペレータ",
+  "tel":"電話番号"
 
 
 

+ 8 - 1
cust_data/web/unique/i18n/i18n_xibanya.js

@@ -463,7 +463,14 @@ const i18n_xibanya={
   "zc":"Normal",
   "stwdcgq":"Sensor de temperatura de doble cabeza",
   "ylcgq":"Sensores de presión",
-  "RS485adress":"Dirección rs485"
+  "RS485adress":"Dirección rs485",
+  "wifiwl":"Red WIFI",
+  "fourgwl":"Red 4G",
+  "fourgwlsz":"Configuración de la red 4G",
+  "qy":"Habilitar",
+  "xhqd":"Intensidad de la señal",
+  "yys":"Operadores",
+  "tel":"Número de teléfono"
 
 
 

+ 8 - 1
cust_data/web/unique/i18n/i18n_yidali.js

@@ -463,7 +463,14 @@ const i18n_yidali={
   "stwdcgq":"Sensore di temperatura a doppia testa",
   "ylcgq":"Sensore di pressione",
 
-  "RS485adress":"Indirizzo RS485"
+  "RS485adress":"Indirizzo RS485",
+  "wifiwl":"Rete WIFI",
+  "fourgwl":"Rete 4G",
+  "fourgwlsz":"Impostazioni di rete 4G",
+  "qy":"Abilita",
+  "xhqd":"Fortezza del segnale",
+  "yys":"Operatore",
+  "tel":"Numero di telefono:"
 
 
 

+ 8 - 1
cust_data/web/unique/i18n/i18n_yingguo.js

@@ -463,6 +463,13 @@ const i18n_yingguo={
   "zc":"normal",
   "stwdcgq":"Dual head temperature sensor",
   "ylcgq":"Pressure sensor",
-  "RS485adress":"RS485 address"
+  "RS485adress":"RS485 address",
+  "wifiwl":"wifi network",
+  "fourgwl":"4g network",
+  "fourgwlsz":"4G network settings",
+  "qy":"Enable",
+  "xhqd":"Signal strength",
+  "yys":"Operator",
+  "tel":"phone number"
 
 }

+ 8 - 1
cust_data/web/unique/i18n/i18n_zh_CN.js

@@ -463,7 +463,14 @@ const i18n_zh_CN = {
   "zc":"正常",
   "stwdcgq":"双头温度传感器",
   "ylcgq":"压力传感器",
-"RS485adress":"RS485地址"
+"RS485adress":"RS485地址",
+  "wifiwl":"WIFI网络",
+  "fourgwl":"4G网络",
+  "fourgwlsz":"4G网络设置",
+  "qy":"启用",
+  "xhqd":"信号强度",
+  "yys":"运营商",
+  "tel":"电话号码"
 
 
 

BIN
cust_data/web/unique/img/logo.png


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 1
cust_data/web/unique/index.html


+ 1 - 1
f407/applications/cascade.c

@@ -708,7 +708,7 @@ void cascade_scan_thread(void *arg)
 				}
 				
 			}
-			LOGD("cpy data to north user\n");
+			//LOGD("cpy data to north user\n");
 			//slave_get_info(&slave_info);
 		}
 		sleep(1);

+ 0 - 6
f407/applications/datadef.h

@@ -150,9 +150,6 @@ enum {
 ////////////////////////////////////////////////
 #pragma pack (1)
 
-
-
-
 typedef struct {
     uint8_t             mode;
     uint8_t             addr;               
@@ -488,9 +485,6 @@ typedef struct {
     uint8_t             flag;
 }mesg_data_t;
 
-
-
-
 typedef struct {
     uint8_t             cnt;
     uint8_t             addr[CASCADE_MAX];

+ 1 - 20
f407/applications/main.c

@@ -8,7 +8,6 @@
 #include <netdb.h>
 #include <unistd.h>
 #include "web.h"
-#include "fs.h"
 #include "ui.h"
 #include "sys.h"
 #include "power.h"
@@ -91,29 +90,12 @@ __exit:
     return ret;
 }
 
-static int sd_mount(void)
-{
-    int r=1,n=0;
-    while(n<10) {
-        r = mmcsd_wait_cd_changed(500);
-        if(r==MMCSD_HOST_PLUGED) {
-            r = fs_mount("sd", 1);
-        }
-        else if(r==MMCSD_HOST_UNPLUGED) {
-            r = fs_mount("sd", 0);
-        }
-        
-        if(r<=0) break;
-        n++;
-    }
-    return r;
-}
+
 
 
 static int user_init(void)
 {
    // ui_init();
-    sd_mount();
     power_init();
 		LOGD("____________cascade thread!!!!!\n");
     web_init();
@@ -126,7 +108,6 @@ static int user_init(void)
 
 int main(void)
 {
-
     sys_init();
     user_init();
     while (1) {

+ 0 - 4
f407/applications/power.c

@@ -746,13 +746,9 @@ int power_init(void)
     h->cur_addr = 0;
     h->brd_max = BRD_NUM;
     h->prod = &paras_get()->prod;
-    LOGD("11111111111111111111111\n");
     power_scan();
-		LOGD("111111111111111111111112222222222222222222\n");
     //power_set_all_sw(1);
-		LOGD("1111111111111111111111122222222222222222223333333333333333333333\n");
     thread_start(THREAD_ID_POWER, power_thread, h);
-    LOGD("11111111111111111111111222222222222222222233333333333333333333334444444444444444\n");
     return 0;
 }
 

+ 3 - 3
f407/applications/rtconfig.h

@@ -171,9 +171,9 @@
 #define IP_SOF_BROADCAST 1
 #define IP_SOF_BROADCAST_RECV 1
 
-#define RT_LWIP_IPADDR   "192.168.234.132"
-#define RT_LWIP_GWADDR   "192.168.234.1"
-#define RT_LWIP_MSKADDR  "255.255.255.0"
+#define RT_LWIP_IPADDR   "192.168.2.132"
+#define RT_LWIP_GWADDR   "192.168.2.1"
+#define RT_LWIP_MSKADDR  "255.255.2.0"
 #define RT_LWIP_UDP
 #define RT_LWIP_TCP
 #define RT_LWIP_RAW

+ 1 - 1
f407/applications/stm32f4xx_hal_conf.h

@@ -223,7 +223,7 @@
 /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
 #define PHY_RESET_DELAY                 ((uint32_t)0x000000FFU)
 /* PHY Configuration delay */
-#define PHY_CONFIG_DELAY                ((uint32_t)0x00000FFFU)
+#define PHY_CONFIG_DELAY                50//((uint32_t)0x00000FFFU)
 
 #define PHY_READ_TO                     ((uint32_t)0x0000FFFFU)
 #define PHY_WRITE_TO                    ((uint32_t)0x0000FFFFU)

+ 19 - 1
f407/applications/sys.c

@@ -4,6 +4,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <limits.h>
+#include <rtdevice.h>
 #include "log.h"
 #include "sys.h"
 #include "lock.h"
@@ -58,9 +59,26 @@ static void* poll_thread(void *arg)
 
 
 
-
+static int sd_mount(void)
+{
+    int r=1,n=0;
+    while(n<10) {
+        r = mmcsd_wait_cd_changed(500);
+        if(r==MMCSD_HOST_PLUGED) {
+            r = fs_mount("sd", 1);
+        }
+        else if(r==MMCSD_HOST_UNPLUGED) {
+            r = fs_mount("sd", 0);
+        }
+        
+        if(r<=0) break;
+        n++;
+    }
+    return r;
+}
 int sys_init(void)
 {
+    sd_mount();
     paras_init();
     
     //thread_start(THREAD_ID_POLL, poll_thread, NULL);

+ 2 - 0
f407/applications/web.c

@@ -241,6 +241,8 @@ static int ws_handle(web_handle_t *h, pkt_hdr_t *hdr, mg_conn_t *c)
                 case SUB_TYPE_PARAS_NETWORK:
                 {
                     network_data_t *p=(network_data_t*)hdr->data;
+                    
+                    //set_if
                 }
                 break;
                 

+ 5 - 6
f407/project/app/app.uvoptx

@@ -120,8 +120,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
-          <Name>d</Name>
-        </SetRegEntry>
+          <Name>
</Name>        </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
           <Key>ARMRTXEVENTFLAGS</Key>
@@ -554,7 +553,7 @@
 
   <Group>
     <GroupName>applications/ui</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -2854,7 +2853,7 @@
 
   <Group>
     <GroupName>drivers/drv</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -3742,7 +3741,7 @@
 
   <Group>
     <GroupName>rt-thread/comp/lwip-port</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -3774,7 +3773,7 @@
 
   <Group>
     <GroupName>rt-thread/comp/lwip2.1.2</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>

+ 476 - 157
f407/tools/web/JS/data.js

@@ -27,9 +27,14 @@ const SUB_TYPE=function(){
         SUB_TYPE_POWER_THRESHOLD:len++,         //power_ch_t
         SUB_TYPE_POWER_START_DELAY:len++,       //power_total_t
         SUB_TYPE_POWER_STOP_DELAY:len++,
+        
+        SUB_TYPE_PARAS_MODBUS:len++,
+        SUB_TYPE_PARAS_MISC:len++,
+        SUB_TYPE_PARAS_PROD:len++,
+        SUB_TYPE_PARAS_SERV:len++,
+        SUB_TYPE_PARAS_NETWORK:len++,
     }
 }();
-
 const PDU_TYPE=function(){
     var len = 0;
     return {
@@ -40,7 +45,6 @@ const PDU_TYPE=function(){
     PDU_AC_I3O1_H:len++,
     }
 }();
-
 const ALARM_ACT=function(){
     var len = 1;
     return {
@@ -49,7 +53,42 @@ const ALARM_ACT=function(){
     ALARM_ACT_CLOSE_CHALL:len++,
     }
 }();
-
+const IP_MODE=function(){
+    var len = 0;
+    return {
+    IP_MODE_DHCP:len++,
+    IP_MODE_STATIC:len++,
+    }
+}();
+const IP_VER=function(){
+    var len = 0;
+    return {
+    IP_VER_ERR:len++,
+    IP_VER_V4:len++,
+    IP_VER_V6:len++,
+    }
+}();
+const MODBUS_MODE=function(){
+    var len = 0;
+    return {
+    MODBUS_MASTER:len++,
+    MODBUS_SLAVE:len++,
+    }
+}();
+const LANG_ID=function(){
+    var len = 0;
+    return {
+    LANG_ID_CHINESE:len++,
+    LANG_ID_ENGLISH:len++,
+    LANG_ID_RUSSIAN:len++,
+    LANG_ID_SPANISH:len++,
+    LANG_ID_PORTYGYESE:len++,
+    LANG_ID_GERMAN:len++,
+    LANG_ID_FRENCH:len++,
+    LANG_ID_ITALIAN:len++,
+    LANG_ID_JAPANESE:len++,
+    }
+}();
 
 ///////////////////////////////////////////////////////
 function array_to_string(data){
@@ -57,6 +96,13 @@ function array_to_string(data){
     return decoder.decode(new Uint8Array(data));
 }
 
+function array_set(array,str,offset){
+    const encoder = new TextEncoder(); // ĬÈÏ'utf-8'±àÂë
+    const buffer = encoder.encode(str);
+    array.set(buffer);
+    array.fill(offset, buffer.length);
+}
+
 function string_to_array(data,len){
     const encoder = new TextEncoder(); // ĬÈÏ'utf-8'±àÂë
     const buffer = encoder.encode(data);
@@ -81,14 +127,14 @@ function array_cat(a1,a2){
     }
     return buffer;
 }
-function mk_hdr(addr,type,flag)
+function mk_hdr_bin(addr,type,subtype,nack,flag,dlen)
 {
     var tmp,length=0;
-    var buffer = new ArrayBuffer(13);
-
+    var buffer = new ArrayBuffer(14);
+    
     tmp = new DataView(buffer, length);
     var t = MAGIC;
-    tmp.setUint16(0,t,true);//magic
+    tmp.setUint16(0,t,true);    //magic
     length += 2;
 
     tmp = new DataView(buffer, length);
@@ -112,58 +158,42 @@ function mk_hdr(addr,type,flag)
     length += 4;
     
     tmp = new DataView(buffer, length);
-    tmp.setUint32(0,0,true);    //dlen
+    tmp.setUint32(0,dlen,true);    //dlen
     length += 4;
     
     return buffer;
 }
-function pkt_to_bin(type,subtype,js)
+function mk_hdr_obj(addr,type,subtype,nack,flag,dlen)
 {
-    var tmp,tmp2,length=0;
-    var buffer = new ArrayBuffer(13);
-
-    tmp = new DataView(buffer, length);
-    var t = MAGIC;
-    tmp.setUint16(0,t,true);//magic
-    length += 2;
-
-    tmp = new DataView(buffer, length);
-    tmp.setUint8(0,type,true);  //type
-    length += 1;
-
-    tmp = new DataView(buffer, length);
-    tmp.setUint8(0,subtype,true);     //subtype
-    length += 1;
-    
-    tmp = new DataView(buffer, length);
-    tmp.setUint8(0,0,true);     //nack
-    length += 1;
-    
-    tmp = new DataView(buffer, length);
-    tmp.setUint32(0,0,true);     //flag
-    length += 4;
-    
-    tmp = new DataView(buffer, length);
-    tmp.setUint32(0,js.len,true);    //dlen
-    length += 4;
+    this.magic = MAGIC;
+    this.addr = addr;
+    this.type = type;
+    this.subtype = subtype;
+    this.flag = flag;
+    this.dlen = dlen;
+}
+function pkt_to_bin(addr,type,subtype,nack,flag,js)
+{
+    var tmp;
+    var buffer = new mk_hdr_bin(addr,type,subtype,nack,flag,js.len);
     
     switch(type){
         case PKT_TYPE.PKT_TYPE_POWER_CH:
-            tmp2 = new powerc_to_bin(js);
+            tmp = new powerc_to_bin(js);
             break;
 
         case PKT_TYPE.PKT_TYPE_POWER_TOTAL:
-            tmp2 = BIN.powert.j2b(js);
+            tmp = new powert_to_bin(js);
             break;
            
        case PKT_TYPE.PKT_TYPE_ALARM:
-            tmp2 = BIN.alarm.j2b(js);
+            tmp = new alarm_to_bin(js);
             break;
             
        default:
-       return tmp2;
+       return tmp;
     }
-    return array_cat(buffer,tmp2);
+    return array_cat(buffer,tmp);
 }
 function bin_to_pkt(bin)
 {
@@ -187,14 +217,17 @@ function bin_to_pkt(bin)
            case PKT_TYPE.PKT_TYPE_ALARM:
                 hdr.alarmd = BIN.alarmd.b2j(data);
                 break;
-            
-            default :
+           
+           case PKT_TYPE.PKT_TYPE_SLAVE_LIST:
+                hdr.slaves = BIN.alarmd.b2j(data);
+                break;
+           
+           default:
                 console.log("wrong hdr type: "+hdr.type);
         }
     }
     return hdr;
 }
-
 ///////////////////////////////////////////////////
 function bin_to_hdr(bin) {
     var tmp, length=0;
@@ -391,6 +424,155 @@ function bin_to_thr(bin) {
 
     this.len = length;
 }
+////////////////////////////////
+function bin_to_modbus(bin) {
+    var tmp, length=0;
+    
+    tmp = new DataView(bin, length);
+    this.mode = tmp.getUint8(0,true);
+    length += 1;
+    
+    tmp = new DataView(bin, length);
+    this.addr = tmp.getUint8(0,true);
+    length += 1;
+    
+    tmp = new DataView(bin, length);
+    this.baud = tmp.getUint32(0,true);
+    length += 4;
+
+    this.len = length;
+}
+function bin_to_misc(bin) {
+    var tmp, length=0;
+    
+    tmp = new DataView(bin, length);
+    this.watchdog = tmp.getUint8(0,true);
+    length += 1;
+    
+    tmp = new DataView(bin, length);
+    this.fliptime = tmp.getUint32(0,true);
+    length += 4;
+    
+    tmp = new DataView(bin, length);
+    this.led = tmp.getUint8(0,true);
+    length += 1;
+    
+    tmp = new DataView(bin, length);
+    this.beep = tmp.getUint8(0,true);
+    length += 1;
+    
+    tmp = new DataView(bin, length);
+    this.rotate = tmp.getUint8(0,true);
+    length += 1;
+
+    this.len = length;
+}
+function bin_to_prod(bin) {
+    var tmp, length=0;
+    
+    tmp = new DataView(bin, length);
+    this.id = tmp.getUint8(0,true);
+    length += 1;
+    
+    this.pname = array_to_string(bin.slice(length,32));
+    length += 32;
+    
+    this.pnumber = array_to_string(bin.slice(length,32));
+    length += 32;
+    
+    this.status = array_to_string(bin.slice(length,32));
+    length += 32;
+    
+    this.name = array_to_string(bin.slice(length,32));
+    length += 32;
+    
+    this.number = array_to_string(bin.slice(length,32));
+    length += 32;
+    
+    this.date = array_to_string(bin.slice(length,32));
+    length += 32;
+    
+    this.batch = array_to_string(bin.slice(length,32));
+    length += 32;
+    
+    tmp = new DataView(bin, length);
+    this.type = tmp.getUint8(0,true);
+    length += 1;
+    
+    tmp = new DataView(bin, length);
+    this.pwr_type = tmp.getUint8(0,true);
+    length += 1;
+    
+    this.version = array_to_string(bin.slice(length,8));
+    length += 8;
+    
+    tmp = new DataView(bin, length);
+    this.language = tmp.getUint8(0,true);
+    length += 1;
+    
+    tmp = new DataView(bin, length);
+    this.samptime = tmp.getUint32(0,true);
+    length += 4;
+    
+    tmp = new DataView(bin, length);
+    this.savetime = tmp.getUint32(0,true);
+    length += 4;
+    
+    tmp = new DataView(bin, length);
+    this.ph_group = tmp.getUint16(0,true);
+    length += 2;
+    
+    tmp = new DataView(bin, length);
+    this.ch_delay = tmp.getUint16(0,true);
+    length += 2;
+
+    this.len = length;
+}
+function bin_to_serv(bin) {
+    var tmp, length=0;
+    
+    this.name = array_to_string(bin.slice(length,256));
+    length += 256;
+    
+    this.site = array_to_string(bin.slice(length,256));
+    length += 256;
+    
+    this.mail = array_to_string(bin.slice(length,256));
+    length += 256;
+    
+    this.addr = array_to_string(bin.slice(length,256));
+    length += 256;
+    
+    this.tele = array_to_string(bin.slice(length,32));
+    length += 32;
+
+    this.len = length;
+}
+function bin_to_network(bin) {
+    var tmp, length=0;
+      
+    tmp = new DataView(bin, length);
+    this.mode = tmp.getUint8(0,true);
+    length += 1;
+    
+    this.ipaddr = array_to_string(bin.slice(length,48));
+    length += 48;
+    
+    this.mask   = array_to_string(bin.slice(length,48));
+    length += 48;
+    
+    this.gateway = array_to_string(bin.slice(length,48));
+    length += 48;
+    
+    this.dns1 = array_to_string(bin.slice(length,48));
+    length += 48;
+    
+    this.dns2 = array_to_string(bin.slice(length,48));
+    length += 48;
+
+    this.len = length;
+}
+////////////////////////////////
 function bin_to_powerc(bin) {
     var tmp, bin2, length=0;
 
@@ -487,6 +669,44 @@ function bin_to_alarmd(bin) {
 
     this.len = length;
 }
+function bin_to_paras(bin) {
+    var tmp, length=0;
+    
+    this.cas = new bin_to_modbus(bin.slice(length));
+    length += this.cas.len;
+    
+    this.misc = new bin_to_misc(bin.slice(length));
+    length += this.misc.len;
+    
+    this.prod = new bin_to_prod(bin.slice(length));
+    length += this.prod.len;
+    
+    this.serv = new bin_to_serv(bin.slice(length));
+    length += this.serv.len;
+    
+    this.network = new bin_to_network(bin.slice(length));
+    length += this.network.len;
+
+    this.len = length;
+}
+function bin_to_slist(bin) {
+    var tmp, length=0;
+    
+    tmp = new DataView(bin, length);
+    this.cnt = tmp.getUint8(0,true);
+    length += 1;
+    
+    this.addr = [];
+    tmp = new DataView(bin, length);
+    for(var i=0; i<this.cnt; i++) {
+        this.addr[i] = tmp.getUint8(i,true);
+    }
+    length += this.cnt;
+
+    this.len = length;
+}
+
+
 ///////////////////////////////////////////////////
 function hdr_to_bin(js) {
     var tmp, length=0;
@@ -496,6 +716,10 @@ function hdr_to_bin(js) {
     tmp.setUint16(0,js.magic,true);
     length += 2;
 
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.addr,true);
+    length += 1;
+
     tmp = new DataView(buffer, length);
     tmp.setUint8(0,js.type,true);
     length += 1;
@@ -637,7 +861,7 @@ function alarm_to_bin(js) {
 
     return buffer;
 }
-function thrval_to_js(js) {
+function thrval_to_bin(js) {
     var tmp, length=0;
     var buffer = new ArrayBuffer(js.len);
     
@@ -664,21 +888,179 @@ function thrval_to_js(js) {
 function thr_to_bin(js) {
     var bin,tmp, length=0;
     
-    bin = thrval_to_js(js.v_upper);
-    tmp = thrval_to_js(js.v_lower);
+    bin = thrval_to_bin(js.v_upper);
+    tmp = thrval_to_bin(js.v_lower);
     
     bin = array_cat(bin, tmp);
-    tmp = thrval_to_js(js.c_upper);
+    tmp = thrval_to_bin(js.c_upper);
     bin = array_cat(bin, tmp);
     
-    tmp = thrval_to_js(js.p_upper);
+    tmp = thrval_to_bin(js.p_upper);
     bin = array_cat(bin, tmp);
     
-    tmp = thrval_to_js(js.w_upper);
+    tmp = thrval_to_bin(js.w_upper);
     bin = array_cat(bin, tmp);
 
     return bin;
 }
+////////////////////////////////
+function modbus_to_bin(js) {
+    var tmp, length=0;
+    var buffer = new ArrayBuffer(js.len);
+
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.mode,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.addr,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint32(0,js.baud,true);
+    length += 4;
+    
+    return buffer;
+}
+function misc_to_bin(js) {
+    var tmp, length=0;
+    var buffer = new ArrayBuffer(js.len);
+
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.watchdog,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.fliptime,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.led,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.beep,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.rotate,true);
+    length += 1;
+    
+    return buffer;
+}
+function prod_to_bin(js) {
+    var tmp, length=0;
+    var buffer = new ArrayBuffer(js.len);
+
+    tmp = new DataView(buffer, length);
+    tmp.setUint32(0,js.id,true);
+    length += 4;
+    
+    array_set(buffer,js.pname,length);
+    length += 32;
+    
+    array_set(buffer,js.pnumber,length);
+    length += 32;
+    
+    array_set(buffer,js.status,length);
+    length += 32;
+    
+    array_set(buffer,js.name,length);
+    length += 32;
+    
+    array_set(buffer,js.number,length);
+    length += 32;
+    
+    array_set(buffer,js.date,length);
+    length += 32;
+    
+    array_set(buffer,js.batch,length);
+    length += 32;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.type,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.pwrtype,true);
+    length += 1;
+    
+    array_set(buffer,js.version,length);
+    length += 8;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.language,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.count,true);
+    length += 1;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint32(0,js.samptime,true);
+    length += 4;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint32(0,js.savetime,true);
+    length += 4;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint16(0,js.ph_group,true);
+    length += 2;
+    
+    tmp = new DataView(buffer, length);
+    tmp.setUint16(0,js.ch_delay,true);
+    length += 2;
+    
+    return buffer;
+}
+function serv_to_bin(js) {
+    var tmp, length=0;
+    var buffer = new ArrayBuffer(js.len);
+
+    array_set(buffer,js.name,length);
+    length += 256;
+    
+    array_set(buffer,js.site,length);
+    length += 256;
+    
+    array_set(buffer,js.mail,length);
+    length += 256;
+    
+    array_set(buffer,js.addr,length);
+    length += 256;
+    
+    array_set(buffer,js.tele,length);
+    length += 32;
+    
+    return buffer;
+}
+function network_to_bin(js) {
+    var tmp, length=0;
+    var buffer = new ArrayBuffer(js.len);
+
+    tmp = new DataView(buffer, length);
+    tmp.setUint8(0,js.mode,true);
+    length += 1;
+    
+    array_set(buffer,js.ipaddr,length);
+    length += 48;
+    
+    array_set(buffer,js.mask,length);
+    length += 48;
+    
+    array_set(buffer,js.gateway,length);
+    length += 48;
+    
+    array_set(buffer,js.dns1,length);
+    length += 48;
+    
+    array_set(buffer,js.dns2,length);
+    length += 48;
+    
+    return buffer;
+}
+////////////////////////////////
 function powerc_to_bin(js) {
     var bin,tmp, length=0;
     
@@ -778,120 +1160,57 @@ function alarmd_to_bin(js) {
     return array_cat(bin, buffer);
 }
 //////////////////////////////////////////////////////////////
-
-var XXX ={};
-XXX.hdr = function() {
-    this.j2b = function (js) {
-        var tmp;
-
-        switch(js.type){
+function bin_parse(bin)
+{
+    var tmp,h = new bin_to_hdr(bin);
+    if(h.nack == 1){
+        //tmp = myBinary.ack.bin2js(bin,this.h.len,true);
+        //myLog('log',tmp);
+        //var data = tmp.data;
+    }
+    
+    var data = bin.slice(h.len);
+    if(data.byteLength>0 && h.dlen==data.byteLength) {
+        switch(h.type) {
             case PKT_TYPE.PKT_TYPE_POWER_CH:
-                tmp = BIN.powerc.j2b(js.powerc);
-                break;
+            {
+                var tmp=[],length=0;
+                for(var i=0;; i++) {
+                    tmp[i] =  new bin_to_powerc(data.slice(length));
+                    length += tmp[i].len;
+                    if(length >= data.byteLength) {
+                        break;
+                    }
+                }
+                h.powerc = tmp;
+            }
+            break;
 
             case PKT_TYPE.PKT_TYPE_POWER_TOTAL:
-                tmp = BIN.powert.j2b(js.powert);
-                break;
+            h.powert = new bin_to_powert(data);
+            break;
                
            case PKT_TYPE.PKT_TYPE_ALARM:
-                tmp = BIN.alarm.j2b(js.alarmd);
-                break;
-                
-           default:
-           return tmp;
-        }
-        js.dlen = tmp.byteLength;
-        var hdr = new hdr_to_bin(js);
-        return array_cat(hdr,tmp);
-    };
-
-    this.b2j = function (bin) {
-        var tmp;
-        var hdr = new bin_to_hdr(bin);
-        
-        if(hdr.nack == 1){
-            //tmp = myBinary.ack.bin2js(bin,this.hdr.len,true);
-            //myLog('log',tmp);
-            //var data = tmp.data;
-        }
-        
-        var data = bin.slice(hdr.len);
-        if(data.byteLength>0 && hdr.dlen==data.byteLength) {
-            switch(hdr.type) {
-                case PKT_TYPE.PKT_TYPE_POWER_CH:
-                    hdr.powerc = BIN.powerc.b2j(data);
-                    break;
-
-                case PKT_TYPE.PKT_TYPE_POWER_TOTAL:
-                    hdr.powert = BIN.powert.b2j(data);
-                    break;
-                   
-               case PKT_TYPE.PKT_TYPE_ALARM:
-                    hdr.alarmd = BIN.alarmd.b2j(data);
-                    break;
-                
-                default :
-                    console.log("wrong hdr type: "+hdr.type);
-            }
-        }
-        return hdr;
-    }
-};
-XXX.paras=function() {
-    this.j2b = function (js) {
-        
-    }
-    
-    this.b2j = function (bin) {
-        
-    }
-};
-XXX.powerc=function() {
-    this.j2b = function (js) {
-        return new powerc_to_bin(js);
-    }
-
-    this.b2j = function (bin) {
-        var tmp=[],length=0;
-        for(var i=0;; i++) {
-            tmp[i] =  new bin_to_powerc(bin.slice(length));
-            length += tmp[i].len;
-            if(length >= bin.byteLength) {
-                break;
-            }
+            h.alarmd = new bin_to_alarm(data);
+            break;
+           
+           case PKT_TYPE.PKT_TYPE_SLAVE_LIST:
+            h.alarmd = new bin_to_slist(data);
+            break;
+           
+           case PKT_TYPE.PKT_TYPE_PARAS:
+            h.alarmd = new bin_to_paras(data);
+            break;
+           
+           default :
+           console.log("wrong hdr type: "+h.type);
+           break;
         }
-        return tmp;
-    }
-};
-XXX.powert=function() {
-    this.j2b = function (js) {
-        return new powert_to_bin(js);
-    }
-
-    this.b2j = function (bin) {
-        return new bin_to_powert(bin);
-    }
-};
-XXX.alarmd=function() {
-    this.j2b = function (js) {
-        return new alarmd_to_bin(js);
-    }
-
-    this.b2j = function (bin) {
-        return new bin_to_alarmd(bin);
     }
+    return h;
 };
 
 
-var BIN=new function() {
-    this.hdr = new XXX.hdr();
-    this.paras = new XXX.paras();
-    this.powerc = new XXX.powerc();
-    this.powert = new XXX.powert();
-    this.alarmd = new XXX.alarmd();
-}();
-
-
 //////////////////////////////////////////
 function LOG(){
     var data = [];
@@ -899,7 +1218,6 @@ function LOG(){
         data.push(arguments[i])
     }
     console.log(data);
-
 }
 
 
@@ -975,7 +1293,7 @@ function WS(url,fn) {
     function _onopen(evt) {
         his.closeCount = 0;
         console.log("___ ws.onopen");
-        setTimeout(loop_send, 2000);
+        //setTimeout(loop_send, 2000);
     }
 
     function _onclose(evt) {
@@ -987,7 +1305,8 @@ function WS(url,fn) {
     function _onmsg(evt) {
         console.log("___ ws.onmsg");
         if (evt.data instanceof ArrayBuffer) {
-            fn(evt.data);
+            var obj=bin_parse(evt.data);
+            fn(obj);
         }
     }
 

+ 2 - 30
f407/tools/web/JS/index.js

@@ -24,12 +24,12 @@ function showPage(pageId) {
 
 function function1() 
 {
-    ws.send(mk_hdr(PKT_TYPE.PKT_TYPE_POWER_TOTAL,0));
+    ws.send(mk_hdr_bin(0,PKT_TYPE.PKT_TYPE_POWER_TOTAL,0,0,0));
 }
    
 function function2() 
 {
-    ws.send(mk_hdr(PKT_TYPE.PKT_TYPE_POWER_CH,0));
+    ws.send(mk_hdr_bin(0,PKT_TYPE.PKT_TYPE_POWER_CH,0,0,0));
 }
 
 function function3()
@@ -51,31 +51,3 @@ document.addEventListener('DOMContentLoaded', () => {
     showPage('page1');
 });
 
-function mk_hdr(type)
-{
-    var tmp,length=0;
-    var buffer = new ArrayBuffer(9);
-
-    tmp = new DataView(buffer, length);
-    var t = 0xdead;
-    tmp.setUint16(0,t,true);//magic
-    length += 2;
-
-    tmp = new DataView(buffer, length);
-    tmp.setUint8(0,type,true);  //type
-    length += 1;
-
-    tmp = new DataView(buffer, length);
-    tmp.setUint8(0,0,true);     //subtype
-    length += 1;
-    
-    tmp = new DataView(buffer, length);
-    tmp.setUint8(0,0,true);     //nack
-    length += 1;
-    
-    tmp = new DataView(buffer, length);
-    tmp.setUint32(0,0,true);    //dlen
-    length += 4;
-    
-    return buffer;
-}

+ 7 - 7
f407/tools/web/JS/operation.js

@@ -1,11 +1,11 @@
 function all_open()
 {
-    ws.send(mk_hdr(PKT_TYPE.PKT_TYPE_CH_ALL,1));
+    ws.send(mk_hdr_bin(0,PKT_TYPE.PKT_TYPE_CH_ALL,0,1,0));
 }
 
 function all_close()
 {
-    ws.send(mk_hdr(PKT_TYPE.PKT_TYPE_CH_ALL,0));
+    ws.send(mk_hdr_bin(0,PKT_TYPE.PKT_TYPE_CH_ALL,0,0,0));
 }
 
 function single_open(j_data,channel_power_infro,j)
@@ -17,8 +17,8 @@ function single_open(j_data,channel_power_infro,j)
     {
         opreation_data[j].power[0].status = 1
     }
-    a = pkt_to_bin(PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_SWITCH,opreation_data[j])
-    var b = bin_to_pkt(a)
+    a = pkt_to_bin(0,PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_SWITCH,0,0,opreation_data[j])
+    //var b = bin_to_pkt(a)
     ws.send(a)
 }
 
@@ -31,14 +31,14 @@ function single_close(j_data,channel_power_infro,j)
     {
         opreation_data[j].power[0].status = 0
     }
-    a = pkt_to_bin(PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_SWITCH,opreation_data[j])
-    var b = bin_to_pkt(a)
+    a = pkt_to_bin(0,PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_SWITCH,0,0,opreation_data[j])
+    //var b = bin_to_pkt(a)
     ws.send(a)
 }
 
 function threshold_update(orgin_data)
 {
     translate_data = orgin_data
-    a = pkt_to_bin(PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_THRESHOLD,translate_data)
+    a = pkt_to_bin(0,PKT_TYPE.PKT_TYPE_POWER_CH,SUB_TYPE.SUB_TYPE_POWER_THRESHOLD,0,0,translate_data)
     ws.send(a)
 }

+ 18 - 17
f407/tools/web/JS/ws.js

@@ -1,27 +1,26 @@
-function on_ws_msg(bin){
-    var j = BIN.hdr.b2j(bin);
-    console.log(j)
+function on_ws_msg(js){
+    console.log(js)
     //总电源数据显示
-    if (j.powert != undefined){
-        total_data = j.powert.total
-        total_Infor(j,total_data)
+    if (js.powert != undefined){
+        total_data = js.powert.total
+        total_Infor(js,total_data)
     }
     //通道电源数据显示
-    if(j.powerc != undefined){
-        channel_power_infro = j.powerc
+    if(js.powerc != undefined){
+        channel_power_infro = js.powerc
         channel_infro = channel_power_infro.power
-        alarm = j.powerc.alarm
-        channel_number = j.powerc.info
-        channel_power = j.powerc.power
-        j_data = j
+        alarm = js.powerc.alarm
+        channel_number = js.powerc.info
+        channel_power = js.powerc.power
+        j_data = js
         Channel_Info(j_data,channel_power_infro)
-        threshold_mannage(j,channel_power_infro)
+        threshold_mannage(js,channel_power_infro)
         //populateTable(j_data,channel_power)
     }
-    if(j.alarmd != undefined)
+    if(js.alarmd != undefined)
     {
-        console.log(j.alarmd)
-        alarmd_data = j.alarmd
+        console.log(js.alarmd)
+        alarmd_data = js.alarmd
         systemAlarm(alarmd_data)
     }
 }
@@ -36,4 +35,6 @@ function ws_hdr(){
     return ws;
 }
 
-ws = new WS('ws://'+window.location.host+'/ws',on_ws_msg);
+//ws = new WS('ws://'+window.location.host+'/ws',on_ws_msg);
+ws = new WS('ws://192.168.2.132/ws',on_ws_msg);
+

+ 3 - 0
f407/tools/web/index.html

@@ -2,6 +2,9 @@
 <html lang="en">
 <head>
     <meta charset="UTF-8">
+    <meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
+    <meta http-equiv="pragma" content="no-cache">
+    <meta http-equiv="expires" content="0">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>SmartPDU</title>
     <link rel="stylesheet" href="CSS/index.css">

+ 1 - 1
f407/tools/webServer/EasyWebSvr.ini

@@ -1,5 +1,5 @@
 [WebServer]
-RootDir=F:\pdu\SmartPDCode\f407\tools\web
+RootDir=..\web
 ListenPort=80
 MaxThreadNum=100
 Timeout=5000

+ 2 - 2
output/t113i/push/pull.bat

@@ -14,10 +14,10 @@ SET PLINK=%CURDIR%\tools\plink
 
 SET USR=root
 SET FBAT=%CURDIR%\tools\script.sh
-SET PWD=123456
+SET PWD=gowone123
 
 ::pull file
-ECHO  y  | %PSCP%  -r %USR%@%IP%:%TARGET% %OUTDIR%
+ECHO  y  | %PSCP% -pw %PWD% -r %USR%@%IP%:%TARGET% %OUTDIR%
 IF %ERRORLEVEL% EQU 0 (
     ECHO pull finished!) 
 ELSE (

+ 2 - 2
output/t113i/push/push.bat

@@ -20,11 +20,11 @@ SET PLINK=%CURDIR%\tools\plink
 
 SET USR=root
 SET FBAT=%CURDIR%\tools\script.sh
-SET PWD=123456
+SET PWD=gowone123
 
 ::send file
 ECHO send %TARGET% to device ...
-ECHO  y  | %PSCP% %OUTDIR%\%TARGET% root@%IP%:%DEVDIR%
+ECHO  y  | %PSCP% -pw %PWD% %OUTDIR%\%TARGET% %USR%@%IP%:%DEVDIR%
 IF %ERRORLEVEL% NEQ 0 (
     ECHO send failed!
     EXIT /B 1

+ 1 - 1
output/t113i/push2/pull.bat

@@ -17,7 +17,7 @@ SET FBAT=%CURDIR%\tools\script.sh
 SET PWD=123456
 
 ::pull file
-ECHO  y  | %PSCP%  -r %USR%@%IP%:%TARGET% %OUTDIR%
+ECHO  y  | %PSCP%  -pw %PWD% -r %USR%@%IP%:%TARGET% %OUTDIR%
 IF %ERRORLEVEL% EQU 0 (
     ECHO pull finished!) 
 ELSE (

+ 3 - 4
output/t113i/push2/push.bat

@@ -19,15 +19,14 @@ SET PLINK=%CURDIR%\tools\plink
 
 SET USR=root
 SET FBAT=%CURDIR%\tools\script.sh
-SET PWD=123456
-
+SET PWD=gowone123
 SET FILES=pdutar logo.png smartPDU.ini
 
 ::enterin current directory
 CD %CURDIR%
 
 ::copy files
-MKDIR  %TMPDIR% 2 > NUL
+MKDIR  %TMPDIR% 2>NUL
 FOR %%x IN (%FILES%) DO (
     XCOPY /DQY %%x  %TMPDIR%\  > NUL
 )
@@ -45,7 +44,7 @@ IF %ERRORLEVEL% NEQ 0 (
 
 ::send files
 ECHO send %TMPDIR% to device ...
-ECHO  y  | %PSCP% -r %TMPDIR% %USR%@%IP%:%DEVDIR%
+ECHO  y  | %PSCP% -pw %PWD% -r %TMPDIR% %USR%@%IP%:%DEVDIR%
 IF %ERRORLEVEL% NEQ 0 (
     ECHO send failed!
     EXIT /B 2