emcops.cc
1 /******************************************************************** 2 * Description: emcops.cc 3 * Initialization and other ad hoc functions for NML. This complements 4 * the auto-generated emc.cc, which contains all the rote update 5 * methods for the message classes. 6 * 7 * Derived from a work by Fred Proctor & Will Shackleford 8 * 9 * Author: 10 * License: GPL Version 2 11 * System: Linux 12 * 13 * Copyright (c) 2004 All rights reserved. 14 * 15 * Last change: 16 ********************************************************************/ 17 18 #include "emc.hh" 19 #include "emc_nml.hh" 20 21 EMC_AXIS_STAT::EMC_AXIS_STAT(): 22 EMC_AXIS_STAT_MSG(EMC_AXIS_STAT_TYPE, sizeof(EMC_AXIS_STAT)) 23 { 24 } 25 26 EMC_JOINT_STAT::EMC_JOINT_STAT(): 27 EMC_JOINT_STAT_MSG(EMC_JOINT_STAT_TYPE, sizeof(EMC_JOINT_STAT)) 28 { 29 jointType = EMC_LINEAR; 30 units = 1.0; 31 backlash = 0.0; 32 minPositionLimit = -1.0; 33 maxPositionLimit = 1.0; 34 minFerror = 1.0; 35 maxFerror = 1.0; 36 ferrorCurrent = 0.0; 37 ferrorHighMark = 0.0; 38 output = 0.0; 39 input = 0.0; 40 velocity = 0.0; 41 inpos = 1; 42 homing = 0; 43 homed = 0; 44 enabled = 0; 45 fault = 0; 46 minSoftLimit = 0; 47 maxSoftLimit = 0; 48 minHardLimit = 0; 49 maxHardLimit = 0; 50 overrideLimits = 0; 51 } 52 53 EMC_TRAJ_STAT::EMC_TRAJ_STAT(): 54 EMC_TRAJ_STAT_MSG(EMC_TRAJ_STAT_TYPE, sizeof(EMC_TRAJ_STAT)) 55 { 56 linearUnits = 1.0; 57 angularUnits = 1.0; 58 cycleTime = 0.0; 59 joints = 1; 60 deprecated_axes = 1; 61 axis_mask = 1; 62 mode = EMC_TRAJ_MODE_FREE; 63 enabled = OFF; 64 inpos = ON; 65 queue = 0; 66 activeQueue = 0; 67 queueFull = OFF; 68 id = 0; 69 paused = OFF; 70 scale = 0.0; 71 rapid_scale = 0.0; 72 73 ZERO_EMC_POSE(position); 74 ZERO_EMC_POSE(actualPosition); 75 76 velocity = 1.0; 77 acceleration = 1.0; 78 maxVelocity = 1.0; 79 maxAcceleration = 1.0; 80 81 ZERO_EMC_POSE(probedPosition); 82 probe_tripped = OFF; 83 probing = OFF; 84 probeval = 0; 85 86 ZERO_EMC_POSE(dtg); 87 distance_to_go = 0.0; 88 kinematics_type = 0; 89 motion_type = 0; 90 current_vel = 0.0; 91 feed_override_enabled = OFF; 92 adaptive_feed_enabled = OFF; 93 feed_hold_enabled = OFF; 94 } 95 96 EMC_MOTION_STAT::EMC_MOTION_STAT(): 97 EMC_MOTION_STAT_MSG(EMC_MOTION_STAT_TYPE, sizeof(EMC_MOTION_STAT)) 98 { 99 int i; 100 101 for (i = 0; i < EMCMOT_MAX_DIO; i++) { 102 synch_di[i] = 0; 103 synch_do[i] = 0; 104 } 105 106 for (i = 0; i < EMCMOT_MAX_AIO; i++) { 107 analog_input[i] = 0.0; 108 analog_output[i] = 0.0; 109 } 110 111 debug = 0; 112 }; 113 114 EMC_TASK_STAT::EMC_TASK_STAT(): 115 EMC_TASK_STAT_MSG(EMC_TASK_STAT_TYPE, sizeof(EMC_TASK_STAT)) 116 { 117 int t; 118 119 mode = EMC_TASK_MODE_MANUAL; 120 state = EMC_TASK_STATE_ESTOP; 121 execState = EMC_TASK_EXEC_DONE; 122 interpState = EMC_TASK_INTERP_IDLE; 123 callLevel = 0; 124 motionLine = 0; 125 currentLine = 0; 126 readLine = 0; 127 optional_stop_state = OFF; 128 block_delete_state = OFF; 129 input_timeout = OFF; 130 file[0] = 0; 131 command[0] = 0; 132 133 ZERO_EMC_POSE(g5x_offset); 134 g5x_index = 0; 135 ZERO_EMC_POSE(g92_offset); 136 ZERO_EMC_POSE(toolOffset); 137 138 rotation_xy = 0.0; 139 140 for (t = 0; t < ACTIVE_G_CODES; t++) 141 activeGCodes[t] = -1; 142 for (t = 0; t < ACTIVE_M_CODES; t++) 143 activeMCodes[t] = -1; 144 for (t = 0; t < ACTIVE_SETTINGS; t++) 145 activeSettings[t] = 0.0; 146 147 programUnits = CANON_UNITS_MM; 148 interpreter_errcode = 0; 149 task_paused = 0; 150 delayLeft = 0.0; 151 queuedMDIcommands = 0; 152 } 153 154 EMC_TOOL_STAT::EMC_TOOL_STAT(): 155 EMC_TOOL_STAT_MSG(EMC_TOOL_STAT_TYPE, sizeof(EMC_TOOL_STAT)) 156 { 157 int t; 158 159 pocketPrepped = 0; 160 toolInSpindle = 0; 161 162 for (t = 0; t < CANON_POCKETS_MAX; t++) { 163 toolTable[t].toolno = 0; 164 toolTable[t].pocketno = 0; 165 ZERO_EMC_POSE(toolTable[t].offset); 166 toolTable[t].diameter = 0.0; 167 toolTable[t].orientation = 0; 168 toolTable[t].frontangle = 0.0; 169 toolTable[t].backangle = 0.0; 170 } 171 } 172 173 EMC_AUX_STAT::EMC_AUX_STAT(): 174 EMC_AUX_STAT_MSG(EMC_AUX_STAT_TYPE, sizeof(EMC_AUX_STAT)) 175 { 176 estop = 1; 177 } 178 179 EMC_SPINDLE_STAT::EMC_SPINDLE_STAT(): 180 EMC_SPINDLE_STAT_MSG(EMC_SPINDLE_STAT_TYPE, sizeof(EMC_SPINDLE_STAT)) 181 { 182 speed = 0.0; 183 direction = 0; 184 brake = 1; 185 increasing = 0; 186 enabled = 0; 187 spindle_scale = 1.0; 188 spindle_override_enabled = 0; 189 190 } 191 192 EMC_COOLANT_STAT::EMC_COOLANT_STAT():EMC_COOLANT_STAT_MSG(EMC_COOLANT_STAT_TYPE, 193 sizeof 194 (EMC_COOLANT_STAT)) 195 { 196 mist = 0; 197 flood = 0; 198 } 199 200 EMC_LUBE_STAT::EMC_LUBE_STAT(): 201 EMC_LUBE_STAT_MSG(EMC_LUBE_STAT_TYPE, sizeof(EMC_LUBE_STAT)) 202 { 203 on = 0; 204 level = 1; 205 } 206 207 // overload = , since class has array elements 208 EMC_TOOL_STAT EMC_TOOL_STAT::operator =(EMC_TOOL_STAT s) 209 { 210 int t; 211 212 pocketPrepped = s.pocketPrepped; 213 toolInSpindle = s.toolInSpindle; 214 215 for (t = 0; t < CANON_POCKETS_MAX; t++) { 216 toolTable[t].toolno = s.toolTable[t].toolno; 217 toolTable[t].pocketno = s.toolTable[t].pocketno; 218 toolTable[t].offset = s.toolTable[t].offset; 219 toolTable[t].diameter = s.toolTable[t].diameter; 220 toolTable[t].frontangle = s.toolTable[t].frontangle; 221 toolTable[t].backangle = s.toolTable[t].backangle; 222 toolTable[t].orientation = s.toolTable[t].orientation; 223 } 224 225 return s; 226 } 227 228 EMC_STAT::EMC_STAT():EMC_STAT_MSG(EMC_STAT_TYPE, sizeof(EMC_STAT)) 229 { 230 }