public void CopyState(PrintState cp) { this.comment = cp.comment; this.motion = cp.motion; this.working_plane = cp.working_plane; this.coordinates_mode = cp.coordinates_mode; this.position_coordinates_units = cp.position_coordinates_units; this.feed = cp.feed; this.feed_direction = cp.feed_direction; this.feed_acceleration = cp.feed_acceleration; this.feed_deceleration = cp.feed_deceleration; this.interpolation = cp.interpolation; this.position = (double[])cp.position.Clone(); this.feed_rate = cp.feed_rate; }
// Peek Line - Displays the line command without affecting the parser states // Not the cleanest way, but the quickest way to handle this is to store a shallow // copy of current states, parse line normally and then return the states back to // their original values public string PeekLine(int index) { PrintState ModalSafe = new PrintState(); PrintState CurrentSafe = new PrintState(); ModalSafe.CopyState(ModalState); CurrentSafe.CopyState(CurrentState); ParseSingleLine(index); string peek = understand; ModalState.CopyState(ModalSafe); CurrentState.CopyState(CurrentSafe); return(peek); }
public Parser() { //Decimal separator is the 'dot' System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; System.Globalization.CultureInfo.DefaultThreadCurrentCulture = customCulture; //GCode Lists FullGCode_ = new List <string>(); ParsedGCode_ = new List <string>(); StatisticsGCode_ = new Dictionary <int, List <double> >(); //Default printer states ModalState = new PrintState(); CurrentState = new PrintState(); //Unidirectional Binding of states: Modal -> Current ModalState.PrinterStateChanged += new PrintState.PrinterStateChangedHandler(CurrentState.PrinterState_PropertyChanged); //Default non-set parameters max_acc = MAX_ACC; //Maximum ramp acceleration m_accw = new double[] { 1.0, 1.0, 1.0 }; //Std acceleration weights m_accw_rapid = new double[] { 1.0, 1.0, 1.0 }; //Rapid acceleration weights //m_time_weights = new double[] { 1.0, 1.0, 1.0 }; //m_time_weights_rapid = new double[] { 1.0, 1.0, 1.0 }; //Only affect to the current command line //Velocity at index 1 is the current velocity //Velocities at indices 0 and 2 are different from index 1 only if there is a ramp //respectively before and after the current velocity. m_cmd_vel = new double[] { 0.0, 0.0, 0.0 }; m_desacelerate_next = false; m_ref_offset = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0 }; double hovel = 500 / 60; m_home_offset_vel = new double[] { 0, hovel, 0 }; //Parser pointer current_line = 0; }