TG Motion  version 421 - 4033/904 cnc 121
Real-time system for controlling servo drives and I/O modules
TGM_CNC.h
Go to the documentation of this file.
1 
17 #ifndef TGM_CNC_H_FILE_INCLUDED
18 #define TGM_CNC_H_FILE_INCLUDED
19 
21 #define COMM_DLL_VERSION 355
22 
23 // standard data types
24 #include <stdint.h>
25 #include <string.h>
26 #include <assert.h>
27 
28 // include usefull math constants
29 #define _USE_MATH_DEFINES
30 #include <math.h>
31 
32 #ifdef __GNUC__
33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-pedantic" // disable warning about nameless structs
35 #else
36 #pragma warning(push)
37 # pragma warning(disable : 4201) // disable warning: nameless struct/union....
38 # if _MSC_VER < 1800 // below Visual Studio 2013
39 # pragma warning(disable: 4480) // Visual Studio 2010 emits warning for enum with type specified
40 # endif
41 #endif
42 
44 //################################### Constants definitions #######################################
46 
47 #ifndef MAX_FLOAT
48 # define MAX_FLOAT 3.402823466e+38
49 #endif
50 
52 #ifndef INVALID_VALUE
53 # define INVALID_VALUE (MAX_FLOAT / 2.)
54 #endif
55 
57 #ifndef _countof
58 # define _countof(array) (sizeof(array)/sizeof(array[0]))
59 #endif
60 
61 // suppress compiler warning about unreferenced parameter
62 // (mainly in no-init optimized constructor)
63 #ifndef UNREFERENCED_PARAM
64 # define UNREFERENCED_PARAM(P) \
65 { \
66  (void)(P); \
67 }
68 #endif
69 
71 #define MAX_FUNC_ADDRESSES ('Z' - 'A' + 1)
72 
73 // exporting functions from SF_TCh library
74 #if defined __linux__ && !defined UNDER_RTSS
75 
76 # if defined(SF_TCH_LIBRARY)
77 # define TOOLCHAIN_DLL_EXPORT __attribute__((visibility("default")))
78 # define CNC_CALC_DLL_EXPORT __attribute__((visibility("default"))) // swapped!
79 # else
80 # define TOOLCHAIN_DLL_EXPORT __attribute__((visibility("default")))
81 # define CNC_CALC_DLL_EXPORT __attribute__((visibility("default"))) // swapped!
82 # endif
83 # define TOOLCHAIN_CALLTYPE
84 
85 // prevent multiple typedefs by #define trick
86 
88 # ifndef TGM_LPCTSTR
89 # define TGM_LPCTSTR TGM_LPCTSTR
90  typedef const char * TGM_LPCTSTR;
91 # endif
92 
93 # ifndef TGM_LPTSTR
94 # define TGM_LPTSTR TGM_LPTSTR
95  typedef char * TGM_LPTSTR;
96 # endif
97 
99 # ifndef TGM_LPCSTR
100 # define TGM_LPCSTR TGM_LPCSTR
101  typedef const char * TGM_LPCSTR;
102 # endif
103 
104 #elif defined WIN32 // !__linux__
105 
106 # if defined DOXYGEN
107 # define TOOLCHAIN_DLL_EXPORT
108 # elif defined(SF_TCH_LIBRARY)
109 # define TOOLCHAIN_DLL_EXPORT __declspec(dllexport)
110 # define CNC_CALC_DLL_EXPORT __declspec(dllimport) // swapped!
111 # else
112 # define TOOLCHAIN_DLL_EXPORT __declspec(dllimport)
113 # define CNC_CALC_DLL_EXPORT __declspec(dllexport) // swapped!
114 # endif
115 # define TOOLCHAIN_CALLTYPE __cdecl
116 
117 # if !defined _UNICODE
118 # error "_UNICODE must be defined for WIN32"
119 # endif
120 
121 // prevent multiple typedefs by #define trick
122 
123 # ifndef TGM_LPCTSTR
124 # define TGM_LPCTSTR TGM_LPCTSTR
125  typedef const wchar_t * TGM_LPCTSTR;
127 # endif
128 
129 # ifndef TGM_LPTSTR
130 # define TGM_LPTSTR TGM_LPTSTR
131  typedef wchar_t * TGM_LPTSTR;
133 # endif
134 
135 # ifndef TGM_LPCSTR
136 # define TGM_LPCSTR TGM_LPCSTR
137  typedef const char * TGM_LPCSTR;
139 # endif
140 
141 #else // ARM or Xenomai
142 
143 // on ARM all default strings are ANSI (8bit)
144 # ifndef TGM_LPCTSTR
145 # define TGM_LPCTSTR TGM_LPCTSTR
146  typedef const char * TGM_LPCTSTR;
147 # endif
148 
149 # ifndef TGM_LPTSTR
150 # define TGM_LPTSTR TGM_LPTSTR
151  typedef char * TGM_LPTSTR;
152 # endif
153 
154 // explicit ANSI string type
155 # ifndef TGM_LPCSTR
156 # define TGM_LPCSTR TGM_LPCSTR
157  typedef const char * TGM_LPCSTR;
158 # endif
159 
160 # define TOOLCHAIN_DLL_EXPORT
161 # define CNC_CALC_DLL_EXPORT
162 # define TOOLCHAIN_CALLTYPE
163 
164 #endif // ARM
165 
167 
169 #define TOOL_CHAIN_BAD_INTR_INDEX (-2)
170 #define TOOL_CHAIN_ERROR (-1)
171 #define TOOL_CHAIN_SUCCESS 0
172 #define TOOL_CHAIN_XEXEC 1
173 #define TOOL_CHAIN_XBREAK 2
174 
175 #define ACTUAL_N_AXES (sizeof(P10DOUBLE) / sizeof(double))
177 
179 #define START_CNC_SIMULATION 10
180 #define START_CNC_TEST 20
181 #define START_CNC_FORWARD 30
182 #define START_CNC_FORWARD_NO_MFUNC 31
183 #define START_CNC_BACKWARD 32
184 #define START_CNC_FORWARD_SKIP_FIRST_M 33
185 #define START_CNC_CONNECT 40
186 #define START_CNC_CONNECT_MOVE 41
187 #define START_CNC_GOTO_POSITION 50
188 #define START_CNC_CALCULATING 60
189 #define START_CNC_HELP 999
190 
191 #define RESET_CNC_NO_G92 1
193 
194 #ifndef MAX_DECLARED_PARAMS
195 # define NUMBER_OF_VARIABLES 100
197 # define SUB_PARS 50
199 # define MAX_DECLARED_PARAMS (NUMBER_OF_VARIABLES + SUB_PARS)
201 # define MAXLABELLENGTH 40
203 #endif
204 
213 #define MAX_M_FUNC_IN_G (4)
214 
215 #ifndef ADDR_IDX
216 // simplify G-code address indexing
217 # define ADDR_IDX(w) ((w) - 'A')
218 # define G_FUNC_IDX ADDR_IDX('G')
219 # define M_FUNC_IDX ADDR_IDX('M')
220 # define X_ADDR_IDX ADDR_IDX('X')
221 # define Y_ADDR_IDX ADDR_IDX('Y')
222 # define Z_ADDR_IDX ADDR_IDX('Z')
223 # define C_ADDR_IDX ADDR_IDX('C')
224 # define F_ADDR_IDX ADDR_IDX('F')
225 # define S_ADDR_IDX ADDR_IDX('S')
226 #endif
227 
229 //################################### Enumerations ################################################
235 
237 enum cnc_status : int32_t
238 {
261 
280 
285 
298 
299  statusNONSENSE = -1234,
301 };
302 
304 enum connect_type : int32_t
305 {
407 };
408 
412 enum axis_idx : int32_t
413 {
414  AXIS_NONE = -1,
415  AXIS_X = 0,
425  AXIS_S = 100,
429  AXIS_XY = 200
430 };
431 
435 
437 //################################### Structures declaration ######################################
443 
447 {
448  uint32_t m_editorLine;
449  int32_t m_fileIdx;
450  int32_t m_gCodeIndex;
451 };
452 
456 {
457  double m_setFeed;
458  double m_calcFeed;
459  double m_actFeed;
460  double m_relFeed;
461  double m_actPartLen;
465  double m_actPartsLen;
466  int32_t m_nWorkCounter;
467  int32_t m_nG00Counter;
470  int32_t m_nMCounter;
472  int32_t m_MasterFileIdx;
473  int32_t m_statusCNC;
474  double m_cncRunTime;
475 };
476 
479 struct P10DOUBLE
480 {
481  // use union -> allow different naming convention or loops
482  union
483  {
484  // using anonymous struct
485  struct // all axes as separate members
486  {
487  double x_axis;
488  double y_axis;
489  double z_axis;
490  double c_axis;
491  double b_axis;
492  double u_axis;
493  double v_axis;
494  double w_axis;
495  double a_axis;
496  double o_axis;
497  };
498  struct
499  {
500  double xyzcbuvwao[10];
501  };
502  struct // legacy variables naming
503  {
504  double x;
505  double y;
506  double z;
507  double c;
508  double buvwao[6];
509  };
510  };
511  // member methods
512  // --------------
514  P10DOUBLE(double xVal, double yVal, double zVal, double cVal,
515  double bVal = 0.0, double uVal = 0.0, double vVal = 0.0,
516  double wVal = 0.0, double aVal = 0.0, double oVal = 0.0)
517  : x_axis(xVal)
518  , y_axis(yVal)
519  , z_axis(zVal)
520  , c_axis(cVal)
521  , b_axis(bVal)
522  , u_axis(uVal)
523  , v_axis(vVal)
524  , w_axis(wVal)
525  , a_axis(aVal)
526  , o_axis(oVal)
527  {
528  }
531  {
532  // use optimized memset instead of settings all the parameters to zero
533  memset(this, 0, sizeof(P10DOUBLE));
534  }
536  explicit P10DOUBLE(bool bNoInit) // -V730
537  {
538  UNREFERENCED_PARAM(bNoInit);
539  }
542  {
543  // use c library optimized memcpy instead of setting all the members one-to-one
544  memcpy(this, &n, sizeof(P10DOUBLE));
545  }
548  {
549  if (this != &n)
550  {
551  memcpy(this, &n, sizeof(P10DOUBLE));
552  }
553  return *this;
554  }
555 
557  void CopyFrom(const P10DOUBLE &n)
558  {
559  memcpy(this, &n, sizeof(P10DOUBLE));
560  }
561 
563  void SetToZero()
564  {
565  // use optimized memset instead of settings all the parameters to zero
566  memset(this, 0, sizeof(P10DOUBLE));
567  }
569  void SetAllToValue(double val)
570  {
571  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
572  xyzcbuvwao[i] = val;
573  }
574 
575  // usefull operators
576  P10DOUBLE &operator+=(const P10DOUBLE &n)
577  {
578  // optimizer might unroll the loop
579  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
580  xyzcbuvwao[i] += n.xyzcbuvwao[i];
581  return *this;
582  }
583  P10DOUBLE &operator+=(const double n)
584  {
585  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
586  xyzcbuvwao[i] += n;
587  return *this;
588  }
589  P10DOUBLE &operator-=(const P10DOUBLE &n)
590  {
591  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
592  xyzcbuvwao[i] -= n.xyzcbuvwao[i];
593  return *this;
594  }
595  P10DOUBLE &operator-=(const double n)
596  {
597  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
598  xyzcbuvwao[i] -= n;
599  return *this;
600  }
601 
602  int operator<(const double n) const
603  {
604  return x_axis < n && y_axis < n && z_axis < n && c_axis < n &&
605  b_axis < n && u_axis < n && v_axis < n &&
606  w_axis < n && a_axis < n && o_axis < n;
607  }
608 
609  // divide operator
610  P10DOUBLE &operator/=(const double val)
611  {
612  assert(fabs(val) >= 1e-12);
613  double val1x = 1.0;
614  if (fabs(val) >= 1e-12)
615  {
616  val1x /= val;
617  }
618  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
619  xyzcbuvwao[i] *= val1x;
620  return *this;
621  }
622 
623  // multiply operator
624  P10DOUBLE &operator*=(const double val)
625  {
626  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
627  xyzcbuvwao[i] *= val;
628  return *this;
629  }
630 
631  // Add operator
632  friend P10DOUBLE operator+(const P10DOUBLE &a, const P10DOUBLE &b)
633  {
634  return P10DOUBLE(a.x_axis + b.x_axis,
635  a.y_axis + b.y_axis,
636  a.z_axis + b.z_axis,
637  a.c_axis + b.c_axis,
638  a.b_axis + b.b_axis,
639  a.u_axis + b.u_axis,
640  a.v_axis + b.v_axis,
641  a.w_axis + b.w_axis,
642  a.a_axis + b.a_axis,
643  a.o_axis + b.o_axis);
644  }
645  // subtract operator
646  friend P10DOUBLE operator-(const P10DOUBLE &a, const P10DOUBLE &b)
647  {
648  return P10DOUBLE(a.x_axis - b.x_axis,
649  a.y_axis - b.y_axis,
650  a.z_axis - b.z_axis,
651  a.c_axis - b.c_axis,
652  a.b_axis - b.b_axis,
653  a.u_axis - b.u_axis,
654  a.v_axis - b.v_axis,
655  a.w_axis - b.w_axis,
656  a.a_axis - b.a_axis,
657  a.o_axis - b.o_axis);
658  }
659  // unary minus operator
660  friend P10DOUBLE operator-(const P10DOUBLE &a)
661  {
662  return P10DOUBLE(-a.x_axis,
663  -a.y_axis,
664  -a.z_axis,
665  -a.c_axis,
666  -a.b_axis,
667  -a.u_axis,
668  -a.v_axis,
669  -a.w_axis,
670  -a.a_axis,
671  -a.o_axis);
672  }
673 
674  friend P10DOUBLE operator*(const P10DOUBLE &a, const double val)
675  {
676  return P10DOUBLE(a.x_axis * val,
677  a.y_axis * val,
678  a.z_axis * val,
679  a.c_axis * val,
680  a.b_axis * val,
681  a.u_axis * val,
682  a.v_axis * val,
683  a.w_axis * val,
684  a.a_axis * val,
685  a.o_axis * val);
686  }
687 
688  // internal inline public functions declared in a separate file (CNC_cncpars2005.h)
689  // compare to closeness
690  intptr_t IsNearToAll(const P10DOUBLE &a, double threshold) const;
691  intptr_t IsNearToAllByPlane(const P10DOUBLE &a, double threshold, intptr_t plane) const;
692  intptr_t IsNearToAll_CheckInvalidValue(const P10DOUBLE &a, const P10DOUBLE &threshold) const;
693  intptr_t IsNearToAll_CheckInvalidValue(const P10DOUBLE &a, double threshold) const;
694  intptr_t IsNearToXYZC(const P10DOUBLE &a, double threshold) const;
695  intptr_t IsNearToXYZ(const P10DOUBLE &a, double threshold) const;
696  intptr_t IsNearToZCBUVWAO(const P10DOUBLE &a, double threshold) const;
697  intptr_t IsNearToXY(const P10DOUBLE &a, double threshold) const;
698  intptr_t IsOutOfXY(const P10DOUBLE &a, double threshold) const;
699  // if any member is larger than INVALID_VALUE (i.e. > 1e-38), reset to zero
700  void ResetInvalidPositions();
701  // calculate distance to zero
702  double Length() const
703  {
704  double squareLen = 0.0;
705  for (size_t i = 0; i < _countof(xyzcbuvwao); i++)
706  {
707  squareLen += xyzcbuvwao[i] * xyzcbuvwao[i];
708  }
709  return sqrt(squareLen);
710  }
711  // calculate length of line
712  double Length(const P10DOUBLE &n) const
713  {
714  double dx = 0.0, dy = 0.0, dz = 0.0, dc = 0.0;
715  double d0 = 0.0, d1 = 0.0, d2 = 0.0, d3 = 0.0, d4 = 0.0, d5 = 0.0;
716  if (x < INVALID_VALUE) dx = x;
717  if (y < INVALID_VALUE) dy = y;
718  if (z < INVALID_VALUE) dz = z;
719  if (c < INVALID_VALUE) dc = c;
720  if (buvwao[0] < INVALID_VALUE) d0 = buvwao[0];
721  if (buvwao[1] < INVALID_VALUE) d1 = buvwao[1];
722  if (buvwao[2] < INVALID_VALUE) d2 = buvwao[2];
723  if (buvwao[3] < INVALID_VALUE) d3 = buvwao[3];
724  if (buvwao[4] < INVALID_VALUE) d4 = buvwao[4];
725  if (buvwao[5] < INVALID_VALUE) d5 = buvwao[5];
726  if (n.x < INVALID_VALUE) dx -= n.x;
727  if (n.y < INVALID_VALUE) dy -= n.y;
728  if (n.z < INVALID_VALUE) dz -= n.z;
729  if (n.c < INVALID_VALUE) dc -= n.c;
730  if (n.buvwao[0] < INVALID_VALUE) d0 -= n.buvwao[0];
731  if (n.buvwao[1] < INVALID_VALUE) d1 -= n.buvwao[1];
732  if (n.buvwao[2] < INVALID_VALUE) d2 -= n.buvwao[2];
733  if (n.buvwao[3] < INVALID_VALUE) d3 -= n.buvwao[3];
734  if (n.buvwao[4] < INVALID_VALUE) d4 -= n.buvwao[4];
735  if (n.buvwao[5] < INVALID_VALUE) d5 -= n.buvwao[5];
736  return sqrt(dx * dx + dy * dy + dz * dz + dc * dc + d0 * d0 + d1 * d1 + d2 * d2 + d3 * d3 +
737  d4 * d4 + d5 * d5);
738  }
739  // square lengths
740  double SquareLength(const P10DOUBLE &n) const;
741  double SquareLengthXYZCBU(const P10DOUBLE &n) const;
742  double SquareLengthXYZ_BU_NoC(const P10DOUBLE &n) const;
743  double SquareLengthXYZC(const P10DOUBLE &n) const;
744  double SquareLengthXYZ(const P10DOUBLE &n) const;
745  double SquareLengthXY(const P10DOUBLE &n) const;
746 
747  void Round(double accuracy, double accuracy1x);
748  void RoundXY(double accuracy, double accuracy1x);
749 };
750 
752 
754 struct P10BOOL
755 {
756  // use union -> allow different naming convention or loops
757  union
758  {
759  struct // all axes as separate members
760  {
761  int32_t x_axis;
762  int32_t y_axis;
763  int32_t z_axis;
764  int32_t c_axis;
765  int32_t b_axis;
766  int32_t u_axis;
767  int32_t v_axis;
768  int32_t w_axis;
769  int32_t a_axis;
770  int32_t o_axis;
771  };
772  struct
773  {
774  int32_t xyzcbuvwao[10];
775  };
776  struct // legacy variables naming
777  {
778  int32_t x;
779  int32_t y;
780  int32_t z;
781  int32_t c;
782  int32_t buvwao[6];
783  };
784  };
786  P10BOOL(int32_t _x, int32_t _y, int32_t _z, int32_t _c,
787  int32_t _b, int32_t _u, int32_t _v, int32_t _w, int32_t _a, int32_t _o)
788  : x_axis(_x)
789  , y_axis(_y)
790  , z_axis(_z)
791  , c_axis(_c)
792  , b_axis(_b)
793  , u_axis(_u)
794  , v_axis(_v)
795  , w_axis(_w)
796  , a_axis(_a)
797  , o_axis(_o)
798  {
799  }
801  P10BOOL() { memset(this, 0, sizeof(P10BOOL)); }
803  P10BOOL(const P10BOOL &n) { memcpy(this, &n, sizeof(P10BOOL)); }
806  {
807  if (&n == this)
808  return *this;
809  memcpy(this, &n, sizeof(P10BOOL));
810  return *this;
811  }
812 };
813 
815 
816 // internal structures
817 // simplified circle description
818 struct P4CIRCLE
819 {
820  double x; // circle center X
821  double y; // circle center Y
822  double z; // circle center Z
823  double c; // radius
824 
825  // constructor
826  P4CIRCLE(double _x, double _y, double _z, double _c) : x(_x), y(_y), z(_z), c(_c) {}
827  // default constructor
828  P4CIRCLE() { memset(this, 0, sizeof(P4CIRCLE)); }
829  // no init contructor
830  explicit P4CIRCLE(bool bNoInit) // -V730
831  {
832  UNREFERENCED_PARAM(bNoInit);
833  }
834  // copy constructor
835  P4CIRCLE(const P4CIRCLE &n) { memcpy(this, &n, sizeof(P4CIRCLE)); }
836  // Assign operator
837  P4CIRCLE &operator=(const P4CIRCLE &n)
838  {
839  if (this != &n)
840  memcpy(this, &n, sizeof(P4CIRCLE));
841  return *this;
842  }
843 
844  void SetToZero() { memset(this, 0, sizeof(P4CIRCLE)); }
845 
846  inline P4CIRCLE &operator+=(const P4CIRCLE &n)
847  {
848  x += n.x; y += n.y; z += n.z; c += n.c;
849  return *this;
850  }
851  // += operator
852  inline P4CIRCLE &operator+=(const double n)
853  {
854  x += n; y += n; z += n; c += n;
855  return *this;
856  }
857  inline P4CIRCLE &operator-=(const P4CIRCLE &n)
858  {
859  x -= n.x; y -= n.y; z -= n.z; c -= n.c;
860  return *this;
861  }
862  // += operator
863  inline P4CIRCLE &operator-=(const double n)
864  {
865  x -= n; y -= n; z -= n; c -= n;
866  return *this;
867  }
868 
869  inline int operator<(const double n) { return x < n && y < n && z < n && c < n; }
870 
871  // divide operator
872  inline P4CIRCLE &operator/=(const double val)
873  {
874  assert(fabs(val) >= 1e-12);
875  if (fabs(val) >= 1e-12)
876  {
877  double val1x = 1.0 / val;
878  x *= val1x; y *= val1x; z *= val1x; c *= val1x;
879  }
880  return *this;
881  }
882 
883  // multiply operator
884  inline P4CIRCLE &operator*=(const double val)
885  {
886  x *= val; y *= val; z *= val;c *= val;
887  return *this;
888  }
889 
890  // Add operator
891  friend inline P4CIRCLE operator+(const P4CIRCLE &a, const P4CIRCLE &b)
892  {
893  return P4CIRCLE(a.x + b.x, a.y + b.y, a.z + b.z, a.c + b.c);
894  }
895  // subtract operator
896  friend inline P4CIRCLE operator-(const P4CIRCLE &a, const P4CIRCLE &b)
897  {
898  return P4CIRCLE(a.x - b.x, a.y - b.y, a.z - b.z, a.c - b.c);
899  }
900  // unary minus operator
901  friend inline P4CIRCLE operator-(const P4CIRCLE &a)
902  {
903  return P4CIRCLE(-a.x, -a.y, -a.z, -a.c);
904  }
905 
906  friend inline P4CIRCLE operator*(const P4CIRCLE &a, const double val)
907  {
908  return P4CIRCLE(a.x * val, a.y * val, a.z * val, a.c * val);
909  }
910 
911  void SetAllToValue(double val) { x = y = z = c = val; }
912 
913  intptr_t IsNearToAll(const P10DOUBLE &a, double threshold) const;
914  intptr_t IsNearToAll(const P4CIRCLE &a, double threshold) const;
915  intptr_t IsNearToAllByPlane(const P10DOUBLE &a, double threshold, intptr_t plane) const;
916  intptr_t IsNearToAll_CheckInvalidValue(const P10DOUBLE &a, const P10DOUBLE &threshold) const;
917  intptr_t IsNearToAll_CheckInvalidValue(const P10DOUBLE &a, double threshold) const;
918  intptr_t IsNearToXYZC(const P10DOUBLE &a, double threshold) const;
919  intptr_t IsNearToXYZ(const P10DOUBLE &a, double threshold) const;
920  intptr_t IsNearToXY(const P10DOUBLE &a, double threshold) const;
921  intptr_t IsOutOfXY(const P10DOUBLE &a, double threshold) const;
922  void ResetInvalidPositions();
923  double Length() const { return sqrt(x * x + y * y + z * z + c * c); }
924  double Length(const P10DOUBLE &n) const;
925  double SquareLength(const P10DOUBLE &n) const;
926  double SquareLengthXYZC(const P10DOUBLE &n) const;
927  double SquareLengthXYZ(const P10DOUBLE &n) const;
928  double SquareLengthXY(const P10DOUBLE &n) const;
929  void Round(double accuracy, double accuracy1x);
930  void RoundXY(double accuracy, double accuracy1x);
931 
932 private:
933  int64_t roundTo64bitInt(double v)
934  {
935  return static_cast<int64_t>(v >= 0.0 ? v + 0.5 : v - 0.5); // -V2003
936  }
937 };
938 
939 
942 {
947 // P10DOUBLE m_zero; //!< actual zero offset (G54 - G57)
948  P4CIRCLE m_cc;
949  float m_pars[MAX_FUNC_ADDRESSES];
950  int32_t m_func;
952  int32_t m_planeTool;
955  uint32_t m_reserved;
956  uint32_t m_editorLine;
957  int32_t m_fileIdx;
958  int32_t m_gCodeIndex;
963  int32_t m_bFeedIsMin;
966  float m_fp;
968 
969 #ifdef __cplusplus
970  // no init contructor (optimization)
971  explicit SIMPLE_GM_PARAMS_BASE(bool bNoInit) // -V730
972  : m_s(bNoInit)
973  , m_e(bNoInit)
974  , m_calcS(bNoInit)
975  , m_calcE(bNoInit)
976 // , m_zero(bNoInit)
977  , m_cc(bNoInit)
978  {
979  UNREFERENCED_PARAM(bNoInit);
980  }
982  m_s(),
983  m_e(),
984  m_calcS(),
985  m_calcE(),
986 // m_zero(),
987  m_cc() // -V730
988  {
989  // optimization: other members MUST initialized in the derived class SIMPLE_GM_PARAMS
990  }
992  : m_s(false)
993  , m_e(false)
994  , m_calcS(false)
995  , m_calcE(false)
996 // , m_zero(false)
997  , m_cc(false)
998  {
999  memcpy(this, &n, sizeof(SIMPLE_GM_PARAMS_BASE));
1000  }
1001  SIMPLE_GM_PARAMS_BASE &operator=(const SIMPLE_GM_PARAMS_BASE &n)
1002  {
1003  if (this != &n)
1004  memcpy(this, &n, sizeof(SIMPLE_GM_PARAMS_BASE));
1005  return *this;
1006  }
1007 #endif // __cplusplus
1008 
1009 };
1010 
1014 {
1021  float m_pars[MAX_FUNC_ADDRESSES];
1022 
1040  int32_t m_func;
1044  int32_t m_planeTool;
1047  uint32_t m_reserved;
1048  uint32_t m_editorLine;
1049  int32_t m_fileIdx;
1050  int32_t m_gCodeIndex;
1051  int32_t m_bFeedIsMin;
1055  float m_fp;
1056 
1057  // constructor
1058  // optimization: uses no-init contructors of P10DOUBLE members
1060  : m_s(false)
1061  , m_e(false)
1062  , m_calcS(false)
1063  , m_calcE(false)
1064  , m_zero(false)
1065  , m_cc(false)
1066  {
1067  memset(this, 0, sizeof(SIMPLE_GM_PARAMS_WIN32));
1068  }
1070  : m_s(false)
1071  , m_e(false)
1072  , m_calcS(false)
1073  , m_calcE(false)
1074  , m_zero(false)
1075  , m_cc(false)
1076  {
1077  memcpy(this, &n, sizeof(SIMPLE_GM_PARAMS_WIN32));
1078  }
1080  : m_s(false)
1081  , m_e(false)
1082  , m_calcS(false)
1083  , m_calcE(false)
1084  , m_zero(false)
1085  , m_cc(false)
1086  {
1087  CopyFrom(n, zero);
1088  }
1089  SIMPLE_GM_PARAMS_WIN32 &operator=(const SIMPLE_GM_PARAMS_WIN32 &n)
1090  {
1091  if (this != &n)
1092  memcpy(this, &n, sizeof(SIMPLE_GM_PARAMS_WIN32));
1093  return *this;
1094  }
1095  // auxiliary methods
1096  void CopyFrom(const SIMPLE_GM_PARAMS_BASE &n, const P10DOUBLE &zero)
1097  {
1098  static_assert(sizeof(m_pars) == sizeof(n.m_pars),
1099  "Size of SIMPLE_GM_PARAMS_BASE::m_pars and SIMPLE_GM_PARAMS_WIN32::m_pars must be the same");
1100  m_s.CopyFrom(n.m_s);
1101  m_e.CopyFrom(n.m_e);
1102  m_calcS.CopyFrom(n.m_calcS);
1103  m_calcE.CopyFrom(n.m_calcE);
1104  m_zero.CopyFrom(zero);
1105  m_cc.x = n.m_cc.x;
1106  m_cc.y = n.m_cc.y;
1107  m_cc.z = n.m_cc.z;
1108  m_cc.c = n.m_cc.c;
1109  memcpy(m_pars, n.m_pars, sizeof(m_pars));
1110  m_func = n.m_func;
1111  m_planeTool = n.m_planeTool;
1112  m_reserved = n.m_reserved;
1113  m_editorLine = n.m_editorLine;
1114  m_fileIdx = n.m_fileIdx;
1115  m_gCodeIndex = n.m_gCodeIndex;
1116  m_bFeedIsMin = n.m_bFeedIsMin;
1117  m_fp = n.m_fp;
1118  }
1119 
1120  void Func(const int32_t f)
1121  {
1122  m_func = f;
1123  }
1124 
1125  void Feed(const double f, const int32_t bIsMin)
1126  {
1127  m_pars[F_ADDR_IDX] = static_cast<float>(f);
1128  if (bIsMin)
1129  m_bFeedIsMin |= 1;
1130  else
1131  m_bFeedIsMin &= ~1;
1132  }
1133 
1134  void Spindle(const double s)
1135  {
1136  m_pars[S_ADDR_IDX] = static_cast<float>(s);
1137  }
1138 
1139  void AssignmentIdx(const int32_t p)
1140  {
1141  m_planeTool = p;
1142  }
1143 
1144  void GCodeIndex(const int32_t idx)
1145  {
1146  m_gCodeIndex = idx;
1147  }
1148 };
1149 
1153 
1155 {
1156  int32_t stringId;
1157  int32_t nLines;
1159  int32_t actLine;
1161  int32_t fileIdx;
1163  TGM_LPCSTR m_fullError;
1166  TGM_LPCSTR m_errorArguments;
1194 
1195  CALLBACK_INFO() : stringId(-1), nLines(0), actLine(0), fileIdx(-1)
1196  {
1197  m_fullError = nullptr;
1198  m_errorArguments = nullptr;
1199  }
1200  CALLBACK_INFO(int _stringId) : stringId(_stringId), nLines(0), actLine(0), fileIdx(-1)
1201  {
1202  m_fullError = nullptr;
1203  m_errorArguments = nullptr;
1204  }
1205 };
1206 
1207 
1209 // G-code parameters:
1211 
1214 {
1215  double feed;
1216  double acc;
1217  double dec;
1218  int32_t rampType;
1219  int32_t padding1;
1220 };
1221 
1224 {
1225  double maxFeed;
1226  double maxAcc;
1227  double maxDec;
1228 };
1229 
1232 {
1233  double size;
1234  int32_t gCode;
1235  int32_t padding1;
1236 };
1237 
1243 {
1244  double m_r;
1245  double m_relFeed;
1246 };
1247 
1251 {
1252  int32_t mFunc;
1253  double relFeed;
1254  double distance;
1256 };
1257 
1260 {
1261  int32_t absMode;
1267 
1268  int32_t swapG2G3;
1271 
1273 #define CORR_STRATEGY_G41_ALREADY_CORRECTED 0
1274 #define CORR_STRATEGY_G41_STARTS_CORRECTION 1
1276 #define CORR_STRATEGY_MASK 0xFF
1277 
1281 #define CORR_STRATEGY_OLD_VERSION 0x80000000
1282 
1284 #define CORR_STRATEGY_G00_WITHOUT_CORR 0x40000000
1285 
1288 #define CORR_STRATEGY_FORCE_TO_CONTINUE 0x20000000
1289 
1291 #define CORR_STRATEGY_CHECK_ORIGINAL_GCODE 0x02000000
1292 
1294 #define CORR_STRATEGY_REMOVE_LAST_ARC 0x01000000
1295 
1297 #define CORR_STRATEGY_REMOVE_FIRST_ARC 0x00800000
1298 
1301 #define CORR_STRATEGY_NO_ADD_R 0x00400000
1302 
1306 #define CORR_STRATEGY_REMOVE_SMALL_ARCS 0x00200000
1307 
1309 #define CORR_STRATEGY_ALLOW_REVERSE_LINES 0x00100000
1310 
1312 #define CORR_STRATEGY_REMOVE_CROSSES 0x00080000
1313 
1315 #define CORR_STRATEGY_CONNECT_WRONG_BY_G1 0x00040000
1316 
1319 #define CORR_STRATEGY_CONNECT_WRONG_BY_MOVE 0x00020000
1320 
1322 #define CORR_STRATEGY_ALLOW_FIRST_LAST_CROSS 0x00010000
1323 
1324 #define CORR_STRATEGY_SEARCH_MASK 0x00000700
1325 
1327 #define CORR_STRATEGY_SEARCH_DEEP_10 0x00000100
1328 #define CORR_STRATEGY_SEARCH_DEEP_50 0x00000200
1330 #define CORR_STRATEGY_SEARCH_DEEP_100 0x00000300
1332 #define CORR_STRATEGY_SEARCH_DEEP_500 0x00000400
1334 #define CORR_STRATEGY_SEARCH_DEEP_1000 0x00000500
1336 #define CORR_STRATEGY_SEARCH_DEEP_2000 0x00000600
1338 #define CORR_STRATEGY_SEARCH_DEEP_ALL 0x00000700
1340 
1342 #define CORR_STRATEGY_DEFAULT_DEEP 1000
1343 #define CORR_STRATEGY_MIN_DEEP 10
1344 
1397 
1398 
1400 #define F_BY_GCODE 0
1401 #define F_BY_PARAMETERS 1
1403 #define F_BY_PARAMETERS_FP_BY_GCODE 2
1405 
1406  int32_t forceMode;
1419 
1420  // indexes to feed table
1421 #define DEF_GCODE_FEED_G00 0
1422 #define DEF_GCODE_FEED_G01 1
1423 #define DEF_GCODE_FEED_REVERSE 2
1424 #define DEF_GCODE_FEED_CONNECT 3
1425 #define DEF_GCODE_FEED_WITHOUT_M 4
1426 #define DEF_GCODE_FEED_GOTO_POSITION 5
1427 #define DEF_GCODE_FEED_NORMAL_STOP 6
1428 #define DEF_GCODE_FEED_EMERGENCY_STOP 7
1429 
1430  GCODE_FEED motion[8];
1442 
1443  GCODE_CORRECTION correction[8];
1455 
1460  double startAngle;
1466  double endAngle;
1484  double overrideInc;
1490 
1491  ARC_FEED_TABLE arcFeedTable[5];
1506 
1507  INTERNAL_MFUNC_INSERT_TABLE mFuncInsertTable[3];
1525 
1526  double reserved;
1528 
1548  int32_t M07_coolOn;
1551  int32_t M08_oilOn;
1557  int32_t M17_return;
1560  int32_t M29_print;
1563  int32_t M80_mirrorOff;
1566  int32_t M81_mirrorX;
1569  int32_t M82_mirrorY;
1572  int32_t M83_mirrorZ;
1575  int32_t M84_mirrorXY;
1578  int32_t M85_mirrorXZ;
1581  int32_t M86_mirrorYZ;
1584  int32_t M87_mirrorXYZ;
1587  int32_t M99_defFeed;
1590 
1591  int32_t insertArcMode;
1596 
1597 #define DISABLE_OPCODE_CALL 0x00000001
1598 #define DISABLE_ASSIGN_CALL 0x00000002
1599 #define DISABLE_REFRESH_ALL_PARAMS_CALL 0x00000004
1626  int32_t reserved1;
1627  int32_t calcTime;
1630  int32_t reserved2;
1642  double dynamicG41Correction_percent;
1648 
1649  // indexes to tolerance array
1650 #define GCODE_ALLOWED_CIRC_CENTER_ACCURACY 0
1651 #define GCODE_CROSSING_ACCURACY 1
1652 #define GCODE_ANGULAR_PRECISION 2
1653 #define GCODE_ANGULAR_DISTANCE_PRECISION 3
1654 #define GCODE_MINIMAL_ALLOWED_ARC_R 4
1655 #define GCODE_NO_ADD_R_MULTIPLIER 5
1656 #define GCODE_SOURCE_PRECISION 6
1657 #define GCODE_MINIMAL_ALLOWED_LINE_LENGTH 7
1658 
1659  double tolerance[10];
1670 
1671 #ifdef __cplusplus
1672  // constructor
1674  {
1675  memset(this, 0, sizeof(GCODE_PARAMETERS));
1676  absMode = 1;
1677  startAngle = 360.0; // disable angle override by default
1678  endAngle = 360.0;
1679  M02_programEnd1 = 2;
1680  M30_programEnd2 = 30;
1681  M03_startSpindleCW = 3;
1682  M04_startSpindleCCW = 4; // -V112
1683  M05_stopSpindle = 5;
1684  M06_changeTool = 6;
1685  M07_coolOn = 7;
1686  M08_oilOn = 8;
1687  M09_coolOilOff = 9;
1688  M17_return = 17;
1689  M29_print = 29;
1690  M80_mirrorOff = 80;
1691  M81_mirrorX = 81;
1692  M82_mirrorY = 82;
1693  M83_mirrorZ = 83;
1694  M84_mirrorXY = 84;
1695  M85_mirrorXZ = 85;
1696  M86_mirrorYZ = 86;
1697  M87_mirrorXYZ = 87;
1698  M99_defFeed = 99;
1699  insertArcToleranceRMax = 0.03;
1700  insertArcToleranceRMin = 0.03;
1701 
1702  tolerance[GCODE_ALLOWED_CIRC_CENTER_ACCURACY] = 0.005;
1703  tolerance[GCODE_CROSSING_ACCURACY] = 0.001;
1704  tolerance[GCODE_ANGULAR_PRECISION] = 0.03;
1705  tolerance[GCODE_ANGULAR_DISTANCE_PRECISION] = 0.005;
1706  tolerance[GCODE_NO_ADD_R_MULTIPLIER] = 3.0;
1707  tolerance[GCODE_SOURCE_PRECISION] = 0.01;
1708  }
1709 #endif // __cplusplus
1710 };
1711 
1713 
1714 struct P4CIRCLE; // internal struct forward declaration
1715 
1718 {
1719 public:
1724 
1725  // internal functions
1726  void SetStartPos(const P10DOUBLE &start);
1727  void MinMaxLine(const P10DOUBLE &end);
1728  void MinMaxCirc(const int type, const int plane, const P10DOUBLE &start, const P10DOUBLE &end,
1729  const P4CIRCLE &cc);
1730 
1731 protected:
1732  int angleQuadrant(double x, double y, int type) const;
1733  void getMinMax(const int type, const int plane, double &minX, double &minY, double &minZ,
1734  double &maxX, double &maxY, double &maxZ, const P4CIRCLE &cc, int fq,
1735  int sq) const;
1736 };
1737 
1740 {
1741 // indexes to size array
1742 #define GCODE_SIZE_ORIGINAL_IDX 0
1743 #define GCODE_SIZE_CORRECTED_IDX 1
1744 #define GCODE_SIZE_ROTATED_IDX 2
1745 #define GCODE_SIZE_ROTATED_CORRECTED 3
1746 
1747  GCODE_SIZE m_size[4];
1755 };
1756 
1758 
1761 {
1765 
1766 #define LOCAL_CORE_MODE_TGM 0
1767 #define LOCAL_CORE_MODE_DLL 1
1768 #define LOCAL_CORE_MODE_OFFLINE 2
1769 
1777 
1778 };
1779 
1781 
1784 {
1792  uint32_t enhancedInterpolatorParameters;
1800 };
1802 
1803 #define INTERPOLATOR_LINEAR_FUNC 1 // @flag 1 | <f Interpolator_Linear>
1804 #define INTERPOLATOR_ARC_CW_FUNC 2 // @flag 2 | <f Interpolator_Arc> CW
1805 #define INTERPOLATOR_ARC_CCW_FUNC 3 // @flag 3 | Interpolator_Arc CCW
1806 #define INTERPOLATOR_CLEAR_FUNC 4
1807 #define INTERPOLATOR_GENERIC_FUNC 5 // any generic G-function
1808 #define INTERPOLATOR_G0_FUNC 10 // G0
1809 #define INTERPOLATOR_STOP_FUNC 30 // @flag 30 | <f Interpolator_Stop>
1810 #define INTERPOLATOR_START_FUNC 31 // @flag 31 | <f Interpolator_Start>
1811 #define INTERPOLATOR_NORMAL_STOP_FUNC 32 // @flag 32 | <f Interpolator_NormalStop>
1812 #define INTERPOLATOR_SET_COORDS_FUNC 92 // @flag 92 | <f Interpolator_SetCoords>
1813 #define INTERPOLATOR_SET_PARAMS_FUNC 93 // @flag 93 | <f Interpolator_SetParams>
1814 #define INTERPOLATOR_SET_MACHINE_PARAMS_FUNC 94 // @flag 94 | SetMachineParams (called via SetParams)
1815 #define INTERPOLATOR_SET_DOUBLE_INTEGER_PARS 95 // @flag 95
1816 #define INTERPOLATOR_CONTINUOUS_M_FUNC 999 // @flag 999 | prubezna M funkce
1817 #define INTERPOLATOR_M_FUNC 1000 // @flag 1000 | M funkce s cekanim
1818 
1819 #define INTERPOLATOR_MAX_N_USER_PARAMS 26 // max supported number of M function addresses
1820 
1823  uint32_t nFunc;
1824  //
1825  // @flag 1 | Linear (= G1)
1826  // @flag 2 | Arc CW (= G2)
1827  // @flag 3 | Arc CCW (= G3)
1828  // @flag 30 | Emergency Stop
1829  // @flag 31 | Start
1830  // @flag 32 | Normal Stop
1831  // @flag 92 | SetCoords (= G92)
1832  // @flag 999 | M funkce (prubezna)
1833  // @flag 1000 | M funkce (cekaci)
1834  uint32_t nCoords;
1835  int32_t gCodeIdx;
1836  uint32_t editorLine;
1837 
1838  union {
1839  struct // commands: 1, 2, 3, 92
1840  {
1841  double coords[ACTUAL_N_AXES];
1842  double feed;
1843  double arcCenter[3];
1844  // circCenter[0] a circCenter[1], rezerva pro XYZ souradnici v prostoru
1845  uint32_t arcAxis[2];
1846  } c;
1847 
1848  struct // command: 999, 1000 (M functions)
1849  {
1850  int32_t funcNumber;
1851  uint32_t timeout;
1852  float fltMParams[INTERPOLATOR_MAX_N_USER_PARAMS];
1853  } m;
1854 
1855  struct // command: 95
1856  {
1857  double acc;
1858  double dec;
1859  double start_angle;
1860  double end_angle;
1861  double minimal_feed;
1862  double reserve[8];
1864  // @flag 0 | mm/min (minutovy)
1865  // @flag 1 | mm/ot (otackovy)
1866  // @flag 2 | otackovy (zavisly na poloze vretene, start podle pozice)
1867  // @flag 3 | otackovy (zavisly na poloze vretene, start podle pulzu)
1868  // @flag 4 | minutovy bez override posuvu (G00 plna rychlost)
1869  // @normal cislo nastroje v hornich 24 bitech
1870 
1871  uint32_t fileIdx;
1872  uint32_t correction;
1873 
1875  // = 0 | zarucena je vzdy nizsi rychlost
1876  // = 1 | snazi se zrychlovat tak, aby na zacatku pohybu uz byla pozadovana rychlost, pokud je to mozne
1877  } p;
1878  } u;
1879 };
1880 
1884 
1886 //################################### Function callbacks ###########################################
1888 
1893 
1894 #define CALLBACK_CALLTYPE TOOLCHAIN_CALLTYPE
1895 
1896 typedef int32_t CALLBACK_CALLTYPE FuncPrototype(intptr_t dwUserData);
1898 
1899 #define DEVICE_ERROR_OUT_TAB 0
1900 #define CNC_OUT_TAB 1
1901 #define M29_OUT_TAB 2
1902 #define STATUS_LINE_ONLY 3
1903 #define ACTIVATE_TAB 0x100
1904 #define PREFIX_TIME 0x200
1905 #define HIDE_OUTPUT_VIEW 0x400
1906 
1908 #define APP_AddOutputLogFunc 1
1909 typedef int32_t CALLBACK_CALLTYPE AddOutputLogFunc(intptr_t dwUserData,
1923  int32_t tab,
1924  TGM_LPCTSTR info,
1925  CALLBACK_INFO *callBackInfo);
1926 
1928 #define APP_SetStatusBarTextFunc 2
1929 typedef int32_t CALLBACK_CALLTYPE SetStatusBarTextFunc(intptr_t dwUserData,
1937  int32_t pane,
1938  TGM_LPCTSTR strText,
1939  CALLBACK_INFO *callBackInfo);
1940 
1942 #define APP_IsDebugModeFunc 3
1943 typedef int32_t CALLBACK_CALLTYPE IsDebugModeFunc(intptr_t dwUserData);
1950 
1952 #define APP_IsVerboseModeFunc 4
1953 typedef int32_t CALLBACK_CALLTYPE IsVerboseModeFunc(intptr_t dwUserData);
1960 
1962 #define APP_GetLibPathFunc 5
1963 typedef TGM_LPCTSTR CALLBACK_CALLTYPE GetLibPathFunc(intptr_t dwUserData);
1968 
1970 #define APP_GetToolPathFunc 6
1971 typedef TGM_LPCTSTR CALLBACK_CALLTYPE GetToolPathFunc(intptr_t dwUserData);
1976 
1978 #define APP_GetSystemPathFunc 7
1979 typedef TGM_LPCTSTR CALLBACK_CALLTYPE GetSystemPathFunc(intptr_t dwUserData); // path for system directory
1984 
1985 
1987 #define APP_GetFileTimeStampFunc 10
1988 typedef int64_t CALLBACK_CALLTYPE GetFileTimeStampFunc(intptr_t dwUserData, uint32_t fileIdx);
1994 
1996 #define APP_DoYieldFunc 11
1997 typedef int32_t CALLBACK_CALLTYPE DoYieldFunc(intptr_t dwUserData, int32_t messageOnly);
2003 
2005 #define APP_ReadIniStringFunc 12
2006 typedef void CALLBACK_CALLTYPE ReadIniStringFunc(intptr_t dwUserData,
2016  TGM_LPCTSTR section,
2017  TGM_LPCTSTR key,
2018  TGM_LPCTSTR defValue,
2019  TGM_LPTSTR buffer,
2020  uint32_t bufferSizeInCharacters);
2021 
2023 #define APP_ReadIniDoubleFunc 13
2024 typedef double CALLBACK_CALLTYPE ReadIniDoubleFunc(intptr_t dwUserData,
2033  TGM_LPCTSTR section,
2034  TGM_LPCTSTR key,
2035  double defValue);
2036 
2038 #define APP_ReadIniIntFunc 14
2039 typedef int32_t CALLBACK_CALLTYPE ReadIniIntFunc(intptr_t dwUserData,
2048  TGM_LPCTSTR section,
2049  TGM_LPCTSTR key,
2050  int32_t defValue);
2051 
2053 #define APP_DispRunInfoAndWaitFunc 15
2054 typedef int32_t CALLBACK_CALLTYPE DispRunInfoAndWaitFunc(intptr_t dwUserData,
2066  uint32_t editorLine,
2067  int32_t fileIdx,
2068  TGM_LPCTSTR statusInfo,
2069  int32_t bNoBreakpoints,
2070  int32_t bForceToWait,
2071  const double *params,
2072  const uint32_t maxParams);
2073 
2075 #define APP_DispRunInfoFunc 16
2076 typedef int32_t CALLBACK_CALLTYPE DispRunInfoFunc(intptr_t dwUserData,
2085  uint32_t editorLine,
2086  int32_t fileIdx,
2087  TGM_LPCTSTR statusInfo,
2088  const SIMPLE_GM_PARAMS_WIN32 *pCmd);
2089 
2091 #define APP_IsBreakpointFunc 17
2092 typedef int32_t CALLBACK_CALLTYPE IsBreakpointFunc(intptr_t dwUserData,
2100  uint32_t editorLine,
2101  int32_t fileIdx);
2102 
2104 #define APP_DispAndLocateErrorFunc 18
2105 typedef int32_t CALLBACK_CALLTYPE DispAndLocateErrorFunc(intptr_t dwUserData,
2117  uint32_t editorLine,
2118  int32_t fileIdx,
2119  TGM_LPCTSTR errString,
2120  CALLBACK_INFO *callBackInfo);
2121 
2123 #define APP_DispLastInfoFunc 19
2124 typedef int32_t CALLBACK_CALLTYPE DispLastInfoFunc(intptr_t dwUserData);
2129 
2131 #define APP_IsStepModeFunc 20
2132 typedef int32_t CALLBACK_CALLTYPE IsStepModeFunc(intptr_t dwUserData);
2136 
2138 #define APP_IsHandControlFunc 21
2139 typedef int32_t CALLBACK_CALLTYPE IsHandControlFunc(intptr_t dwUserData);
2143 
2145 #define APP_SetRegimeFromUserKeyFunc 22
2146 typedef int32_t CALLBACK_CALLTYPE SetRegimeFromUserKeyFunc(intptr_t dwUserData, int32_t key);
2151 
2153 #define APP_ExecMenuCommandFromUserKeyFunc 23
2154 typedef int32_t CALLBACK_CALLTYPE ExecMenuCommandFromUserKeyFunc(intptr_t dwUserData, int key);
2159 
2160 
2162 #define APP_MaxFuncNumber 1000
2163 
2164 
2166 #define DRV_InitializeFunc 1001
2167 typedef int32_t CALLBACK_CALLTYPE DriverInitializeFunc(intptr_t dwUserData,
2177  double *params,
2178  uint32_t nParams,
2179  int32_t bTestMode);
2180 
2182 #define DRV_GFunc 1002
2183 typedef int32_t CALLBACK_CALLTYPE DriverGFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v);
2188 
2190 #define DRV_MFunc 1003
2191 typedef int32_t CALLBACK_CALLTYPE DriverMFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v);
2196 
2198 #define ConnectPointCalcStartFuncNumber 1004
2199 typedef int32_t CALLBACK_CALLTYPE ConnectPointCalcStartFunc(intptr_t dwUserData,
2210  const int32_t nType,
2211  const uint32_t nCoords,
2212  const double *coords,
2213  const uint32_t bitCodedAxesForCalc);
2214 
2216 #define ConnectPointCalcFunc_UseReturnValues 1
2217 
2219 #define ConnectPointCalcFuncNumber 1005
2220 
2239 
2240 typedef int32_t CALLBACK_CALLTYPE ConnectPointCalcFunc(intptr_t dwUserData,
2241  const SIMPLE_GM_PARAMS_WIN32 *part,
2242  double *calcSquareDistanceFromCoords,
2243  P10DOUBLE *calcConnectPoint);
2244 
2246 #define ConnectPointCalcEndFuncNumber 1006
2247 typedef int32_t CALLBACK_CALLTYPE ConnectPointCalcEndFunc(intptr_t dwUserData,
2260  SIMPLE_GM_PARAMS_WIN32 *partToBeConnectedTo,
2261  P10DOUBLE *connectPosToBeMovedTo);
2262 
2264 #define DRV_MaxFuncNumber 2000
2265 
2267 #define MATH_WarningFunc 2001
2268 typedef int32_t CALLBACK_CALLTYPE MathWarningFunc(intptr_t dwUserData, CALLBACK_INFO *pCallbackInfo);
2274 
2275 
2277 #define MATH_MaxFuncNumber 3000 // last function in DRV group
2278 
2282 
2283 
2284 //################################### Main SF_TCh exported functions ######################################
2289 
2290 #ifdef __cplusplus
2291 extern "C" {
2292 #endif
2293 
2303  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_Init(DLL_INIT_STRUCT *pInitValues);
2304  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_INIT(DLL_INIT_STRUCT *pInitValues);
2305 
2332  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_LoadFromIni(int32_t intIdx,
2333  TGM_LPCTSTR iniFile,
2334  int32_t *pnMaxCores);
2335  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_LOADFROMINI(int32_t intIdx,
2336  TGM_LPCTSTR iniFile,
2337  int32_t *pnMaxCores);
2338 
2344  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_DestroyCNC(int32_t intIdx);
2345  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_DESTROYCNC(int32_t intIdx);
2346 
2359  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetGCodeParameters(int32_t intIdx,
2360  const GCODE_PARAMETERS *params);
2361  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_SETGCODEPARAMETERS(int32_t intIdx,
2362  const GCODE_PARAMETERS *params);
2363 
2372  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetGCodeParameters(int32_t intIdx,
2373  GCODE_PARAMETERS *params);
2374  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GETGCODEPARAMETERS(int32_t intIdx,
2375  GCODE_PARAMETERS *params);
2376 
2411  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StatusCNC(int32_t intIdx);
2412  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_STATUSCNC(int32_t intIdx);
2413 
2430  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetPos(int32_t intIdx,
2431  int32_t regime,
2433  GM_PARAMS_ENHANCED *enhParams);
2434  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GETPOS(int32_t intIdx,
2435  int32_t regime,
2437  GM_PARAMS_ENHANCED *enhParams);
2438 
2451  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_CompileFromFile(int32_t intIdx,
2452  TGM_LPCTSTR fileName);
2453  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_COMPILEFROMFILE(int32_t intIdx,
2454  TGM_LPCTSTR fileName);
2455 
2470  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_CompileFromMemory(int32_t intIdx,
2471  TGM_LPCTSTR fileName,
2472  TGM_LPCSTR mainCode);
2473  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_COMPILEFROMMEMORY(int32_t intIdx,
2474  TGM_LPCTSTR fileName,
2475  TGM_LPCSTR mainCode);
2476 
2480  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_IsBusy(int32_t intIdx);
2481  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_ISBUSY(int32_t intIdx);
2482 
2506  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StartCNCEx(int32_t intIdx,
2507  int32_t regime,
2508  TGM_LPCSTR strAddGCode);
2509  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_STARTCNCEX(int32_t intIdx,
2510  int32_t regime,
2511  TGM_LPCSTR strAddGCode);
2512 
2531  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_ResetCNC(int32_t intIdx,
2532  int32_t regime,
2533  const uint32_t nCoords,
2534  const double *coords);
2535  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_RESETCNC(int32_t intIdx,
2536  int32_t regime,
2537  const uint32_t nCoords,
2538  const double *coords);
2539 
2556  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StopCNCEx(int32_t intIdx, TGM_LPCSTR strAddCode);
2557  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_STOPCNCEX(int32_t intIdx, TGM_LPCSTR strAddCode);
2558 
2609  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_ConnectCNCEx_Plane(int32_t intIdx,
2610  int32_t nType,
2611  const uint32_t nCoords,
2612  const double *coords,
2613  TGM_LPCSTR strAddCode,
2614  uint32_t bitCodedAxesForCalc,
2615  uint32_t bitCodedAxesForConnect,
2616  int32_t trajectoryStateAfterConnect);
2617  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_CONNECTCNCEX_PLANE(int32_t intIdx,
2618  int32_t nType,
2619  const uint32_t nCoords,
2620  const double *coords,
2621  TGM_LPCSTR strAddCode,
2622  uint32_t bitCodedAxesForCalc,
2623  uint32_t bitCodedAxesForConnect,
2624  int32_t trajectoryStateAfterConnect);
2625 
2626 
2639  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPosition(int32_t intIdx,
2640  const uint32_t nCoords,
2641  const double *coords);
2642  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GOTOPOSITION(int32_t intIdx,
2643  const uint32_t nCoords,
2644  const double *coords);
2645 
2665  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPositionEx(int32_t intIdx,
2666  const SIMPLE_GM_PARAMS_WIN32 *pDest);
2667  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GOTOPOSITIONEX(int32_t intIdx,
2668  const SIMPLE_GM_PARAMS_WIN32 *pDest);
2669 
2670 
2683  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_MFunc(int32_t intIdx,
2684  const SIMPLE_GM_PARAMS_WIN32 &fun,
2685  int32_t bDirectToPLC);
2686  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_MFUNC(int32_t intIdx,
2687  const SIMPLE_GM_PARAMS_WIN32 &fun,
2688  int32_t bDirectToPLC);
2689 
2690 
2703  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_FileToIdx(int32_t intIdx,
2704  TGM_LPCTSTR fileName);
2705  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_FILETOIDX(int32_t intIdx,
2706  TGM_LPCTSTR fileName);
2707 
2718  TOOLCHAIN_DLL_EXPORT TGM_LPCTSTR TOOLCHAIN_CALLTYPE ToolChainCore_IdxToFile(int32_t intIdx,
2719  int32_t fileIdx);
2720  typedef TGM_LPCTSTR TOOLCHAIN_CALLTYPE TOOLCHAINCORE_IDXTOFILE(int32_t intIdx,
2721  int32_t fileIdx);
2722 
2732  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetRelFeed(int32_t intIdx,
2733  double relFeed);
2734  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_SETRELFEED(int32_t intIdx,
2735  double relFeed);
2736 
2737 
2754  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetCallBack(int32_t intIdx,
2755  int32_t fceNo,
2756  intptr_t dwUserData,
2757  FuncPrototype *funcPtr);
2758  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_SETCALLBACK(int32_t intIdx,
2759  int32_t fceNo,
2760  intptr_t dwUserData,
2761  FuncPrototype *funcPtr);
2762 
2763 
2778  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetLastError(int32_t intIdx,
2779  CALLBACK_INFO *pLastErrorInfo);
2780  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GETLASTERROR(int32_t intIdx,
2781  CALLBACK_INFO *pLastErrorInfo);
2782 
2783 
2794  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetBreakpoint(int32_t intIdx,
2795  uint32_t editorLine,
2796  int32_t fileIdx);
2797  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_SETBREAKPOINT(int32_t intIdx,
2798  uint32_t editorLine,
2799  int32_t fileIdx);
2800 
2801 
2811  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetGCodeSizeInfo(int32_t intIdx,
2812  GCODE_INFO *pInfo);
2813  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GETGCODESIZEINFO(int32_t intIdx,
2814  GCODE_INFO *pInfo);
2815 
2832  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetStructuresSize(int32_t intIdx,
2833  uint32_t nItems,
2834  uint32_t *items);
2835  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GETSTRUCTURESSIZE(int32_t intIdx,
2836  uint32_t nItems,
2837  uint32_t *items);
2838 
2839 
2843  TOOLCHAIN_DLL_EXPORT TGM_LPCTSTR TOOLCHAIN_CALLTYPE ToolChainCore_GetVersionString(int32_t intIdx);
2844  typedef TGM_LPCTSTR TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GETVERSIONSTRING(int32_t intIdx);
2845 
2846 
2857  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetMachineParameters(int32_t intIdx,
2858  MACHINE_PARAMETERS *pParameters);
2859  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_GETMACHINEPARAMETERS(int32_t intIdx,
2860  MACHINE_PARAMETERS *pParameters);
2861 
2873  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetMachineParameters(int32_t intIdx,
2874  const MACHINE_PARAMETERS *pParameters);
2875 
2876  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_SETMACHINEPARAMETERS(int32_t intIdx,
2877  const MACHINE_PARAMETERS *pParameters);
2878 
2879 #define CNC_CALC_LOAD_ALL 0
2880 #define CNC_CALC_LOAD_DLL_ONLY 1
2881 #define CNC_CALC_LOAD_TGM_ONLY 2
2882 
2883 
2920  TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_LoadCNCCalcPlugIn(TGM_LPCTSTR fileName, uint32_t loadFlags, int64_t userValue);
2921  typedef int32_t TOOLCHAIN_CALLTYPE TOOLCHAINCORE_LOADCNCCALCPLUGIN(TGM_LPCTSTR fileName, uint32_t loadFlags, int64_t userValue);
2922 
2926 
2927 //################################### Exported functions for CNC Calc plug-in DLL ##########################
2946 
2947 #ifdef __GNUC__
2948 #define TGM_COM_CALLTYPE
2949 #else
2950 #define TGM_COM_CALLTYPE __cdecl
2951 #endif
2952 
2953 #ifdef WIN32
2954 
2955 # if !defined(_UNICODE)
2956 # error "_UNICODE must be defined for WIN32"
2957 # endif
2958 
2959 typedef const wchar_t * CNC_CONST_STRING;
2960 
2961 #else // WIN32
2962 
2963 #include <stdlib.h>
2964 
2965 typedef const char * CNC_CONST_STRING;
2966 
2967 // mark text as ANSI/UNICODE compatible
2968 #ifndef _T
2969 # define _T(a) (a)
2970 #endif
2971 
2972 #endif
2973 
2974  // read/write functions from TGM_Comm_Int_2
2975 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_I32(uint32_t memoryType, uint32_t offset, int32_t *pValue);
2976 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_I64(uint32_t memoryType, uint32_t offset, int64_t *pValue);
2977 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_double(uint32_t memoryType, uint32_t offset, double *pValue);
2978 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_BLOCK(uint32_t memoryType, uint32_t offset, void *buffer, uint32_t bufferLength);
2979 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_I32(uint32_t memoryType, uint32_t offset, int32_t Value);
2980 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_I64(uint32_t memoryType, uint32_t offset, int64_t Value);
2981 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_double(uint32_t memoryType, uint32_t offset, double Value);
2982 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_BLOCK(uint32_t memoryType, uint32_t offset, const void *buffer, uint32_t bufferLength);
2983 typedef int32_t TGM_COM_CALLTYPE TGM_COM_SET_BIT_I32(uint32_t memoryType, uint32_t offset, int32_t Value);
2984 typedef int32_t TGM_COM_CALLTYPE TGM_COM_SET_BIT_I64(uint32_t memoryType, uint32_t offset, int64_t Value);
2985 typedef int32_t TGM_COM_CALLTYPE TGM_COM_CLR_BIT_I32(uint32_t memoryType, uint32_t offset, int32_t Value);
2986 typedef int32_t TGM_COM_CALLTYPE TGM_COM_CLR_BIT_I64(uint32_t memoryType, uint32_t offset, int64_t Value);
2987 typedef int32_t TGM_COM_CALLTYPE TGM_COM_TGL_BIT_I32(uint32_t memoryType, uint32_t offset, int32_t Value);
2988 typedef int32_t TGM_COM_CALLTYPE TGM_COM_TGL_BIT_I64(uint32_t memoryType, uint32_t offset, int64_t Value);
2989 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_I32_DIRECT(uint32_t memoryType, uint32_t offset, int32_t *pValue);
2990 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_I64_DIRECT(uint32_t memoryType, uint32_t offset, int64_t *pValue);
2991 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_double_DIRECT(uint32_t memoryType, uint32_t offset, double *pValue);
2992 typedef int32_t TGM_COM_CALLTYPE TGM_COM_READ_BLOCK_DIRECT(uint32_t memoryType, uint32_t offset, void *buffer, uint32_t bufferLength);
2993 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_I32_DIRECT(uint32_t memoryType, uint32_t offset, int32_t Value);
2994 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_I64_DIRECT(uint32_t memoryType, uint32_t offset, int64_t Value);
2995 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_double_DIRECT(uint32_t memoryType, uint32_t offset, double Value);
2996 typedef int32_t TGM_COM_CALLTYPE TGM_COM_WRITE_BLOCK_DIRECT(uint32_t memoryType, uint32_t offset, const void *buffer, uint32_t bufferLength);
2997 typedef int32_t TGM_COM_CALLTYPE TGM_COM_SET_BIT_I32_DIRECT(uint32_t memoryType, uint32_t offset, int32_t Value);
2998 typedef int32_t TGM_COM_CALLTYPE TGM_COM_SET_BIT_I64_DIRECT(uint32_t memoryType, uint32_t offset, int64_t Value);
2999 typedef int32_t TGM_COM_CALLTYPE TGM_COM_CLR_BIT_I32_DIRECT(uint32_t memoryType, uint32_t offset, int32_t Value);
3000 typedef int32_t TGM_COM_CALLTYPE TGM_COM_CLR_BIT_I64_DIRECT(uint32_t memoryType, uint32_t offset, int64_t Value);
3001 typedef int32_t TGM_COM_CALLTYPE TGM_COM_TGL_BIT_I32_DIRECT(uint32_t memoryType, uint32_t offset, int32_t Value);
3002 typedef int32_t TGM_COM_CALLTYPE TGM_COM_TGL_BIT_I64_DIRECT(uint32_t memoryType, uint32_t offset, int64_t Value);
3003 typedef int32_t TGM_COM_CALLTYPE TGM_COM_FLUSH_BUFFER();
3004 // debug output function
3005 typedef int32_t TGM_COM_CALLTYPE TGM_RTWPRINTF_EX(int32_t severity, CNC_CONST_STRING strFormat, ...);
3006 
3012 {
3013  uint32_t structSize;
3014  TGM_COM_READ_I32 *pReadI32;
3015  TGM_COM_READ_I64 *pReadI64;
3016  TGM_COM_READ_double *pReadDouble;
3017  TGM_COM_READ_BLOCK *pReadBlock;
3018  TGM_COM_WRITE_I32 *pWriteI32;
3019  TGM_COM_WRITE_I64 *pWriteI64;
3020  TGM_COM_WRITE_double *pWriteDouble;
3021  TGM_COM_WRITE_BLOCK *pWriteBlock;
3022  TGM_COM_SET_BIT_I32 *pSetBitI32;
3023  TGM_COM_SET_BIT_I64 *pSetBitI64;
3024  TGM_COM_CLR_BIT_I32 *pClrBitI32;
3025  TGM_COM_CLR_BIT_I64 *pClrBitI64;
3026  TGM_COM_TGL_BIT_I32 *pTglBitI32;
3027  TGM_COM_TGL_BIT_I64 *pTglBitI64;
3028  TGM_COM_READ_I32_DIRECT *pReadI32Direct;
3029  TGM_COM_READ_I64_DIRECT *pReadI64Direct;
3030  TGM_COM_READ_double_DIRECT *pReadDoubleDirect;
3031  TGM_COM_READ_BLOCK_DIRECT *pReadBlockDirect;
3032  TGM_COM_WRITE_I32_DIRECT *pWriteI32Direct;
3033  TGM_COM_WRITE_I64_DIRECT *pWriteI64Direct;
3034  TGM_COM_WRITE_double_DIRECT *pWriteDoubleDirect;
3035  TGM_COM_WRITE_BLOCK_DIRECT *pWriteBlockDirect;
3036  TGM_COM_SET_BIT_I32_DIRECT *pSetBitI32Direct;
3037  TGM_COM_SET_BIT_I64_DIRECT *pSetBitI64Direct;
3038  TGM_COM_CLR_BIT_I32_DIRECT *pClrBitI32Direct;
3039  TGM_COM_CLR_BIT_I64_DIRECT *pClrBitI64Direct;
3040  TGM_COM_TGL_BIT_I32_DIRECT *pTglBitI32Direct;
3041  TGM_COM_TGL_BIT_I64_DIRECT *pTglBitI64Direct;
3042  TGM_COM_FLUSH_BUFFER *pFlushBuffer;
3043  TGM_RTWPRINTF_EX *pPrintf;
3044  int64_t userValue;
3048 };
3049 
3050 
3051 
3052 #define CNC_CALC_MFUNC_OFFSET 10000
3053 
3054 #define CNC_CALC_DISABLE_AUTOMATIC_GCODEINDEX_UPDATE_BIT 0x01
3055 
3056 #define CNC_CALC_MAX_STATIC_RETURNED_PARTS 8
3057 
3061 struct CNC_CALC_RETURN_VALUE
3067 {
3068  double dblFeed;
3069  int32_t options;
3070  uint32_t nEntriesInPart0;
3075  int32_t reserved2;
3078 };
3079 
3080 #define CNC_CALC_RETURN_ERROR (-1)
3081 
3083 #define CNC_CALC_RETURN_IGNORE 0
3084 
3086 #define CNC_CALC_RETURN_USE 1
3087 
3089 #define CNC_CALC_RETURN_OK 1
3090 
3092 #define CNC_CALC_RETURN_FEED_ONLY 2
3093 
3095 CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Load(const CNC_CALC_INIT_DATA *pInitData);
3104 typedef int32_t TOOLCHAIN_CALLTYPE CNC_CALC_LOAD(const CNC_CALC_INIT_DATA *pInitData);
3105 
3109 CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Unload();
3110 typedef int32_t TOOLCHAIN_CALLTYPE CNC_CALC_UNLOAD();
3111 
3112 #define CNC_CALC_IDX_INIT_DATA_STRUCT 0
3113 #define CNC_CALC_IDX_SIMPLE_GM_PARAMS_BASE_STRUCT 1
3114 #define CNC_CALC_IDX_RETURN_VALUE_STRUCT 2
3115 
3144 CNC_CALC_DLL_EXPORT uint32_t TOOLCHAIN_CALLTYPE CNC_Calc_Get_Structures_Size(uint32_t structureIdx);
3145 typedef uint32_t TOOLCHAIN_CALLTYPE CNC_CALC_GET_STRUCTURES_SIZE(uint32_t structureIdx);
3146 
3169 CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Get_Compatibility_IDs(uint32_t *pID_COMPATIBILITY,
3170  uint32_t *pID_MEMORY_COMPATIBILITY,
3171  uint32_t *pID_CNC_COMPATIBILITY);
3172 typedef int32_t TOOLCHAIN_CALLTYPE CNC_CALC_GET_COMPATIBILITY_IDS(uint32_t *pID_COMPATIBILITY,
3173  uint32_t *pID_MEMORY_COMPATIBILITY,
3174  uint32_t *pID_CNC_COMPATIBILITY);
3175 
3199 
3200 CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Start(uint32_t intIdx,
3201  int32_t regime,
3202  const SIMPLE_GM_PARAMS_BASE *pInitPos,
3203  CNC_CALC_RETURN_VALUE *pChangedParts);
3204 typedef int32_t TOOLCHAIN_CALLTYPE CNC_CALC_START(uint32_t intIdx,
3205  int32_t regime,
3206  const SIMPLE_GM_PARAMS_BASE *pInitPos,
3207  CNC_CALC_RETURN_VALUE *pChangedParts);
3208 
3305 
3306 CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_GFunc(uint32_t intIdx,
3307  const SIMPLE_GM_PARAMS_BASE *pGFunc,
3308  CNC_CALC_RETURN_VALUE *pChangedParts);
3309 
3310 typedef int32_t TOOLCHAIN_CALLTYPE CNC_CALC_GFUNC(uint32_t intIdx,
3311  const SIMPLE_GM_PARAMS_BASE *pGFunc,
3312  CNC_CALC_RETURN_VALUE *pChangedParts);
3327 
3328 CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_MFunc(uint32_t intIdx,
3329  const SIMPLE_GM_PARAMS_BASE *pMFunc,
3330  CNC_CALC_RETURN_VALUE *pChangedParts);
3331 
3332 typedef int32_t TOOLCHAIN_CALLTYPE CNC_CALC_MFUNC(uint32_t intIdx,
3333  const SIMPLE_GM_PARAMS_BASE *pMFunc,
3334  CNC_CALC_RETURN_VALUE *pChangedParts);
3341 
3342 CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Finish(uint32_t intIdx,
3343  const SIMPLE_GM_PARAMS_BASE *pFinishMFunc,
3344  CNC_CALC_RETURN_VALUE *pChangedParts);
3345 
3346 typedef int32_t TOOLCHAIN_CALLTYPE CNC_CALC_FINISH(uint32_t intIdx,
3347  const SIMPLE_GM_PARAMS_BASE *pFinishMFunc,
3348  CNC_CALC_RETURN_VALUE *pChangedParts);
3349 
3353 
3354 #ifdef __cplusplus
3355 } // extern "C"
3356 #endif
3357 
3359 #define G_FUNC_SETTINGS 900
3360 
3361 #define G_FUNC_SETTINGS_PUSH 1
3362 #define G_FUNC_SETTINGS_POP 2
3363 #define G_FUNC_SETTINGS_SET_AXIS_LIMITS 7
3364 #define G_FUNC_SETTINGS_SET_MUTUAL_ANGLES 9
3365 #define G_FUNC_SETTINGS_ENA_MUTUAL_ANGLES 10
3366 #define G_FUNC_SETTINGS_ENA_FEED_CALC 11
3367 #define G_FUNC_SETTINGS_SET_ANGLE_MODE 12
3368 #define G_FUNC_SETTINGS_IGNORE_ARC_FEED_TBL 13
3369 #define G_FUNC_SETTINGS_FEED_G00 20
3370 #define G_FUNC_SETTINGS_FEED_FORWARD 30
3371 #define G_FUNC_SETTINGS_FEED_FORWARD_NO_M 31
3372 #define G_FUNC_SETTINGS_FEED_BACKWARD 32
3373 #define G_FUNC_SETTINGS_FEED_CONNECT 40
3374 #define G_FUNC_SETTINGS_FEED_GOTO 50
3375 #define G_FUNC_SETTINGS_FEED_NORMAL_STOP 60
3376 #define G_FUNC_SETTINGS_FEED_EMERGENCY_STOP 70
3377 
3534 
3535 
3738 
3741 
3742 
3743 #ifdef __GNUC__
3744 # pragma GCC diagnostic pop
3745 #else
3746 # pragma warning(pop)
3747 #endif
3748 
3749 
3750 #endif // TGM_CNC_H_FILE_INCLUDED
3751 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Unload()
Plug-in DLL cleanup.
int32_t CALLBACK_CALLTYPE DriverMFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)
Called to simulate M function.
Definition: TGM_CNC.h:2195
P10DOUBLE(bool bNoInit)
no init contructor - members will be initialized afterwards, use with care
Definition: TGM_CNC.h:536
uint32_t timeout
timeout pro cekaci M funkci
Definition: TGM_CNC.h:1851
int32_t insertArcPlane
Definition: TGM_CNC.h:1623
double overrideInc
Definition: TGM_CNC.h:1484
int32_t M06_changeTool
Definition: TGM_CNC.h:1545
P10DOUBLE m_zero
actual zero offset (G54 - G57)
Definition: TGM_CNC.h:1019
Definition of default feeds.
Definition: TGM_CNC.h:1213
P10DOUBLE m_e
absolute end position (original)
Definition: TGM_CNC.h:944
P10DOUBLE m_e
absolute end position (original)
Definition: TGM_CNC.h:1016
#define _countof(array)
determine number of elements in an array (not bytes)
Definition: TGM_CNC.h:58
TGM_LPCTSTR CALLBACK_CALLTYPE GetSystemPathFunc(intptr_t dwUserData)
Returns path to system files. Not yet used by CNC module.
Definition: TGM_CNC.h:1983
double x_axis
Axis X.
Definition: TGM_CNC.h:487
int32_t reserved2
reserved
Definition: TGM_CNC.h:1630
int32_t forceMode
Definition: TGM_CNC.h:1406
uint32_t fileIdx
index souboru
Definition: TGM_CNC.h:1871
P10DOUBLE m_startPos
Initial position.
Definition: TGM_CNC.h:1720
int32_t b_axis
Axis B.
Definition: TGM_CNC.h:765
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_CompileFromMemory(int32_t intIdx, TGM_LPCTSTR fileName, TGM_LPCSTR mainCode)
Compiles G-code from string in memory.
int32_t stringId
Definition: TGM_CNC.h:1156
double m_actPartRemain
remaining length of section in progress (changes continuously)
Definition: TGM_CNC.h:462
Initialization structure. Used by ToolChainCore_Init.
Definition: TGM_CNC.h:1760
P10BOOL & operator=(const P10BOOL &n)
Assignment operator.
Definition: TGM_CNC.h:805
uint32_t nDynamicEntriesInPart1
number of entries in the dParts1 array
Definition: TGM_CNC.h:3076
int32_t M04_startSpindleCCW
Definition: TGM_CNC.h:1539
double feed
feed
Definition: TGM_CNC.h:1215
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetMachineParameters(int32_t intIdx, MACHINE_PARAMETERS *pParameters)
Returns actual values of MACHINE_PARAMETERS.
const char * TGM_LPCSTR
explicit const UTF-8 (8bit ANSI) string type
Definition: TGM_CNC.h:138
int32_t insertArcMode
Definition: TGM_CNC.h:1591
int32_t mFunc
No. of M function or 0 (if 0 not used)
Definition: TGM_CNC.h:1252
Extended actual parameters.
Definition: TGM_CNC.h:455
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_ConnectCNCEx_Plane(int32_t intIdx, int32_t nType, const uint32_t nCoords, const double *coords, TGM_LPCSTR strAddCode, uint32_t bitCodedAxesForCalc, uint32_t bitCodedAxesForConnect, int32_t trajectoryStateAfterConnect)
Move to the nearest point of trajectory of G-code with possibility of M function insertion after the ...
-2: remote device not connected (TGMmini, TGM_REMOTE)
Definition: TGM_CNC.h:239
#define START_CNC_CALCULATING
Internal calculations are performed. No movement.
Definition: TGM_CNC.h:188
double b_axis
Axis B.
Definition: TGM_CNC.h:491
double v_axis
Axis V.
Definition: TGM_CNC.h:493
TOOLCHAIN_DLL_EXPORT TGM_LPCTSTR TOOLCHAIN_CALLTYPE ToolChainCore_IdxToFile(int32_t intIdx, int32_t fileIdx)
Returns the complete filename of file with relevant number (index).
int32_t M86_mirrorYZ
Definition: TGM_CNC.h:1581
double c_axis
Axis C.
Definition: TGM_CNC.h:490
int32_t CALLBACK_CALLTYPE ConnectPointCalcStartFunc(intptr_t dwUserData, const int32_t nType, const uint32_t nCoords, const double *coords, const uint32_t bitCodedAxesForCalc)
Initiate user connection calculation.
Definition: TGM_CNC.h:2209
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetGCodeSizeInfo(int32_t intIdx, GCODE_INFO *pInfo)
Identifies size (dimension) of G-code.
#define INVALID_VALUE
this "nonsense" value is used for not used G-code addresses.
Definition: TGM_CNC.h:53
4 - B axis
Definition: TGM_CNC.h:419
TGM_LPCTSTR CALLBACK_CALLTYPE GetToolPathFunc(intptr_t dwUserData)
Returns path to files describing tools geometry. Only for lathe.
Definition: TGM_CNC.h:1975
-21: Test broken by ToolChainCore_StopCNCEx
Definition: TGM_CNC.h:259
float m_fp
actual value of FP address (percent of F), usually 1.0
Definition: TGM_CNC.h:966
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetPos(int32_t intIdx, int32_t regime, SIMPLE_GM_PARAMS_WIN32 *pos, GM_PARAMS_ENHANCED *enhParams)
Returns current position of machine axes together with additonal informations.
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_LoadFromIni(int32_t intIdx, TGM_LPCTSTR iniFile, int32_t *pnMaxCores)
Loads DLL chain from INI file.
double u_axis
Axis U.
Definition: TGM_CNC.h:492
int32_t CALLBACK_CALLTYPE SetRegimeFromUserKeyFunc(intptr_t dwUserData, int32_t key)
Reserved.
Definition: TGM_CNC.h:2150
int32_t m_nG00Counter
counter of fastfeeds (G0)
Definition: TGM_CNC.h:467
double size
Size of correction (tool radius) for gCode correction, if negative, the meanings of G41/G42 are switc...
Definition: TGM_CNC.h:1233
int32_t m_fileIdx
File index.
Definition: TGM_CNC.h:1049
-33: Stop on trajectory by M0 function
Definition: TGM_CNC.h:269
int32_t a_axis
Axis A.
Definition: TGM_CNC.h:769
int32_t CALLBACK_CALLTYPE IsDebugModeFunc(intptr_t dwUserData)
Ask if debug regime is enabled.
Definition: TGM_CNC.h:1949
9 - O axis
Definition: TGM_CNC.h:424
int32_t CALLBACK_CALLTYPE SetStatusBarTextFunc(intptr_t dwUserData, int32_t pane, TGM_LPCTSTR strText, CALLBACK_INFO *callBackInfo)
Display informational text in the status line of the application.
Definition: TGM_CNC.h:1936
int32_t M05_stopSpindle
Definition: TGM_CNC.h:1542
G-code size.
Definition: TGM_CNC.h:1739
int32_t M85_mirrorXZ
Definition: TGM_CNC.h:1578
int32_t m_nWorkCounter
counter of cutting parts (G1, G2, G3)
Definition: TGM_CNC.h:466
double relFeed
<0.01;1.0>. Cannot be used for inserting M function before G00.
Definition: TGM_CNC.h:1253
P10DOUBLE m_endPos
End position.
Definition: TGM_CNC.h:1721
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_GFunc(uint32_t intIdx, const SIMPLE_GM_PARAMS_BASE *pGFunc, CNC_CALC_RETURN_VALUE *pChangedParts)
Called for any G function inside G-code.
int32_t M83_mirrorZ
Definition: TGM_CNC.h:1572
#define MAX_FUNC_ADDRESSES
number of letters in alphabet, i.e. all the G-code addresses
Definition: TGM_CNC.h:71
int32_t padding1
reserved
Definition: TGM_CNC.h:1219
-3: sending compiled G-code to TGMmini or TGM_REMOTE, percent progress in GCodeIndex ...
Definition: TGM_CNC.h:241
double dynamicG42Correction_mm
Definition: TGM_CNC.h:1635
101 - tool
Definition: TGM_CNC.h:426
int32_t M99_defFeed
Definition: TGM_CNC.h:1587
uint32_t m_editorLine
Line in G-code.
Definition: TGM_CNC.h:1048
double maxFeed
Max allowed feed.
Definition: TGM_CNC.h:1225
double dynamicG41Correction_mm
Definition: TGM_CNC.h:1632
Initial position, end position and size.
Definition: TGM_CNC.h:1717
const wchar_t * TGM_LPCTSTR
default const string type: Win UNICODE (16bit), Linux UTF-8 (8bit)
Definition: TGM_CNC.h:126
int32_t CALLBACK_CALLTYPE ReadIniIntFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, int32_t defValue)
Read integer value from .INI file.
Definition: TGM_CNC.h:2047
int32_t M07_coolOn
Definition: TGM_CNC.h:1548
Structure similar to P10DOUBLE, using integers. Its use is for setting additional flags to axes...
Definition: TGM_CNC.h:754
int32_t CALLBACK_CALLTYPE DoYieldFunc(intptr_t dwUserData, int32_t messageOnly)
Switch control to other thread. LOCAL_CORE_MODE_DLL only.
Definition: TGM_CNC.h:2002
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_FileToIdx(int32_t intIdx, TGM_LPCTSTR fileName)
Returns index number of the file with a given name. If the file name is new, it returns a new number...
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StatusCNC(int32_t intIdx)
Actual CNC module state.
uint32_t m_reserved
Internal reseved value.
Definition: TGM_CNC.h:1047
int32_t m_nMCounter
M functions counter.
Definition: TGM_CNC.h:470
double CALLBACK_CALLTYPE ReadIniDoubleFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, double defValue)
Read double value from .INI file.
Definition: TGM_CNC.h:2032
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_LoadCNCCalcPlugIn(TGM_LPCTSTR fileName, uint32_t loadFlags, int64_t userValue)
Load CNC Calc plugin (see CNC Calc plug-in exported functions)
-1234: Invalid nonsense value
Definition: TGM_CNC.h:299
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_MFunc(uint32_t intIdx, const SIMPLE_GM_PARAMS_BASE *pMFunc, CNC_CALC_RETURN_VALUE *pChangedParts)
Called for any M function inside G-code.
int32_t c_axis
Axis C.
Definition: TGM_CNC.h:764
90: Extra connecion M functions are sending
Definition: TGM_CNC.h:296
double dec
deceleration, if negative then it is specified as time in [s]
Definition: TGM_CNC.h:1217
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_IsBusy(int32_t intIdx)
Checks if the machine is executing G-code.
int32_t m_func
Number of G or M function.
Definition: TGM_CNC.h:951
int32_t m_speedPreference
strategie dosahovani rezne rychlosti
Definition: TGM_CNC.h:1874
int32_t CALLBACK_CALLTYPE ConnectPointCalcEndFunc(intptr_t dwUserData, SIMPLE_GM_PARAMS_WIN32 *partToBeConnectedTo, P10DOUBLE *connectPosToBeMovedTo)
End of connection calculation.
Definition: TGM_CNC.h:2259
int32_t CALLBACK_CALLTYPE DispRunInfoAndWaitFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx, TGM_LPCTSTR statusInfo, int32_t bNoBreakpoints, int32_t bForceToWait, const double *params, const uint32_t maxParams)
Display info about the actual G-code part.
Definition: TGM_CNC.h:2065
void CopyFrom(const P10DOUBLE &n)
no-check copy
Definition: TGM_CNC.h:557
int32_t y
Axis Y.
Definition: TGM_CNC.h:779
Auxiliary G-code functions use this structure.
Definition: TGM_CNC.h:446
double m_actPartLen
total length of section in progress (changes between sections)
Definition: TGM_CNC.h:461
int32_t m_bFeedIsMin
Definition: TGM_CNC.h:963
#define ACTUAL_N_AXES
number of axes used in CNC module (currently 10)
Definition: TGM_CNC.h:176
40: Calculation of connection point
Definition: TGM_CNC.h:281
Describes one G-code part.
Definition: TGM_CNC.h:1013
int32_t m_gCodeIndex
unique G-code part index
Definition: TGM_CNC.h:450
P10DOUBLE m_minimalPos
Minimum.
Definition: TGM_CNC.h:1722
uint32_t correction
aktualni korekce
Definition: TGM_CNC.h:1872
50: Out of trajectory movement (ToolChainCore_GoToPosition)
Definition: TGM_CNC.h:286
-32: End of trajectory, system stops
Definition: TGM_CNC.h:267
#define START_CNC_FORWARD_SKIP_FIRST_M
Start CNC module forward. The first M function is skipped, then continue like in regime 30...
Definition: TGM_CNC.h:184
double buvwao[6]
other axes (B, U, V, W, A, O)
Definition: TGM_CNC.h:508
P10DOUBLE & operator=(const P10DOUBLE &n)
Assignment operator.
Definition: TGM_CNC.h:547
int32_t absMode
Definition: TGM_CNC.h:1261
int32_t CALLBACK_CALLTYPE FuncPrototype(intptr_t dwUserData)
Generic callback function prototype.
Definition: TGM_CNC.h:1897
void SetAllToValue(double val)
set all members to given value
Definition: TGM_CNC.h:569
int32_t reserved2
reserved
Definition: TGM_CNC.h:3075
P10DOUBLE axisSpeedRatio
Definition: TGM_CNC.h:1799
P10DOUBLE m_calcE
absolute end position recalculated
Definition: TGM_CNC.h:946
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetLastError(int32_t intIdx, CALLBACK_INFO *pLastErrorInfo)
Returns the last error, if any.
int32_t disableG0FeedOverride
Definition: TGM_CNC.h:1474
double acc
acceleration, if negative then it is specified as time in [s]
Definition: TGM_CNC.h:1216
int32_t reserved1
reserved
Definition: TGM_CNC.h:1626
double reserved
reserved
Definition: TGM_CNC.h:1526
uint32_t editorLine
cislo radku ve zdrojovem textu
Definition: TGM_CNC.h:1836
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Finish(uint32_t intIdx, const SIMPLE_GM_PARAMS_BASE *pFinishMFunc, CNC_CALC_RETURN_VALUE *pChangedParts)
Called as the last function of the G-code.
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_MFunc(int32_t intIdx, const SIMPLE_GM_PARAMS_WIN32 &fun, int32_t bDirectToPLC)
Send M function directly to system.
int64_t CALLBACK_CALLTYPE GetFileTimeStampFunc(intptr_t dwUserData, uint32_t fileIdx)
returns time stamp of a given file (usually time in ms since epoch)
Definition: TGM_CNC.h:1993
3 - C axis
Definition: TGM_CNC.h:418
int32_t CALLBACK_CALLTYPE IsBreakpointFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx)
Determines if there is a breakpoint on given G-code file line.
Definition: TGM_CNC.h:2099
int32_t gCodeIdx
cislo useku, pro specialni prikazy muze byt zaporne
Definition: TGM_CNC.h:1835
int32_t swapG2G3
Definition: TGM_CNC.h:1268
double m_setFeed
Required feed in mm/min.
Definition: TGM_CNC.h:457
int32_t m_nG00ToWorkChanges
counter of transitions: fastfeed -> cutting part
Definition: TGM_CNC.h:468
Definition of corrections.
Definition: TGM_CNC.h:1231
Values of inserted M functions.
Definition: TGM_CNC.h:1250
100 - spindle
Definition: TGM_CNC.h:425
double m_actWorkPartsLen
current total length of all cutting parts (G1, G2, G3) - (changes continuously during movement) ...
Definition: TGM_CNC.h:463
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetStructuresSize(int32_t intIdx, uint32_t nItems, uint32_t *items)
Returns bytes sizes of internal structures.
TGM_LPCTSTR CALLBACK_CALLTYPE GetLibPathFunc(intptr_t dwUserData)
Returns path to external G functions stored as G-code on the disk.
Definition: TGM_CNC.h:1967
32: Backward movement on trajectory
Definition: TGM_CNC.h:275
int32_t CALLBACK_CALLTYPE MathWarningFunc(intptr_t dwUserData, CALLBACK_INFO *pCallbackInfo)
Called in case of warning issued during tool diameter compensation calculation.
Definition: TGM_CNC.h:2273
wchar_t * TGM_LPTSTR
default string type: Win UNICODE (16bit), Linux UTF-8 (8bit)
Definition: TGM_CNC.h:132
0 - X axis
Definition: TGM_CNC.h:415
int32_t M03_startSpindleCW
Definition: TGM_CNC.h:1536
double z
Axis Z.
Definition: TGM_CNC.h:506
int32_t M81_mirrorX
Definition: TGM_CNC.h:1566
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPositionEx(int32_t intIdx, const SIMPLE_GM_PARAMS_WIN32 *pDest)
Extended manual control.
double y
Axis Y.
Definition: TGM_CNC.h:505
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetGCodeParameters(int32_t intIdx, const GCODE_PARAMETERS *params)
Sets parameters (properties) of G-code.
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPosition(int32_t intIdx, const uint32_t nCoords, const double *coords)
Manual control.
double xyzcbuvwao[10]
all axes as an array -> use in loops
Definition: TGM_CNC.h:500
int32_t y_axis
Axis Y.
Definition: TGM_CNC.h:762
8 - A axis
Definition: TGM_CNC.h:423
-1: Compile finished (with success or error)
Definition: TGM_CNC.h:247
int32_t m_gCodeIndex
Definition: TGM_CNC.h:958
int32_t M30_programEnd2
Definition: TGM_CNC.h:1533
int32_t CALLBACK_CALLTYPE ConnectPointCalcFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *part, double *calcSquareDistanceFromCoords, P10DOUBLE *calcConnectPoint)
Calculate distance from initial tool point to a give G-code part.
Definition: TGM_CNC.h:2240
int32_t M17_return
Definition: TGM_CNC.h:1557
P10DOUBLE m_calcE
absolute end position recalculated
Definition: TGM_CNC.h:1018
int32_t x_axis
Axis X.
Definition: TGM_CNC.h:761
double o_axis
Axis O.
Definition: TGM_CNC.h:496
double m_relFeed
relative feed
Definition: TGM_CNC.h:1245
int32_t callbackWarningsInvokeMode
Definition: TGM_CNC.h:1517
30: Normal forward movement on trajectory
Definition: TGM_CNC.h:271
One direct command to interpolator.
Definition: TGM_CNC.h:1822
uint32_t m_reserved
Internal reseved value.
Definition: TGM_CNC.h:955
P10BOOL()
default constructor
Definition: TGM_CNC.h:801
P10DOUBLE backlash
Backlash in axes in mm.
Definition: TGM_CNC.h:1789
P10DOUBLE m_s
absolute initial position (original) of type P10DOUBLE
Definition: TGM_CNC.h:1015
int32_t M02_programEnd1
Definition: TGM_CNC.h:1529
10: Simulation is in progress
Definition: TGM_CNC.h:249
-11: Simulation broken by ToolChainCore_StopCNCEx
Definition: TGM_CNC.h:253
60: Internal calculation is in progress
Definition: TGM_CNC.h:290
P10DOUBLE m_maximalPos
Maximum.
Definition: TGM_CNC.h:1723
int32_t M80_mirrorOff
Definition: TGM_CNC.h:1563
-10: Simulation finished (OK or NOK)
Definition: TGM_CNC.h:251
P10BOOL(int32_t _x, int32_t _y, int32_t _z, int32_t _c, int32_t _b, int32_t _u, int32_t _v, int32_t _w, int32_t _a, int32_t _o)
constructor
Definition: TGM_CNC.h:786
int32_t gCode
Number of G function for correction (41, 42,...), not yet used.
Definition: TGM_CNC.h:1234
200 - XY plane
Definition: TGM_CNC.h:429
void SetToZero()
explicitly set all the members to zero
Definition: TGM_CNC.h:563
double w_axis
Axis W.
Definition: TGM_CNC.h:494
103 - secondary spindle
Definition: TGM_CNC.h:428
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetBreakpoint(int32_t intIdx, uint32_t editorLine, int32_t fileIdx)
Set breakpoint in the G-code.
TGM_LPCTSTR Macros_Dir
path to CNC macros (external G and M functions written in G-code)
Definition: TGM_CNC.h:1763
int32_t CALLBACK_CALLTYPE DispLastInfoFunc(intptr_t dwUserData)
Called when G-code execution finished (OK and NOK)
Definition: TGM_CNC.h:2128
TGM_LPCTSTR Comm_Int2_Dir
path to communication library
Definition: TGM_CNC.h:1764
7 - W axis
Definition: TGM_CNC.h:422
int32_t v_axis
Axis V.
Definition: TGM_CNC.h:767
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StartCNCEx(int32_t intIdx, int32_t regime, TGM_LPCSTR strAddGCode)
Start or continue G-code.
int32_t backlashValuesSource
Definition: TGM_CNC.h:1791
double m_actG00PartsLen
current total length of all fastfeeds (G0) - (changes continuously within fastfeed) ...
Definition: TGM_CNC.h:464
int32_t padding1
reserved
Definition: TGM_CNC.h:1235
P10DOUBLE minCoords
Minimal allowed coordinates.
Definition: TGM_CNC.h:1785
double m_r
radius
Definition: TGM_CNC.h:1244
#define START_CNC_FORWARD
Start CNC module forward (normal and most used mode)
Definition: TGM_CNC.h:181
Structure for setting G-code properties.
Definition: TGM_CNC.h:1259
double feed
rychlost pohybu
Definition: TGM_CNC.h:1842
Machine parameters.
Definition: TGM_CNC.h:1783
SIMPLE_GM_PARAMS_BASE * dParts1
pointer to user given array for modified parts. The plug-in is responsible of freeing memory (if need...
Definition: TGM_CNC.h:3077
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetCallBack(int32_t intIdx, int32_t fceNo, intptr_t dwUserData, FuncPrototype *funcPtr)
Sets callback function.
int32_t M82_mirrorY
Definition: TGM_CNC.h:1569
P10DOUBLE(double xVal, double yVal, double zVal, double cVal, double bVal=0.0, double uVal=0.0, double vVal=0.0, double wVal=0.0, double aVal=0.0, double oVal=0.0)
constructor
Definition: TGM_CNC.h:514
P10DOUBLE m_calcS
absolute initial position recalculated (tool size compensation) or actual position (ToolChainCore_Get...
Definition: TGM_CNC.h:1017
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Start(uint32_t intIdx, int32_t regime, const SIMPLE_GM_PARAMS_BASE *pInitPos, CNC_CALC_RETURN_VALUE *pChangedParts)
Called before the G-code execution.
double maxConnectionDistance
Definition: TGM_CNC.h:1456
int32_t w_axis
Axis W.
Definition: TGM_CNC.h:768
float m_pars[MAX_FUNC_ADDRESSES]
the G-code or value is > 1e38 (address not included in the G-code function)
Definition: TGM_CNC.h:949
1: Compile is in progress
Definition: TGM_CNC.h:245
int32_t CALLBACK_CALLTYPE IsHandControlFunc(intptr_t dwUserData)
Ask if application is in hand control (service mode). Not yet used.
Definition: TGM_CNC.h:2142
int32_t m_MasterFileIdx
master file index
Definition: TGM_CNC.h:472
uint32_t nCoords
pocet platnych souradnic v coords
Definition: TGM_CNC.h:1834
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetRelFeed(int32_t intIdx, double relFeed)
Sets the feed override (relative speed).
80: Extra final M function are sending
Definition: TGM_CNC.h:294
double dynamicG42Correction_percent
Definition: TGM_CNC.h:1645
int32_t mFuncInsertType
Definition: TGM_CNC.h:1514
double y_axis
Axis Y.
Definition: TGM_CNC.h:488
int32_t CALLBACK_CALLTYPE DriverInitializeFunc(intptr_t dwUserData, double *params, uint32_t nParams, int32_t bTestMode)
Called always before G-code execution.
Definition: TGM_CNC.h:2176
int32_t rampType
type of ramp: 1 - trapezoid, 2 - sin
Definition: TGM_CNC.h:1218
int32_t correctionStrategy
Definition: TGM_CNC.h:1345
int32_t interpolatorConfig0
Definition: TGM_CNC.h:1477
double z_axis
Axis Z.
Definition: TGM_CNC.h:489
31: Forward movement without M functions (which are skipped)
Definition: TGM_CNC.h:273
uint32_t nFunc
command number:
Definition: TGM_CNC.h:1823
double m_actPartsLen
current total length of motion sections (i.e. all G funcs without waiting M funcs) ...
Definition: TGM_CNC.h:465
double insertArcToleranceRMax
Definition: TGM_CNC.h:1609
P10DOUBLE m_s
absolute initial position (original) of type P10DOUBLE
Definition: TGM_CNC.h:943
int32_t CALLBACK_CALLTYPE DispAndLocateErrorFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx, TGM_LPCTSTR errString, CALLBACK_INFO *callBackInfo)
This function is called in case of an error.
Definition: TGM_CNC.h:2116
void CALLBACK_CALLTYPE ReadIniStringFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, TGM_LPCTSTR defValue, TGM_LPTSTR buffer, uint32_t bufferSizeInCharacters)
Read string from .INI file.
Definition: TGM_CNC.h:2015
Structure for transmitting information for the function ToolChainCore_GetLastError and for the callba...
Definition: TGM_CNC.h:1154
-50: System is stopped and positioned out of trajectory
Definition: TGM_CNC.h:288
This structure defines 10 coordinates of double type (8 bytes)
Definition: TGM_CNC.h:479
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_CompileFromFile(int32_t intIdx, TGM_LPCTSTR fileName)
Compiles G-code from file.
6 - V axis
Definition: TGM_CNC.h:421
TOOLCHAIN_DLL_EXPORT TGM_LPCTSTR TOOLCHAIN_CALLTYPE ToolChainCore_GetVersionString(int32_t intIdx)
Returns the DLLs version number and the date and time of compilation.
int32_t CALLBACK_CALLTYPE IsStepModeFunc(intptr_t dwUserData)
Ask if execute G-code step by step (part by part). Not yet used.
Definition: TGM_CNC.h:2135
70: Extra initial M functions are sending
Definition: TGM_CNC.h:292
Initialization structure.
Definition: TGM_CNC.h:3011
double maxDec
Max allowed deceleration.
Definition: TGM_CNC.h:1227
int32_t M84_mirrorXY
Definition: TGM_CNC.h:1575
int32_t CALLBACK_CALLTYPE DispRunInfoFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx, TGM_LPCTSTR statusInfo, const SIMPLE_GM_PARAMS_WIN32 *pCmd)
Display info about the actual G-code part.
Definition: TGM_CNC.h:2084
int32_t CALLBACK_CALLTYPE DriverGFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)
Called to simulate G function.
Definition: TGM_CNC.h:2187
CNC_CALC_DLL_EXPORT uint32_t TOOLCHAIN_CALLTYPE CNC_Calc_Get_Structures_Size(uint32_t structureIdx)
Check structure sizes - test for compatibility.
P10BOOL(const P10BOOL &n)
copy constructor
Definition: TGM_CNC.h:803
int32_t CALLBACK_CALLTYPE ExecMenuCommandFromUserKeyFunc(intptr_t dwUserData, int key)
Reserved.
Definition: TGM_CNC.h:2158
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_DestroyCNC(int32_t intIdx)
Finishes work with DLLs and frees all the alloctaed memry.
5 - U axis
Definition: TGM_CNC.h:420
double insertArcMaxAngle
Definition: TGM_CNC.h:1617
-20: Test finished (OK or NOK)
Definition: TGM_CNC.h:257
P10BOOL enableMask
Mask to enable testing of limits for individual axes.
Definition: TGM_CNC.h:1788
double centripetalAcc
Maximum allowed centripetal acceleration for arcs (not yet implemented)
Definition: TGM_CNC.h:1504
P10DOUBLE(const P10DOUBLE &n)
copy constructor
Definition: TGM_CNC.h:541
double m_calcFeed
Calculated feed in mm/min.
Definition: TGM_CNC.h:458
P10DOUBLE m_calcS
absolute initial position recalculated (tool size compensation)
Definition: TGM_CNC.h:945
1 - Y axis
Definition: TGM_CNC.h:416
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetGCodeParameters(int32_t intIdx, GCODE_PARAMETERS *params)
Obtains values set with ToolChainCore_SetGCodeParameters, or read from .INI file during startup...
int32_t calcTime
Definition: TGM_CNC.h:1627
no axis is specified (marker for all axes)
Definition: TGM_CNC.h:414
P10DOUBLE refCoords
Reference point for min max coords.
Definition: TGM_CNC.h:1787
connect_type
Connection modes (ToolChainCore_ConnectCNCEx_Plane)
Definition: TGM_CNC.h:304
uint32_t m_editorLine
text row in the soyrce file
Definition: TGM_CNC.h:448
int32_t z
Axis Z.
Definition: TGM_CNC.h:780
cnc_status
StatusCNC return codes.
Definition: TGM_CNC.h:237
#define START_CNC_SIMULATION
Available CNC module regimes:
Definition: TGM_CNC.h:179
int32_t x
Axis X.
Definition: TGM_CNC.h:778
P10DOUBLE backlashInc
Backlash change in mm per 100us.
Definition: TGM_CNC.h:1790
Limits for one axis.
Definition: TGM_CNC.h:1223
#define CNC_CALC_MAX_STATIC_RETURNED_PARTS
Definition: TGM_CNC.h:3056
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Get_Compatibility_IDs(uint32_t *pID_COMPATIBILITY, uint32_t *pID_MEMORY_COMPATIBILITY, uint32_t *pID_CNC_COMPATIBILITY)
Returns compatibility numbers at the time of plug-in build.
double m_cncRunTime
G-code runtime.
Definition: TGM_CNC.h:474
2 - Z axis
Definition: TGM_CNC.h:417
double startAngle
Definition: TGM_CNC.h:1460
int32_t u_axis
Axis U.
Definition: TGM_CNC.h:766
Describes one G-code part.
Definition: TGM_CNC.h:941
#define START_CNC_FORWARD_NO_MFUNC
Start CNC module forward, but all the M functions are ignored (skipped)
Definition: TGM_CNC.h:182
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetMachineParameters(int32_t intIdx, const MACHINE_PARAMETERS *pParameters)
Sets new values of MACHINE_PARAMETERS.
int32_t m_nWorkToG00Changes
counter of transitions: cutting part -> fastfeed
Definition: TGM_CNC.h:469
int32_t M29_print
Definition: TGM_CNC.h:1560
int32_t m_fileIdx
File index.
Definition: TGM_CNC.h:957
uint32_t structSize
CNC_Calc_Load() function should check this value.
Definition: TGM_CNC.h:3013
int32_t m_statusCNC
copy of statusCNC, i.e. ToolChainCore_StatusCNC() function
Definition: TGM_CNC.h:473
double insertArcMinAngle
Definition: TGM_CNC.h:1620
double c
Axis C (e.g. turntable or parting machine)
Definition: TGM_CNC.h:507
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_ResetCNC(int32_t intIdx, int32_t regime, const uint32_t nCoords, const double *coords)
Sets the initial position for G-code.
double a_axis
Axis A.
Definition: TGM_CNC.h:495
int32_t M08_oilOn
Definition: TGM_CNC.h:1551
int32_t c
Axis C (e.g. turntable or parting machine)
Definition: TGM_CNC.h:781
P10DOUBLE maxCoords
Maximal allowed coordinates.
Definition: TGM_CNC.h:1786
int32_t disableAdditionalProgramFlowInfo
Definition: TGM_CNC.h:1600
P4CIRCLE m_cc
arc centre (m_cc.x m_cc.y m_cc.z) and radius (in m_cc.c variable)
Definition: TGM_CNC.h:948
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_Init(DLL_INIT_STRUCT *pInitValues)
Init the CNC module.
Table of speeds, relative arc speeds in relation to radius.
Definition: TGM_CNC.h:1242
int32_t CALLBACK_CALLTYPE AddOutputLogFunc(intptr_t dwUserData, int32_t tab, TGM_LPCTSTR info, CALLBACK_INFO *callBackInfo)
Writes text to output log.
Definition: TGM_CNC.h:1922
double m_relFeed
Feed override(0.5 = 50%, 1.0 = 100%, etc.)
Definition: TGM_CNC.h:460
P10DOUBLE()
default constructor - zero all the members
Definition: TGM_CNC.h:530
double maxAcc
Max allowed acceleration.
Definition: TGM_CNC.h:1226
int32_t z_axis
Axis Z.
Definition: TGM_CNC.h:763
-30: System is on start of trajectory
Definition: TGM_CNC.h:262
uint32_t feedTypeToolNumber
typ posuvu (ve spodnich 8 bitech)
Definition: TGM_CNC.h:1863
102 - any I/O module
Definition: TGM_CNC.h:427
int32_t Local_Core_Mode
Definition: TGM_CNC.h:1770
uint32_t m_editorLine
Line in G-code.
Definition: TGM_CNC.h:956
uint32_t m_MasterEditorLine
actual line in master file
Definition: TGM_CNC.h:471
double endAngle
Definition: TGM_CNC.h:1466
double dblFeed
new feed
Definition: TGM_CNC.h:3068
#define START_CNC_BACKWARD
Start CNC module in backward direction. The backward movement buffer is limited to 1000 parts...
Definition: TGM_CNC.h:183
#define GCODE_ALLOWED_CIRC_CENTER_ACCURACY
Definition: TGM_CNC.h:1650
TGM_LPCTSTR CNC_Dll_Dir
path to the directory with CNC libraries (.dll or .so)
Definition: TGM_CNC.h:1762
double x
Axis X.
Definition: TGM_CNC.h:504
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StopCNCEx(int32_t intIdx, TGM_LPCSTR strAddCode)
Stops motion or connecting (break).
float m_fp
actual value of FP address (percent of F), usually 1.0
Definition: TGM_CNC.h:1055
int32_t funcNumber
M function number.
Definition: TGM_CNC.h:1850
int32_t m_fileIdx
index to file, can be negative (special file numbers)
Definition: TGM_CNC.h:449
#define CALLBACK_CALLTYPE
Callbacks uses the same calling convention as exported functions.
Definition: TGM_CNC.h:1894
int32_t M09_coolOilOff
Definition: TGM_CNC.h:1554
20: Test is in progress
Definition: TGM_CNC.h:255
int32_t CALLBACK_CALLTYPE IsVerboseModeFunc(intptr_t dwUserData)
Ask if verbose regime is enabled.
Definition: TGM_CNC.h:1959
41: Movement to connection point is in progress
Definition: TGM_CNC.h:283
int32_t o_axis
Axis O.
Definition: TGM_CNC.h:770
double insertArcToleranceRMin
Definition: TGM_CNC.h:1613
#define START_CNC_TEST
Start CNC module in test mode (for the time being identical to simulation mode)
Definition: TGM_CNC.h:180
double minAngleFeed
Definition: TGM_CNC.h:1470
double m_actFeed
Current speed (m_calcFeed * m_relFeed)
Definition: TGM_CNC.h:459
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Load(const CNC_CALC_INIT_DATA *pInitData)
Plug-in DLL initialization.
P10DOUBLE m_cc
arc centre (m_cc.x m_cc.y m_cc.z) and radius (in m_cc.c variable), other m_cc variables not yet used ...
Definition: TGM_CNC.h:1020
0: Initial state, no G-code loaded
Definition: TGM_CNC.h:243
axis_idx
Axes numbers, together with special axis types. Assignment of the axes to array indexes is fixed...
Definition: TGM_CNC.h:412
Holds changed G-code parts.
Definition: TGM_CNC.h:3066
int32_t M87_mirrorXYZ
Definition: TGM_CNC.h:1584