monitor

Dependents:   mini_02

Fork of mon by V09

Files at this revision

API Documentation at this revision

Comitter:
rs27
Date:
Thu Mar 10 20:35:10 2016 +0000
Parent:
1:bf1028d27a23
Commit message:

Changed in this revision

mon.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r bf1028d27a23 -r 512482b7f8c6 mon.cpp
--- a/mon.cpp	Fri Feb 05 14:40:00 2016 +0000
+++ b/mon.cpp	Thu Mar 10 20:35:10 2016 +0000
@@ -14,16 +14,19 @@
 #include "mon.h"
 #include "MODSERIAL.h"
 #include "timer0.h"
-#include "rs_485.h"
 
 extern MODSERIAL pc;                       // definiert in main
 extern timer0 down_timer;                  // Timer für Zeitsteuerung, definiert in main
-extern rs_485 RS485_BUS;                   // RS385 Schnittstelle für den H-Bus, definiert in main
-   
+
+extern DigitalOut out1;
+extern DigitalOut out2;
+extern DigitalOut out3;
+extern DigitalOut out4;   
+
 #define COMMAND_MAX    5
 #define COMMAND_LEN    7
                                              // "DUMP","HELP","SET","TIME"}; 
-const char command[COMMAND_MAX][COMMAND_LEN] = {"DUMP","HELP","SEND","SET","TIME"};
+const char command[COMMAND_MAX][COMMAND_LEN] = {"DUMP","HELP","SET","TIME"};
 
 //-----------------------------------------------------------------------------
 // constructor
@@ -125,9 +128,8 @@
         {
           case  0: dump();      break;
           case  1: help();      break;
-          case  2: send();      break;
-          case  3: set();       break;
-          case  4: time();      break;
+          case  2: set();       break;
+          case  3: time();      break;
         }                                   
   }
 }
@@ -245,53 +247,12 @@
 {
   pc.printf("\n -- help ------------------------");
   pc.printf("\n clcd val >> lcd Kontrast");
-  pc.printf("\n send [val] [val] [val] ... >> ein Telegramm senden");
-  pc.printf("\n set index [val] >> Sensor auswaehlen");
+  pc.printf("\n set index [val] >> Ausgang setzen");
   pc.printf("\n time [std min sek tag monat jahr]");   
   pc.printf("\n"); 
   pc.printf("\n");
 }
 
-//-----------------------------------------------------------------------------
-// monitor Aufruf send
-// sendet ein Telegramm über die RS485 Schnittstelle
-// Die Telegramm sind hier auf 10 Zeichen begrenzt
-//
-void monitor::send(void)
-{
-    int n, pos0, pos[10];
-    uint8_t data[10];
-    //                                0  1  2  3  4  5  6  7  8  9
-    n = sscanf(&mon_line[MonLinePtr],"%x %x %x %x %x %x %x %x %x %x",&pos[0],&pos[1],&pos[2],&pos[3],&pos[4],&pos[5],&pos[6],&pos[7],&pos[8],&pos[9]);
-    
-    switch (n)
-    {
-      case -1:
-      case  0: 
-              pc.printf("\nbitte Werte fuer das Telegramm eingeben");
-              pc.printf("\n send ADR ZIEL LEN [DATA] ");
-              break;
-      
-      default: 
-              // Telegramm zusammenstellen und ausgeben
-              for (int i = 0; i < 10; i++)
-              {
-                if (i <= n)
-                {
-                    data[i] = (uint8_t) pos[i];   
-                }
-                else
-                {
-                    data[i] = 0;   
-                }     
-              }
-              
-              RS485_BUS.write(data);
-              
-              break;
-              
-     } // end switch
-}
 
 //-----------------------------------------------------------------------------
 // monitor Aufruf set
@@ -300,21 +261,43 @@
 {
     int n, pos, val;
 
+    pos = 0;
+    val = 0;
+    
     n = sscanf(&mon_line[MonLinePtr],"%d %d",&pos,&val);
     
+    if ((pos < 0) || (pos > 4)) n = -1;
+    if ((val < 0) || (val >1)) n = -1;
+    
     switch (n)
     {
-      case -1: pc.printf("\nbitte index [wert] angeben");
-              pc.printf("\n Index >> Sonsor 0 bis 7");
-              pc.printf("\n wert  >> 0 = inaktiv, 1 = Rohwerte, 2 = errechneter Wert");
-              break;
-      
-      case 1: pc.printf("\nread status[%d] ",pos);
-              break;
-              
-      case 2: //status[pos] = val;
-              pc.printf("\nset status[%d] = %d",pos);
-              break;
+      case -1: 
+          pc.printf("\nbitte [Ausgang] [Wert] angeben");
+          pc.printf("\n Ausgang >> 1 bis 6");
+          pc.printf("\n Wert  >> 0 = inaktiv, 1 = aktiv");
+          break;
+            
+          default:
+                    switch (pos)
+                    {
+                        case 1:
+                            pc.printf("\n Ausgang 1 = %d",val);
+                            out1 = val;
+                            break;
+                        case 2:
+                            pc.printf("\n Ausgang 2 = %d",val);
+                            out2 = val;
+                            break;
+                        case 3:
+                            pc.printf("\n Ausgang 3 = %d",val);
+                            out3 = val;
+                            break;
+                        case 4:
+                            pc.printf("\n Ausgang 4 = %d",val);
+                            out4 = val;
+                            break;                    
+                    }
+                    break;
      } // end switch
 }