00001 /* 00002 emcops.cc 00003 00004 Initialization and other ad hoc functions for NML. This complements the 00005 auto-generated emc.cc, which contains all the rote update methods for 00006 the message classes. 00007 00008 Modification history: 00009 00010 31-Jan-1999 FMP added backlash, bias, maxError to EMC_AXIS_STAT 00011 7-Oct-1998 FMP added init of homingVel to EMC_AXIS_STAT ctor 00012 2-Sep-1998 FMP added min/maxSoft/HardLimit inits to EMC_AXIS_STAT ctor 00013 3-Aug-1998 FMP added toolOffset, G/M codes init to 0 00014 8-Jul-1998 FMP added logPoints to status 00015 15-Jun-1998 FMP added this comment, since it was left out. Also added 00016 scale initialization to EMC_AXIS_STAT ctor; EMC_STAT ctor with logging 00017 init 00018 */ 00019 00020 #include "emc.hh" 00021 00022 EMC_AXIS_STAT::EMC_AXIS_STAT() : 00023 EMC_AXIS_STAT_MSG(EMC_AXIS_STAT_TYPE, sizeof(EMC_AXIS_STAT)) 00024 { 00025 axisType = EMC_AXIS_LINEAR; 00026 units = 1.0; 00027 p = 0.0; 00028 i = 0.0; 00029 d = 0.0; 00030 ff0 = 0.0; 00031 ff1 = 0.0; 00032 ff2 = 0.0; 00033 backlash = 0.0; 00034 bias = 0.0; 00035 maxError = 0.0; 00036 cycleTime = 1.0; 00037 inputScale = 1.0; 00038 inputOffset = 0.0; 00039 outputScale = 1.0; 00040 outputOffset = 0.0; 00041 minPositionLimit = -1.0; 00042 maxPositionLimit = 1.0; 00043 minOutputLimit = -1.0; 00044 maxOutputLimit = 1.0; 00045 maxFerror = 1.0; 00046 homingVel = 1.0; 00047 enablePolarity = 1; 00048 minLimitSwitchPolarity = 1; 00049 maxLimitSwitchPolarity = 1; 00050 homeSwitchPolarity = 1; 00051 homingPolarity = 1; 00052 faultPolarity = 1; 00053 ferrorCurrent = 0.0; 00054 ferrorHighMark = 0.0; 00055 output = 0.0; 00056 input = 0.0; 00057 inpos = 1; 00058 homing = 0; 00059 homed = 0; 00060 enabled = 0; 00061 minSoftLimit = 0; 00062 maxSoftLimit = 0; 00063 minHardLimit = 0; 00064 maxHardLimit = 0; 00065 scale = 0.0; 00066 } 00067 00068 EMC_TRAJ_STAT::EMC_TRAJ_STAT() : 00069 EMC_TRAJ_STAT_MSG(EMC_TRAJ_STAT_TYPE, sizeof(EMC_TRAJ_STAT)) 00070 { 00071 linearUnits = 1.0; 00072 angularUnits = 1.0; 00073 axes = 1; 00074 mode = EMC_TRAJ_MODE_FREE; 00075 enabled = 0; 00076 inpos = 1; 00077 queue = 0; 00078 activeQueue = 0; 00079 queueFull = 0; 00080 id = 0; 00081 paused = 0; 00082 00083 position.tran.x = 0.0; 00084 position.tran.y = 0.0; 00085 position.tran.z = 0.0; 00086 position.a = 0.0; 00087 position.b = 0.0; 00088 position.c = 0.0; 00089 00090 actualPosition.tran.x = 0.0; 00091 actualPosition.tran.y = 0.0; 00092 actualPosition.tran.z = 0.0; 00093 actualPosition.a = 0.0; 00094 actualPosition.b = 0.0; 00095 actualPosition.c = 0.0; 00096 00097 velocity = 1.0; 00098 acceleration = 1.0; 00099 maxVelocity = 1.0; 00100 maxAcceleration = 1.0; 00101 } 00102 00103 EMC_TASK_STAT::EMC_TASK_STAT() : 00104 EMC_TASK_STAT_MSG(EMC_TASK_STAT_TYPE, sizeof(EMC_TASK_STAT)) 00105 { 00106 int t; 00107 00108 mode = EMC_TASK_MODE_MANUAL; 00109 state = EMC_TASK_STATE_ESTOP; 00110 execState = EMC_TASK_EXEC_DONE; 00111 interpState = EMC_TASK_INTERP_IDLE; 00112 motionLine = 0; 00113 currentLine = 0; 00114 readLine = 0; 00115 file[0] = 0; 00116 command[0] = 0; 00117 00118 origin.tran.x = 0.0; 00119 origin.tran.y = 0.0; 00120 origin.tran.z = 0.0; 00121 origin.a = 0.0; 00122 origin.b = 0.0; 00123 origin.c = 0.0; 00124 00125 toolOffset.tran.x = 0.0; 00126 toolOffset.tran.y = 0.0; 00127 toolOffset.tran.z = 0.0; 00128 toolOffset.a = 0.0; 00129 toolOffset.b = 0.0; 00130 toolOffset.c = 0.0; 00131 00132 for (t = 0; t < EMC_TASK_ACTIVE_G_CODES; t++) 00133 activeGCodes[t] = -1; 00134 for (t = 0; t < EMC_TASK_ACTIVE_M_CODES; t++) 00135 activeMCodes[t] = -1; 00136 for (t = 0; t < EMC_TASK_ACTIVE_SETTINGS; t++) 00137 activeSettings[t] = 0.0; 00138 } 00139 00140 EMC_TOOL_STAT::EMC_TOOL_STAT() : 00141 EMC_TOOL_STAT_MSG(EMC_TOOL_STAT_TYPE, sizeof(EMC_TOOL_STAT)) 00142 { 00143 int t; 00144 00145 toolPrepped = 0; 00146 toolInSpindle = 0; 00147 00148 for (t = 0; t <= CANON_TOOL_MAX; t++) 00149 { 00150 toolTable[t].id = 0; 00151 toolTable[t].length = 0.0; 00152 toolTable[t].diameter = 0.0; 00153 } 00154 } 00155 00156 EMC_AUX_STAT::EMC_AUX_STAT() : 00157 EMC_AUX_STAT_MSG(EMC_AUX_STAT_TYPE, sizeof(EMC_AUX_STAT)) 00158 { 00159 int t; 00160 00161 estop = 1; 00162 00163 for (t = 0; t < EMC_AUX_MAX_DOUT; t++) 00164 { 00165 dout[t] = 0; 00166 } 00167 00168 for (t = 0; t < EMC_AUX_MAX_DIN; t++) 00169 { 00170 din[t] = 0; 00171 } 00172 00173 for (t = 0; t < EMC_AUX_MAX_AOUT; t++) 00174 { 00175 aout[t] = 0; 00176 } 00177 00178 for (t = 0; t < EMC_AUX_MAX_AIN; t++) 00179 { 00180 ain[t] = 0; 00181 } 00182 } 00183 00184 EMC_SPINDLE_STAT::EMC_SPINDLE_STAT() : 00185 EMC_SPINDLE_STAT_MSG(EMC_SPINDLE_STAT_TYPE, sizeof(EMC_SPINDLE_STAT)) 00186 { 00187 speed = 0.0; 00188 direction = 0; 00189 brake = 1; 00190 increasing = 0; 00191 enabled = 0; 00192 } 00193 00194 EMC_COOLANT_STAT::EMC_COOLANT_STAT() : EMC_COOLANT_STAT_MSG(EMC_COOLANT_STAT_TYPE, sizeof(EMC_COOLANT_STAT)) 00195 { 00196 mist = 0; 00197 flood = 0; 00198 } 00199 00200 EMC_LUBE_STAT::EMC_LUBE_STAT() : 00201 EMC_LUBE_STAT_MSG(EMC_LUBE_STAT_TYPE, sizeof(EMC_LUBE_STAT)) 00202 { 00203 on = 0; 00204 level = 1; 00205 } 00206 00207 // overload = , since class has array elements 00208 EMC_TOOL_STAT EMC_TOOL_STAT::operator = (EMC_TOOL_STAT s) 00209 { 00210 int t; 00211 00212 toolPrepped = s.toolPrepped; 00213 toolInSpindle = s.toolInSpindle; 00214 00215 for (t = 0; t <= CANON_TOOL_MAX; t++) 00216 { 00217 toolTable[t].id = s.toolTable[t].id; 00218 toolTable[t].length = s.toolTable[t].length; 00219 toolTable[t].diameter = s.toolTable[t].diameter; 00220 } 00221 00222 return s; 00223 } 00224 00225 // overload = , since class has array elements 00226 EMC_AUX_STAT EMC_AUX_STAT::operator = (EMC_AUX_STAT s) 00227 { 00228 int t; 00229 00230 estop = s.estop; 00231 00232 for (t = 0; t < EMC_AUX_MAX_DOUT; t++) 00233 { 00234 dout[t] = s.dout[t]; 00235 } 00236 00237 for (t = 0; t < EMC_AUX_MAX_DIN; t++) 00238 { 00239 din[t] = s.din[t]; 00240 } 00241 00242 for (t = 0; t < EMC_AUX_MAX_AOUT; t++) 00243 { 00244 aout[t] = s.aout[t]; 00245 } 00246 00247 for (t = 0; t < EMC_AUX_MAX_AIN; t++) 00248 { 00249 ain[t] = s.ain[t]; 00250 } 00251 00252 return s; 00253 } 00254 00255 EMC_STAT::EMC_STAT() : EMC_STAT_MSG(EMC_STAT_TYPE, sizeof(EMC_STAT)) 00256 { 00257 logFile[0] = 0; 00258 logType = 0; 00259 logSize = 0; 00260 logSkip = 0; 00261 logOpen = 0; 00262 logStarted = 0; 00263 logPoints = 0; 00264 }