Preactor General API Hints

If there are better ways of achieving the same outcome please leave a comment at the bottom of the page.

OnStartDrag, OnDrag, OnDrop, AfterDrag

Difference between OnDrop and AfterDrop

OnDrop: the operation is about to be dropped on the OPB. The "Operation Times" for the operation are reset to its about to be dropped location, but will not bump or change other operations on the resource.

AfterDrop: The operation has been dropped on the OPB, and may have bumped or changed other operations on the same resource.

Cancel a StartDrag event on an operation

You can prevent an operation from being dragged by issuing the following command in the OnStartDrag() method:

pespComObject.set_CustomCheckReturnValue((int)PreactorCheckReturnValues.PrCheckFail);

Code Example:

public int OnStartDrag(ref PreactorObj preactorComObject, ref Core pespComObject) { pespComObject.set_CustomCheckReturnValue((int)PreactorCheckReturnValues.PrCheckFail); return 0; }

Obviously you can check for certain conditions before issuing the command.

Revert an OnDrop event on an operation

UPDATE: A better way of doing this is to issue a ReturnFail (pespComObject.set_CustomCheckReturnValue((int)PreactorCheckReturnValues.PrCheckFail)) on the AfterDrop event. This will cancel the dragging operation and revert back to how the board was before dragging. What follow below is left for reference purposes. (i.e. there is no need now to save and restore the schedule state in order to cancel a dragging operation.)

-----------

If you want to revert the dragging of an operation after dropping it you must first save the state of the planning board at the StartDrag event.

public int OnStartDrag(ref PreactorObj preactorComObject, ref Core pespComObject) { Pom.LoadPreactorObject(preactorComObject); Pom.Preactor.PlanningBoard.SaveScheduleState(1); return 0; }

public int OnDrop(ref PreactorObj preactorComObject, ref Core pespComObject) { Pom.LoadPreactorObject(preactorComObject); Pom.Preactor.PlanningBoard.RestoreScheduleState(1); return 0; }

NOTE: If you issue a pespComObject.set_CustomCheckReturnValue((int)PreactorCheckReturnValues.PrCheckFail) in the OnDrop event preactor will not let you drop an operation at all... (i.e. the operation will stay stuck to your mouse pointer, which is not the desired effect.)

NOTE: If the user has a Network license setup you have to be carful with using SaveScheduleState() and RestoreScheduleState() as the state file is transferred over the network. To avoid this you will need to change the Environment.CurrentDirectory before saving or restoring the state:

string CurrentPath = Environment.CurrentDirectory; string TempPath = preactor.ParseShellString("{TEMP PATH}");

// Change Current Directory Environment.CurrentDirectory = TempPath; PlanningBoard.SaveScheduleState(1); Environment.CurrentDirectory = CurrentPath;

Will need to do the same when RestoreScheduleState()

OnDrop Hints

Don't try and Redraw() the OPB in the OnDrop method as it can cause Preactor to act strange in some corner cases.

TestOperationOnResource()

Determines an operations set-up time and processing times given an earliest start time.

Remarks:

Tests an Operation on a Resource and returns information on the time at which the operation would start set-up, start processing and end processing. This routine takes into account operations on the resource, secondary resources and shift patterns. If the ChangeStart parameter returned is not the same as the Time parameter passed then the job could not be placed on the resource at the given time. If any LOCAL ASSIGNMENT fields are set, then they will remain set. Previously, because the method replaced the operation in the unallocated job list, these fields were set back to Unspecified.

Things to check if TestOpOnResource() returns null or a different time to that specified:

  • CanResourceProcessOperation() check the specified resource can indeed process the operation
  • IsResourceFree() at the time specified
  • Check specified start time is greater than the EarliestStartTime of the operation.
  • The previous operation is not finished yet. (QueryOperationOnResource() will ignore dependent operations, or GetPreviousOperation() and see whether it is scheduled, or whether it has finished yet.)
  • If the Batch method is set to transfer, Preactor will not check if the previous operation is completed.
  • Operation is on an off shift and setup is not allowed
  • The secondary constraints are violated. Will need the secondary constraints the operation is associated with. This can be obtained by looping through the SecondaryConstraints filed matrix. (If the matrix is not empty then disable secondary constraints, and see if we get the same result or not. )
  • Operation might take too long to complete and there is not enough time in a shift to complete it. (Can't think of an easy way to do this. Would have to find all available on shift gap durations and see if the opartion can fit in any of them.)
  • SlackTime after last lot. (GetPreviousOperation() and see if it has a slacktime.)

You can still find out the process time and setup time by using the GetProcessTime() and GetSetupTime() respectively, to find out the Total Process time for the operation at the given point in time for a given resource.

Material Control

When using material control you have to peg orders before an operation can be put on the board. To simulate an order has been pegged the "Material Control Complete" field has to be set to "yes".

op.MaterialControlComplete = true;

Changing the Start time or End Time of an operation.

The "start time" and "end time" of an operation cannot be changed manually using the WriteField() method, if the USE ACTUAL TIMES is set to false.

The operation times (setup start time, start time and end time) are only set once an operation has been put on the scheduling board (whether by drag and drop or using the scheduler).

The only way to change the start time is to use the PutOperationOnResource(), or SequenceOperation() methods.

The API documentation states: "The PutOpOnResource() method is the equivalent of picking up an operation with the mouse and dropping it on a resource."

In order to change the "End Time" of an operation, you have to change the duration of the operation (i.e the field with a PROCESS TIME classification.). Again this cannot be done directly as the PROCESS TIME field gets its value from either of 3 fields with classifications TIME PER ITEM, TIME PER BATCH, RATES PER HOUR.

After changing the values of one of the TIME PER BATCH, TIME PER ITEM or RATES PER HOUR fields, the EvaluateRecord() method needs to be called to re-evaluate the other fields dependent on these values, namely fields with the following classifications: TOTAL PROCESS TIME, PROCESS TIME etc...

Then the Operation times need to be recalculated as well. RecalculateOperationTimes() (NOTE: RecalculateOpertionTimes(ResourceRecord) Will recalculate the operation times for all operations on a resource and can become very slow if there are many operations on the resource. At this point it is better to unschedule and reschedule the operation.)

The same applies to changing the "start time" as opposed to the "setup start time". You can’t change these values manually. Instead the value of the field with a SEQ SETUP classification needs to be changed.

When trying to change the operation times of an operation that is already scheduled, make sure to unscheduled it first, to avoid conflicts with secondary constraints etc...

Last edited Feb 7, 2013 at 10:19 PM by bvsms, version 4

Comments

No comments yet.