private void TriggerEnterSequence() { for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { if (mf.seq.seqEnter[i].function != 0) { mf.DoYouTurnSequenceEvent(mf.seq.seqEnter[i].function, mf.seq.seqEnter[i].action); } } }
//determine when if and how functions are triggered public void DoSequenceEvent() { if (mf.yt.isSequenceTriggered) { //determine if Section is entry or exit based on trigger point direction bool isToolHeadingSameAsABHeading; //Subtract the two headings, if > 1.57 its going the opposite heading as refAB #pragma warning disable CS1690 // Accessing a member on a field of a marshal-by-reference class may cause a runtime exception double abFixHeadingDelta = (Math.Abs(mf.toolPos.heading - mf.ABLine.abHeading)); if (abFixHeadingDelta >= Math.PI) { abFixHeadingDelta = Math.Abs(abFixHeadingDelta - glm.twoPI); } isToolHeadingSameAsABHeading = (abFixHeadingDelta <= glm.PIBy2); mf.hl.FindClosestHeadlandPoint(mf.toolPos); if ((int)mf.hl.closestHeadlandPt.easting != -1) { mf.distTool = glm.Distance(mf.toolPos, mf.hl.closestHeadlandPt); #pragma warning restore CS1690 // Accessing a member on a field of a marshal-by-reference class may cause a runtime exception } else //we've lost the headland { mf.yt.isSequenceTriggered = false; mf.yt.ResetSequenceEventTriggers(); mf.distTool = 999; return; } if (isABLineSameAsHeadingAtTrigger == isToolHeadingSameAsABHeading) { //since same as AB Line, we are entering whereAmI = 1; if (isInHeadland) { mf.distTool *= -1; } } else { //since opposite of AB Line at trigger we are exiting whereAmI = 2; if (isInHeadland) { mf.distTool *= -1; } } //did we do all the events? int c = 0; for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //checked for any not triggered yet (false) - if there is, not done yet if (!mf.seq.seqEnter[i].isTrig) { c++; } if (!mf.seq.seqExit[i].isTrig) { c++; } } if (c == 0) { //sequences all done so reset everything isSequenceTriggered = false; whereAmI = 0; ResetSequenceEventTriggers(); } switch (whereAmI) { case 0: //not in you turn break; case 1: //Entering the headland for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //have we gone past the distance and still haven't done it if (mf.distTool < mf.seq.seqEnter[i].distance && !mf.seq.seqEnter[i].isTrig) { //it shall only run once mf.seq.seqEnter[i].isTrig = true; //send the function and action to perform mf.DoYouTurnSequenceEvent(mf.seq.seqEnter[i].function, mf.seq.seqEnter[i].action); } } break; case 2: //Leaving the headland for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //have we gone past the distance and still haven't done it if (mf.distTool > mf.seq.seqExit[i].distance && !mf.seq.seqExit[i].isTrig) { //it shall only run once mf.seq.seqExit[i].isTrig = true; //send the function and action to perform mf.DoYouTurnSequenceEvent(mf.seq.seqExit[i].function, mf.seq.seqExit[i].action); } } break; } } }
//figure out where we are //yt.isInBoundz = boundz.IsPointInsideBoundary(toolPos); //yt.isInWorkArea = hlArr[0].IsPointInsideHeadland(toolPos); //Are we in the outside headland? //if (!yt.isInWorkArea) //{ // yt.isInHeadland = true; //} //else //{ // yt.isInHeadland = false; // bool isInInnerHeadland = false; // for (int i = 1; i < FormGPS.MAXHEADS; i++) // { // isInInnerHeadland = hlArr[i].IsPointInsideHeadland(toolPos); // if (isInInnerHeadland) // { // yt.isInHeadland = true; // break; // } // } //} //determine when if and how functions are triggered for drive thru //public void DoDriveThruSequenceEvent() //{ // //determine if Section is entry or exit based on trigger point direction // //bool isToolHeadingSameAsABHeading; // ////Subtract the two headings, if > 1.57 its going the opposite heading as refAB // //double headAB; // //if (mf.ABLine.isABLineSet) // //{ // // double abFixHeadingDelta = (Math.Abs(mf.toolPos.heading - mf.ABLine.abHeading)); // // if (abFixHeadingDelta >= Math.PI) abFixHeadingDelta = Math.Abs(abFixHeadingDelta - glm.twoPI); // // isToolHeadingSameAsABHeading = (abFixHeadingDelta <= glm.PIBy2); // // headAB = mf.ABLine.abHeading; // //} // //else //AB Curve // //{ // // //Subtract the two headings, if > 1.57 its going the opposite heading as refAB // // double abFixHeadingDelta = (Math.Abs(mf.toolPos.heading - mf.curve.refHeading)); // // if (abFixHeadingDelta >= Math.PI) abFixHeadingDelta = Math.Abs(abFixHeadingDelta - glm.twoPI); // // isToolHeadingSameAsABHeading = (abFixHeadingDelta <= glm.PIBy2); // // headAB = mf.curve.refHeading; // //} // //if (!isToolHeadingSameAsABHeading) headAB += Math.PI; // //#pragma warning disable CS1690 // Accessing a member on a field of a marshal-by-reference class may cause a runtime exception // // mf.hl.FindClosestHeadlandPoint(mf.toolPos, mf.toolPos.heading); // // if ((int)mf.hl.closestHeadlandPt.easting != -20000) // // { // // mf.distTool = glm.Distance(mf.toolPos, mf.hl.closestHeadlandPt); // // } // // else //we've lost the headland // // { // // isEnteringDriveThru = false; // // isExitingDriveThru = false; // // ResetSequenceEventTriggers(); // // mf.distTool = -3333; // // return; // // } // //#pragma warning restore CS1690 // Accessing a member on a field of a marshal-by-reference class may cause a runtime exception // // //make distance sign correct // // if (isInHeadland) mf.distTool *= -1; // // mf.distTool += (mf.headlandDistanceDelta * 0.5); // // //we are entering // // if (isEnteringDriveThru) whereAmI = 1; // // //we are exiting // // else whereAmI = 2; // // //did we do all the events? // // int c = 0; // // for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) // // { // // //checked for any not triggered yet (false) - if there is, not done yet // // if (!mf.seq.seqEnter[i].isTrig) c++; // // if (!mf.seq.seqExit[i].isTrig) c++; // // } // // if (c == 0) // // { // // //sequences all done so reset everything // // isEnteringDriveThru = false; // // isExitingDriveThru = false; // // whereAmI = 0; // // ResetSequenceEventTriggers(); // // mf.distTool = -2222; // // } // // switch (whereAmI) // // { // // case 0: //not in you turn // // break; // // case 1: //Entering the headland // // for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) // // { // // //have we gone past the distance and still haven't done it // // if (mf.distTool < mf.seq.seqEnter[i].distance && !mf.seq.seqEnter[i].isTrig) // // { // // //it shall only run once // // mf.seq.seqEnter[i].isTrig = true; // // //send the function and action to perform // // mf.DoYouTurnSequenceEvent(mf.seq.seqEnter[i].function, mf.seq.seqEnter[i].action); // // } // // } // // break; // // case 2: //Exiting the headland // // for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) // // { // // //have we gone past the distance and still haven't done it // // if (mf.distTool > mf.seq.seqExit[i].distance && !mf.seq.seqExit[i].isTrig) // // { // // //it shall only run once // // mf.seq.seqExit[i].isTrig = true; // // //send the function and action to perform // // mf.DoYouTurnSequenceEvent(mf.seq.seqExit[i].function, mf.seq.seqExit[i].action); // // } // // } // // break; // // } //} //determine when if and how functions are triggered public void DoSequenceEvent() { if (isSequenceTriggered) { //determine if Section is entry or exit based on trigger point direction //bool isToolHeadingSameAsABHeading; #pragma warning disable CS1690 // Accessing a member on a field of a marshal-by-reference class may cause a runtime exception if (mf.yt.onA <= 0) { whereAmI = 1; mf.yt.onA = -mf.yt.onA; } else { whereAmI = 2; } int c = 0; for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //checked for any not triggered yet (false) - if there is, not done yet if (!mf.seq.seqEnter[i].isTrig) { c++; } if (!mf.seq.seqExit[i].isTrig) { c++; } } if (c == 0) { //sequences all done so reset everything and leave isSequenceTriggered = false; whereAmI = 0; ResetSequenceEventTriggers(); mf.distanceToolToTurnLine = -2222; isSequenceTriggered = false; return; } switch (whereAmI) { case 0: //not in you turn break; case 1: //Entering the headland for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //have we gone past the distance and still haven't done it if (mf.yt.onA >= mf.seq.seqEnter[i].distance && !mf.seq.seqEnter[i].isTrig) { //it shall only run once mf.seq.seqEnter[i].isTrig = true; //send the function and action to perform mf.DoYouTurnSequenceEvent(mf.seq.seqEnter[i].function, mf.seq.seqEnter[i].action); } } break; case 2: //Exiting the headland for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //have we gone past the distance and still haven't done it if (mf.yt.onA <= mf.seq.seqExit[i].distance && !mf.seq.seqExit[i].isTrig) { //it shall only run once mf.seq.seqExit[i].isTrig = true; //send the function and action to perform mf.DoYouTurnSequenceEvent(mf.seq.seqExit[i].function, mf.seq.seqExit[i].action); } } break; } } }
//determine when if and how functions are triggered public void DoSequenceEvent() { if (isSequenceTriggered) { //determine if Section is entry or exit based on trigger point direction bool isToolHeadingSameAsABHeading; #pragma warning disable CS1690 // Accessing a member on a field of a marshal-by-reference class may cause a runtime exception //Subtract the two headings, if > 1.57 its going the opposite heading as refAB double headAB; if (mf.ABLine.isABLineSet) { double abFixHeadingDelta = (Math.Abs(mf.toolPos.heading - mf.ABLine.abHeading)); if (abFixHeadingDelta >= Math.PI) { abFixHeadingDelta = Math.Abs(abFixHeadingDelta - glm.twoPI); } isToolHeadingSameAsABHeading = (abFixHeadingDelta <= glm.PIBy2); headAB = mf.ABLine.abHeading; } else //AB Curve { //Subtract the two headings, if > 1.57 its going the opposite heading as refAB double abFixHeadingDelta = (Math.Abs(mf.toolPos.heading - mf.curve.refHeading)); if (abFixHeadingDelta >= Math.PI) { abFixHeadingDelta = Math.Abs(abFixHeadingDelta - glm.twoPI); } isToolHeadingSameAsABHeading = (abFixHeadingDelta <= glm.PIBy2); headAB = mf.curve.refHeading; } // if (!isToolHeadingSameAsABHeading) headAB += Math.PI; // mf.hl.FindClosestHeadlandPoint(mf.toolPos, headAB, 0); //************ TODO fix bndNum **************88 // if ((int)mf.hl.closestHeadlandPt.easting != -20000) // { // mf.distTool = glm.Distance(mf.toolPos, mf.hl.closestHeadlandPt); //#pragma warning restore CS1690 // Accessing a member on a field of a marshal-by-reference class may cause a runtime exception // } // else //we've lost the headland // { // isSequenceTriggered = false; // ResetSequenceEventTriggers(); // mf.distTool = -3333; // return; // } //make distance sign correct if (isInHeadland) { mf.distanceToolToTurnLine *= -1; } mf.distanceToolToTurnLine += (mf.headlandDistanceDelta * 0.5); //since same as AB Line, we are entering if (isABLineSameAsHeadingAtTrigger == isToolHeadingSameAsABHeading) { whereAmI = 1; } //since opposite of AB Line at trigger we are exiting else { whereAmI = 2; } //did we do all the events? int c = 0; for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //checked for any not triggered yet (false) - if there is, not done yet if (!mf.seq.seqEnter[i].isTrig) { c++; } if (!mf.seq.seqExit[i].isTrig) { c++; } } if (c == 0) { //sequences all done so reset everything isSequenceTriggered = false; whereAmI = 0; ResetSequenceEventTriggers(); mf.distanceToolToTurnLine = -2222; } switch (whereAmI) { case 0: //not in you turn break; case 1: //Entering the headland for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //have we gone past the distance and still haven't done it if (mf.distanceToolToTurnLine < mf.seq.seqEnter[i].distance && !mf.seq.seqEnter[i].isTrig) { //it shall only run once mf.seq.seqEnter[i].isTrig = true; //send the function and action to perform mf.DoYouTurnSequenceEvent(mf.seq.seqEnter[i].function, mf.seq.seqEnter[i].action); } } break; case 2: //Exiting the headland for (int i = 0; i < FormGPS.MAXFUNCTIONS; i++) { //have we gone past the distance and still haven't done it if (mf.distanceToolToTurnLine > mf.seq.seqExit[i].distance && !mf.seq.seqExit[i].isTrig) { //it shall only run once mf.seq.seqExit[i].isTrig = true; //send the function and action to perform mf.DoYouTurnSequenceEvent(mf.seq.seqExit[i].function, mf.seq.seqExit[i].action); } } break; } } }