Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void EvaluateWord()
- {
- int r = 0;
- mBlockAddresses[(int)mCurAddress.Letter] = true;
- switch (mCurAddress.Letter)
- {
- case letters.X:
- mBlockAddresses[(int)letters.ANY] = true;
- mXpos = FormatAxis(mCurAddress.StringValue, mCurMachine.Precision);
- break;
- case letters.Y:
- mBlockAddresses[(int)letters.ANY] = true;
- mYpos = FormatAxis(mCurAddress.StringValue, mCurMachine.Precision);
- break;
- case letters.Z:
- mBlockAddresses[(int)letters.ANY] = true;
- mZpos = FormatAxis(mCurAddress.StringValue, mCurMachine.Precision);
- break;
- case letters.I:
- mBlockAddresses[(int)letters.ANY] = true;
- mI = FormatAxis(mCurAddress.StringValue, mCurMachine.Precision);
- if (mCurMachine.MachineType == MachineType.LATHEDIA)
- {
- if (mCurMachine.AbsArcCenter)
- {
- mI = mI / 2;
- }
- }
- break;
- case letters.J:
- mBlockAddresses[(int)letters.ANY] = true;
- mJ = FormatAxis(mCurAddress.StringValue, mCurMachine.Precision);
- break;
- case letters.K:
- mBlockAddresses[(int)letters.ANY] = true;
- mK = FormatAxis(mCurAddress.StringValue, mCurMachine.Precision);
- break;
- case letters.R:
- mBlockAddresses[(int)letters.ANY] = true;
- mRpoint = FormatAxis(mCurAddress.StringValue, mCurMachine.Precision);
- mArcRad = mRpoint;
- break;
- case letters.S:
- mBlockAddresses[(int)letters.ANY] = true;
- mSpeed = mCurAddress.Value;
- break;
- case letters.F:
- mBlockAddresses[(int)letters.ANY] = true;
- mFeed = mCurAddress.Value;
- break;
- case letters.T:
- mBlockAddresses[(int)letters.ANY] = true;
- mTool = mCurAddress.Value;
- break;
- default:
- if (mBlockAddresses[(int)mMotion.Rotary.Letter] == true)
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mABC = FormatAxis(mCurAddress.StringValue, mCurMachine.RotPrecision) * 0.01745329f;
- //Convert to radians
- //check for -0
- if (mCurAddress.StringValue.StartsWith("-"))
- {
- mRotDir = -1;
- //CCW
- }
- break;
- }
- //Absolute positioning
- if (mCurAddress.Matches(mMotion.Abs))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mAbsolute = true;
- }
- //Incremental positioning
- else if (mCurAddress.Matches(mMotion.Inc))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mAbsolute = false;
- }
- else if (mCurAddress.Matches(mMotion.Rapid))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mMode = Motion.RAPID;
- }
- else if (mCurAddress.Matches(mMotion.Linear))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mMode = Motion.LINE;
- }
- //Arc clockwise
- else if (mCurAddress.Matches(mMotion.CWArc))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- if (mPlane == Motion.XZ_PLN)
- {
- mMode = Motion.CCARC;
- }
- else
- {
- mMode = Motion.CWARC;
- }
- }
- //Arc anti-clockwise
- else if (mCurAddress.Matches(mMotion.CCArc))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- if (mPlane == Motion.XZ_PLN)
- {
- mMode = Motion.CWARC;
- }
- else
- {
- mMode = Motion.CCARC;
- }
- }
- //Drill cancel found
- else if (mCurAddress.Matches(mMotion.Drills[0]))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mMode = Motion.RAPID;
- if (mDrillReturnMode == Motion.I_PLN)
- {
- mZpos = mInitialZBeforeDrill;
- }
- else
- {
- mZpos = mRpoint;
- }
- }
- else if (mCurAddress.Matches(mMotion.ReturnLevel[0]))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mDrillReturnMode = Motion.I_PLN;
- if (mMode > Motion.CCARC)
- {
- mMode = (Motion)((int)Motion.HOLE_I + mDrillReturnMode);
- }
- }
- else if (mCurAddress.Matches(mMotion.ReturnLevel[1]))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mDrillReturnMode = Motion.R_PLN;
- if (mMode > Motion.CCARC)
- {
- mMode = (Motion)((int)Motion.HOLE_I + mDrillReturnMode);
- }
- }
- //Plane Change G17
- else if (mCurAddress.Matches(mMotion.Plane[0]))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mPlane = Motion.XY_PLN;
- }
- //Plane Change G18
- else if (mCurAddress.Matches(mMotion.Plane[1]))
- {
- mBlockAddresses[(int)letters.ANY] = true;
- mPlane = Motion.XZ_PLN;
- }
- //Plane Change G19
- else if (mCurAddress.Matches(mMotion.Plane[2]))
- {
- mPlane = Motion.YZ_PLN;
- mBlockAddresses[(int)letters.ANY] = true;
- }
- else
- {
- //Cycle through all 10 drilling cycles
- for (r = 1; r <= mMotion.Drills.Length - 1; r++)
- {
- //NOT an empty field
- if (mMotion.Drills[r].Value != 0.0f)
- {
- if (mCurAddress.Matches(mMotion.Drills[r]))
- {
- mMode = (Motion)((int)Motion.HOLE_I + mDrillReturnMode);
- //Drill cycle found
- if (mMode == Motion.HOLE_I)
- {
- mDrillClear = mInitialZBeforeDrill;
- }
- if (mMode == Motion.HOLE_R)
- {
- mDrillClear = mRpoint;
- }
- mBlockAddresses[(int)letters.ANY] = true;
- break; // TODO: might not be correct. Was : Exit For
- }
- }
- }
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement