Reading Gcode in LocalFiileSystem and encodeing int array

Files at this revision

API Documentation at this revision

Comitter:
satoyuki1111
Date:
Thu Oct 11 11:23:53 2018 +0000
Parent:
2:4fc4593498d7
Child:
4:1e606e2301f9
Commit message:
v1.3

Changed in this revision

MakeSequencer.cpp Show annotated file Show diff for this revision Revisions of this file
MakeSequencer.h Show annotated file Show diff for this revision Revisions of this file
--- a/MakeSequencer.cpp	Thu Oct 11 11:07:31 2018 +0000
+++ b/MakeSequencer.cpp	Thu Oct 11 11:23:53 2018 +0000
@@ -61,8 +61,7 @@
 
 bool MakeSequencer::ReadGcode()
 {
-    int _ele = 0;
-    
+    _ele = 0;
     for(int i = 0;fgets(_buf,sizeof(_buf), _fp) != NULL;i++)
     {
         _codesize = i;
@@ -71,12 +70,8 @@
             return false;
         else
         {
-            int    _tempnum[ARRAY_EREMENT];
             string _tempstr[ARRAY_EREMENT];
-            char   _element[ARRAY_EREMENT][CODE_LENGTH];
-            char   _char;
-            int    _count = -1;
-            bool   _check[ARRAY_EREMENT][CODE_LENGTH];
+            _count = -1;
             
             for(int n = 0;n < ARRAY_EREMENT;n++)
             {
@@ -122,19 +117,10 @@
             for(int n = 0;n < _ele;n++)
             {
                 _tempnum[n] = atoi(_tempstr[n].c_str());
-                
-                if(i != 0 && _check[n][i] && _element[n][i] != _element[n][0])
-                {
-                    //printf("{%d}-{%d},",n,i);
-                    _data[n][i] = _data[n][i-1];
-                }
-                else
-                {
-                    _data[n][i] = _tempnum[n];
-                }        
-                printf("%c:%d ",_element[n][0],_data[n][i]);    
+                _data[n][i] = (i != 0 && _check[n][i] && _element[n][i] != _element[n][0])
+                            ? _data[n][i-1]
+                            : _tempnum[n];
             }
-            printf("\n\r");
         }
     }
     return true;
--- a/MakeSequencer.h	Thu Oct 11 11:07:31 2018 +0000
+++ b/MakeSequencer.h	Thu Oct 11 11:23:53 2018 +0000
@@ -22,6 +22,13 @@
     int    _data[ARRAY_EREMENT][CODE_LENGTH];
     int    _codesize;
     
+    int    _tempnum[ARRAY_EREMENT];
+    int    _ele;
+    char   _element[ARRAY_EREMENT][CODE_LENGTH];
+    char   _char;
+    int    _count;
+    bool   _check[ARRAY_EREMENT][CODE_LENGTH];
+    
     LocalFileSystem *_local;
     FILE *_fp;
 };