Writing Custom Setup Rules
To determine whether a setup is necessary, you can write a function, ucwtsr, that the Scheduler uses when the Setup Rule on an operation is set to a user-defined setup rule (rule positions 3-39).
Naming the Function
Your custom function can have any name that is not a standard user-callable function name.
Arguments
Summary
#include "factor.h" int ucwtsr (ldp, type, rp, jsp, rule) LOAD *ldp; /* pointer to the load. */ TCHAR type; /* 'R' (resource) */ void *rp; /* pointer to the resource to setup. */ JOBSTEP *jsp; /* pointer to the operation. */ int rule; /* setup rule to use. */
Function ucwtsr must accept five arguments in the following order:
- A pointer to a load (Type: LOAD*).
- Type of resource ("R"esource) (Type: char).
- A pointer to a resource (Type: void*).
- A pointer to an operation (Type: JOBSTEP*).
- Setup rule (Type: int).
Return Values
The function should return 1 for success (setup should be done) and 0 for failure (setup should not be done). Type: int.
The following example of ucwtsr sets up a resource every time the part and/or operation changes for the resources.
int ucwtsr(LOAD *ldp, TCHAR type, void *rp, JOBSTEP *jsp, int rule)
/*-----------------------------------------------------------------
Function to set up a resource if the item or operation is
different from last setup
ARGS:
ldp - pointer to load
type - "R"esource
rp - pointer to resource
jsp - pointer to operation
rule - Setup rule
RETURNS
true - perform setup, or
false - do not perform setup
-----------------------------------------------------------------*/
{
int ireturn = 0
char error[400];
/* Check if setup or setup/operate or super operation. */
if ( (jsp->jstype != 4) && (jsp->jstype != 13) )&&
(jsp->jstype != 19) )
{
sprintf(error,"Operation not a Setup or Setup/Operate or Super
operation\n\nOrder ID %s\nLoad ID %d\nBatch ID
%ld\nOperation ID %s\nOperation Type %d\n",
ldp->loordp->orid, ldp->loid, (ldp->lobat == NULL)
? OL : ldp->lobat->bibatid, jsp->jsid, jsp->jstype);
seferr(0, error);
}
if (type == 'R')
{
ireturn = (((RESRC *)rp)->rsptst != ldp->loordp->orptpt
|| ((RESRC *)rp)->rsjsst != jsp) ? 1 : 0;
}
else
{
ireturn = (((MCRMEMBER *)rp)->mbrptst != ldp->loordp->orptpt
|| ((MCRMEMBER *) rp)->mbrjsst != jsp) ? 1 : 0;
}
return (ireturn);
}
Installing the Custom Function
It is not necessary to install ucwtsr in ucini1 because it is called automatically when the setup rule is greater than 2 (that is, a non-standard rule number).