Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
199:d65ed41d4dd4
Parent:
197:594afd088f32
Child:
203:9d735375f218
--- a/src/CommandParser/cmd.cpp	Thu Oct 06 21:02:11 2016 +0000
+++ b/src/CommandParser/cmd.cpp	Fri Oct 07 11:40:51 2016 +0000
@@ -1101,40 +1101,104 @@
         printf("\rsetting: simin i_bdcond01 2000\r\n");
 
         ModbusRegisterMap["i_tra01"].simulated = true;
-        SimulateInputMap["i_tra01"].start_value = 100;
+        SimulateInputMap["i_tra01"].start_value = 130;
         SimulateInputMap["i_tra01"].min = 0;
         SimulateInputMap["i_tra01"].max = 0;
         SimulateInputMap["i_tra01"].up_step = 0;
         SimulateInputMap["i_tra01"].down_step = 0;
         SimulateInputMap["i_tra01"].moving_up = true;
+        
+        ModbusRegisterMap["i_tag01"].simulated = true;
+        SimulateInputMap["i_tag01"].start_value = 100;
+        SimulateInputMap["i_tag01"].min = 0;
+        SimulateInputMap["i_tag01"].max = 0;
+        SimulateInputMap["i_tag01"].up_step = 0;
+        SimulateInputMap["i_tag01"].down_step = 0;
+        SimulateInputMap["i_tag01"].moving_up = true;
 
         ModbusRegisterMap["i_bdcond01"].simulated = true;
-        SimulateInputMap["i_bdcond01"].start_value = 2000;
+        SimulateInputMap["i_bdcond01"].start_value = 1800;
         SimulateInputMap["i_bdcond01"].min = 0;
         SimulateInputMap["i_bdcond01"].max = 0;
         SimulateInputMap["i_bdcond01"].up_step = 0;
         SimulateInputMap["i_bdcond01"].down_step = 0;
         SimulateInputMap["i_bdcond01"].moving_up = true;
+        
+        ModbusRegisterMap["i_cond_temp01"].simulated = true;
+        SimulateInputMap["i_cond_temp01"].start_value = 25.0;
+        SimulateInputMap["i_cond_temp01"].min = 0;
+        SimulateInputMap["i_cond_temp01"].max = 0;
+        SimulateInputMap["i_cond_temp01"].up_step = 0;
+        SimulateInputMap["i_cond_temp01"].down_step = 0;
+        SimulateInputMap["i_cond_temp01"].moving_up = true;
+        
+        ModbusRegisterMap["i_ph01"].simulated = true;
+        SimulateInputMap["i_ph01"].start_value = 8;
+        SimulateInputMap["i_ph01"].min = 0;
+        SimulateInputMap["i_ph01"].max = 0;
+        SimulateInputMap["i_ph01"].up_step = 0;
+        SimulateInputMap["i_ph01"].down_step = 0;
+        SimulateInputMap["i_ph01"].moving_up = true;
+        
+        ModbusRegisterMap["i_ph_temp01"].simulated = true;
+        SimulateInputMap["i_ph_temp01"].start_value = 25.0;
+        SimulateInputMap["i_ph_temp01"].min = 0;
+        SimulateInputMap["i_ph_temp01"].max = 0;
+        SimulateInputMap["i_ph_temp01"].up_step = 0;
+        SimulateInputMap["i_ph_temp01"].down_step = 0;
+        SimulateInputMap["i_ph_temp01"].moving_up = true;
+        
+        ModbusRegisterMap["i_orp01"].simulated = true;
+        SimulateInputMap["i_orp01"].start_value = 350;
+        SimulateInputMap["i_orp01"].min = 0;
+        SimulateInputMap["i_orp01"].max = 0;
+        SimulateInputMap["i_orp01"].up_step = 0;
+        SimulateInputMap["i_orp01"].down_step = 0;
+        SimulateInputMap["i_orp01"].moving_up = true;
 
         return;
     }
 
-    printf("\rsetting: simin i_tra01 100 94 106 1 .25\r\n");
-    printf("\rsetting: simin i_bdcond01 2000 1990 2006 .25 1\r\n");
+    printf("\rsetting: simin i_tra01 130 120 140 1 .25\r\n");
+    printf("\rsetting: simin i_tag01 100 90 110 1 .25\r\n");
+    printf("\rsetting: simin i_bdcond01 1800 1725 1875 1 5\r\n");
+    printf("\rsetting: simin i_ph01 8.0 7.25 8.75 .0. .1\r\n");
+    printf("\rsetting: simin i_orp01 350 300 400 5 1\r\n");
 
     ModbusRegisterMap["i_tra01"].simulated = true;
-    SimulateInputMap["i_tra01"].start_value = 100;
-    SimulateInputMap["i_tra01"].min = 94;
-    SimulateInputMap["i_tra01"].max = 106;
+    SimulateInputMap["i_tra01"].start_value = 130;
+    SimulateInputMap["i_tra01"].min = 120;
+    SimulateInputMap["i_tra01"].max = 140;
     SimulateInputMap["i_tra01"].up_step = 1;
     SimulateInputMap["i_tra01"].down_step = .25;
+    
+    ModbusRegisterMap["i_tag01"].simulated = true;
+    SimulateInputMap["i_tag01"].start_value = 100;
+    SimulateInputMap["i_tag01"].min = 90;
+    SimulateInputMap["i_tag01"].max = 110;
+    SimulateInputMap["i_tag01"].up_step = 1;
+    SimulateInputMap["i_tag01"].down_step = .25;
 
     ModbusRegisterMap["i_bdcond01"].simulated = true;
-    SimulateInputMap["i_bdcond01"].start_value = 2000;
-    SimulateInputMap["i_bdcond01"].min = 1990;
-    SimulateInputMap["i_bdcond01"].max = 2006;
-    SimulateInputMap["i_bdcond01"].up_step = .25;
-    SimulateInputMap["i_bdcond01"].down_step = 1;
+    SimulateInputMap["i_bdcond01"].start_value = 1800;
+    SimulateInputMap["i_bdcond01"].min = 1725;
+    SimulateInputMap["i_bdcond01"].max = 1875;
+    SimulateInputMap["i_bdcond01"].up_step = 1;
+    SimulateInputMap["i_bdcond01"].down_step = 5;
+    
+    ModbusRegisterMap["i_ph01"].simulated = true;
+    SimulateInputMap["i_ph01"].start_value = 8;
+    SimulateInputMap["i_ph01"].min = 7.25;
+    SimulateInputMap["i_ph01"].max = 8.75;
+    SimulateInputMap["i_ph01"].up_step = .05;
+    SimulateInputMap["i_ph01"].down_step = .1;
+    
+    ModbusRegisterMap["i_orp01"].simulated = true;
+    SimulateInputMap["i_orp01"].start_value = 350;
+    SimulateInputMap["i_orp01"].min = 300;
+    SimulateInputMap["i_orp01"].max = 400;
+    SimulateInputMap["i_orp01"].up_step = 5;
+    SimulateInputMap["i_orp01"].down_step = 1;
 
 }
 
@@ -1302,7 +1366,7 @@
     // INPUT: Conductivity Temperature
     snprintf(buf, sizeof(buf),
              "{ "
-             "\"id\":        \"i_temp01\","
+             "\"id\":        \"i_cond_temp01\","
              "\"name\":      \"Temp Conductivity\","
              "\"units\":     \"C\","
              "\"min\":       \"0\","
@@ -1316,49 +1380,113 @@
              "\"fmt\":       \"%%.2f\","
              "\"vcmd\":      \"\","
              "\"rfreq\":     \"5\" }");
-    rc = GLOBAL_mdot->saveUserFile("input_i_temp01.json", (void *)buf, MAX_FILE_SIZE);
+    rc = GLOBAL_mdot->saveUserFile("input_i_cond_temp01.json", (void *)buf, MAX_FILE_SIZE);
     if ( rc != true ) {
-        printf("\rFailed to save input_i_temp01.json\n");
+        printf("\rFailed to save input_i_cond_temp01.json\n");
         return;
     } else {
-        printf("\r...generated input_i_temp01.json\n");
+        printf("\r...generated input_i_cond_temp01.json\n");
     }
 
     mail = ModbusMasterMailBox.alloc();
     mail->action = ACTION_READ_FILE;
-    strncpy( mail->controlFile, "input_i_temp01.json", (sizeof(mail->controlFile)-1));
+    strncpy( mail->controlFile, "input_i_cond_temp01.json", (sizeof(mail->controlFile)-1));
     ModbusMasterMailBox.put(mail);
 
     Thread::wait(1000);
-
-    // INPUT: Product Factor
+    
+        // INPUT: pH Temperature
     snprintf(buf, sizeof(buf),
              "{ "
-             "\"id\":        \"i_pfac01\","
-             "\"name\":      \"Product Factor\","
-             "\"units\":     \"PPM\","
+             "\"id\":        \"i_ph_temp01\","
+             "\"name\":      \"Temp pH\","
+             "\"units\":     \"C\","
              "\"min\":       \"0\","
-             "\"max\":       \"10000\","
-             "\"node\":      \"1\","
-             "\"reg\":       \"40\","
-             "\"rtype\":     \"3\","
-             "\"type\":      \"0\","
+             "\"max\":       \"10\","
+             "\"node\":      \"22\","
+             "\"reg\":       \"10\","
+             "\"rtype\":     \"4\","
+             "\"type\":      \"1\","
              "\"size\":      \"2\","
              "\"order\":     \"2\","
              "\"fmt\":       \"%%.2f\","
              "\"vcmd\":      \"\","
              "\"rfreq\":     \"5\" }");
-    rc = GLOBAL_mdot->saveUserFile("input_i_pfac01.json", (void *)buf, MAX_FILE_SIZE);
+    rc = GLOBAL_mdot->saveUserFile("input_i_ph_temp01.json", (void *)buf, MAX_FILE_SIZE);
     if ( rc != true ) {
-        printf("\rFailed to save input_i_pfac01.json\n");
+        printf("\rFailed to save input_i_ph_temp01.json\n");
         return;
     } else {
-        printf("\r...generated input_i_pfac01.json\n");
+        printf("\r...generated input_i_ph_temp01.json\n");
     }
 
     mail = ModbusMasterMailBox.alloc();
     mail->action = ACTION_READ_FILE;
-    strncpy( mail->controlFile, "input_i_pfac01.json", (sizeof(mail->controlFile)-1));
+    strncpy( mail->controlFile, "input_i_ph_temp01.json", (sizeof(mail->controlFile)-1));
+    ModbusMasterMailBox.put(mail);
+
+    Thread::wait(1000);
+    
+            // INPUT: pH
+    snprintf(buf, sizeof(buf),
+             "{ "
+             "\"id\":        \"i_ph01\","
+             "\"name\":      \"pH\","
+             "\"units\":     \"pH\","
+             "\"min\":       \"0\","
+             "\"max\":       \"10\","
+             "\"node\":      \"22\","
+             "\"reg\":       \"18\","
+             "\"rtype\":     \"4\","
+             "\"type\":      \"1\","
+             "\"size\":      \"2\","
+             "\"order\":     \"2\","
+             "\"fmt\":       \"%%.2f\","
+             "\"vcmd\":      \"\","
+             "\"rfreq\":     \"5\" }");
+    rc = GLOBAL_mdot->saveUserFile("input_i_ph01.json", (void *)buf, MAX_FILE_SIZE);
+    if ( rc != true ) {
+        printf("\rFailed to save input_i_ph01.json\n");
+        return;
+    } else {
+        printf("\r...generated input_i_ph01.json\n");
+    }
+
+    mail = ModbusMasterMailBox.alloc();
+    mail->action = ACTION_READ_FILE;
+    strncpy( mail->controlFile, "input_i_ph01.json", (sizeof(mail->controlFile)-1));
+    ModbusMasterMailBox.put(mail);
+
+    Thread::wait(1000);
+    
+                // INPUT: ORP
+    snprintf(buf, sizeof(buf),
+             "{ "
+             "\"id\":        \"i_orp01\","
+             "\"name\":      \"ORP\","
+             "\"units\":     \"mV\","
+             "\"min\":       \"0\","
+             "\"max\":       \"10\","
+             "\"node\":      \"22\","
+             "\"reg\":       \"14\","
+             "\"rtype\":     \"4\","
+             "\"type\":      \"1\","
+             "\"size\":      \"2\","
+             "\"order\":     \"2\","
+             "\"fmt\":       \"%%.2f\","
+             "\"vcmd\":      \"\","
+             "\"rfreq\":     \"5\" }");
+    rc = GLOBAL_mdot->saveUserFile("input_i_orp01.json", (void *)buf, MAX_FILE_SIZE);
+    if ( rc != true ) {
+        printf("\rFailed to save input_i_orp01.json\n");
+        return;
+    } else {
+        printf("\r...generated input_i_orp01.json\n");
+    }
+
+    mail = ModbusMasterMailBox.alloc();
+    mail->action = ACTION_READ_FILE;
+    strncpy( mail->controlFile, "input_i_orp01.json", (sizeof(mail->controlFile)-1));
     ModbusMasterMailBox.put(mail);
 
     Thread::wait(1000);
@@ -1458,14 +1586,14 @@
              "\"priority\": \"800\", "
              "\"input\": \"i_bdcond01\", "
              "\"output\": \"o_rly01\", "
-             "\"setpoint\": \"2000\", "
+             "\"setpoint\": \"1800\", "
              "\"prodfact\": \"\", "
              "\"actingDir\": \"1\", "
-             "\"halert\": \"2100\", "
-             "\"lalert\": \"1900\", "
-             "\"hfs\": \"2200\", "
-             "\"lfs\": \"1800\", "
-             "\"tol\": \"5\" }");
+             "\"halert\": \"2400\", "
+             "\"lalert\": \"800\", "
+             "\"hfs\": \"2700\", "
+             "\"lfs\": \"700\", "
+             "\"tol\": \"30\" }");
     rc = GLOBAL_mdot->saveUserFile("control_sp_bd01.json", (void *)buf, MAX_FILE_SIZE);
     if ( rc != true ) {
         printf("\rFailed to save control_sp_bd01.json\n");
@@ -1491,14 +1619,14 @@
              "\"priority\": \"800\", "
              "\"input\": \"i_tra01\", "
              "\"output\": \"o_rly02\", "
-             "\"setpoint\": \"100\", "
+             "\"setpoint\": \"130\", "
              "\"prodfact\": \"100\", "
              "\"actingDir\": \"0\", "
-             "\"halert\": \"115\", "
-             "\"lalert\": \"85\", "
-             "\"hfs\": \"130\", "
+             "\"halert\": \"190\", "
+             "\"lalert\": \"92\", "
+             "\"hfs\": \"200\", "
              "\"lfs\": \"70\", "
-             "\"tol\": \"5\" }");
+             "\"tol\": \"4\" }");
     rc = GLOBAL_mdot->saveUserFile("control_sp_tra01.json", (void *)buf, MAX_FILE_SIZE);
     if ( rc != true ) {
         printf("\rFailed to save control_sp_tra01.json\n");
@@ -1569,9 +1697,9 @@
 void cmd_modbusCmd(int argc, char **argv)
 {
     if ( (argc != 7) && (argc != 8)) {
-        printf("\r\nusage:   modbusCmd <node> <func> <sreg> <nreg> <dtype> <order> <value>\r\n");
-        printf("example (read product factor): modbusCmd 1 3 40 2 0 2\r\n");
-        printf("example (write product factor): modbusCmd 1 16 40 2 0 2 100.0\r\n");
+        printf("\r\nusage:   mod-cmd <node> <func> <sreg> <nreg> <dtype> <order> <value>\r\n");
+        printf("example (read product factor): mod-cmd 1 3 40 2 0 2\r\n");
+        printf("example (write product factor): mod-cmd 1 16 40 2 0 2 100.0\r\n");
         return;
     }