# GracoPd2kDual API

## Functions (FC)

### GetDataBySlotNum

Read data from the specified Profinet device number(defined in target parameter) and a slot number. This FC uses the GEO2LOG and RD_ADDR built-in functions internally to lookup the process data address. The status codes from those functions are forwarded through the return value of this function.

cgmNum (INPUT UInt)

  CGM number (1 or 2)

pnSlotNum (INPUT UInt)

  Profinet slot number

target (INOUT TypeTarget)

  target to operate on

data (OUTPUT DWord)

  Current process data

#### State codes

- 16#8000 - Error - invalid CGM number

RETURN (`GracoCore_TypeFunctionCmdState`_)

### SetDataBySlotNum

Writes data to a specified Profinet device number (defined in target parameter) and a slot number. This FC uses the GEO2LOG and RD_ADDR built-in functions internally to lookup the process data address. The status codes from those functions are forwarded through the return value of this function.

cgmNum (INPUT UInt)

  CGM number (1 or 2)

pnSlotNum (INPUT UInt)

  Profinet slot number

data (INPUT DWord)

  Data to write

target (INOUT TypeTarget)

  target to operate on

#### State codes

- 16#8000 - Error - invalid CGM number

RETURN (`GracoCore_TypeFunctionCmdState`_)

### StatusToUDT

Read status data from a PD2K Integrated device and collect it into a user-defined data type. This provides a more-convenient view of the available data compared to accessing it directly. If an error occurs while attempting to read the device data, the state codes from GetDataBySlotNum will be forwarded through the return value of this function.

target (INOUT TypeTarget)

  Target to operate on

statusUDT (OUTPUT TypePd2kStatus)

  Status data packed in a user-defined data type

RETURN (`GracoCore_TypeFunctionCmdState`_)

## Function Blocks (FB)

### PumpControl

An interface into the pump controls for the PD2K Integrated system. This allows you to control the pump system state (e.g. mixing, standby, recipe change), clear alarms, complete a job, and set the mix control setpoint. The control inputs come from a user-defined data type - see TypePumpControlInputs.

enable (INPUT Bool)

  Enable command

mixUnitNum (INPUT USInt)

  Mix unit number (1-2)

controls (INOUT TypePumpControls)

  Controls

target (INOUT TypeTarget)

  Target to operate on

state (OUTPUT `GracoCore_TypeEnableCmdState`_)

  Command state

#### State codes

- 16#3000 - Command is valid, running

- 16#8000 - Error, device number is invalid

- 16#8002 - Internal error

- 16#8001 - Error, invalid mix unit number

- 16#0000 - Command is disabled

### ReadAlarmInfo

Read an alarm record from the PD2K. See SendDCS for state codes.

indexNum (INPUT USInt)

  Index number (0-199)

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

eventCode (OUTPUT STRING[4])

  Event code

dateTime (OUTPUT DTL)

  Event datetime

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### ReadEventInfo

Read an event record from the PD2K. See SendDCS for state codes.

indexNum (INPUT USInt)

  Index number (0-199)

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

eventCode (OUTPUT STRING[4])

  Event code

dateTime (OUTPUT DTL)

  Event datetime

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### ReadFlushSequence

Read parameters for a flush sequence. See SendDCS for state codes.

flushSeqNum (INPUT USInt)

  Flush sequence number (1-5)

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

gunPurgeTime (OUTPUT UInt)

  Gun purge time (s)

initialFlushVol (OUTPUT UInt)

  Initial flush volume (cc)

finalFlushVol (OUTPUT UInt)

  Final flush volume (cc)

numWashCycles (OUTPUT USInt)

  Number of wash cycles

strokesPerWashCycle (OUTPUT USInt)

  Number of strokes per wash cycle

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### ReadGrandTotals

Read parameters for a flush sequence. See SendDCS for state codes.

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

materialATotal (OUTPUT UInt)

  Material A total (gal)

materialBTotal (OUTPUT UInt)

  Material B total (gal)

materialABTotal (OUTPUT UInt)

  Material A+B total (gal)

solventTotal (OUTPUT USInt)

  Solvent total (gal)

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### ReadJobInfo

Read a job record from the PD2K. See SendDCS for state codes.

indexNum (INPUT USInt)

  Index number

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

dateTime (OUTPUT DTL)

  Recorded datetime

jobNum (OUTPUT UInt)

  Job number

mixUnitNum (OUTPUT USInt)

  Mix unit number

recipeNum (OUTPUT USInt)

  Recipe number

totalVol (OUTPUT UDInt)

  Total volume of mixed material (cc)

userID (OUTPUT STRING[9])

  User ID

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### ReadRecipe

Read parameters for a given recipe number. See SendDCS for state codes.

mixUnitNum (INPUT USInt)

  Mix unit number (1-2)

recipeNum (INPUT USInt)

  Recipe number (0-60)

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

matNumA (OUTPUT USInt)

  Material number of component A

matNumB (OUTPUT USInt)

  Material number of component B

flushSeqNumA (OUTPUT USInt)

  Flush sequence number for component A

flushSeqNumB (OUTPUT USInt)

  Flush sequence number for component B

mixRatioSP (OUTPUT UInt)

  Mix ratio setpoint (A*100 : B)

potLifeTimeSP (OUTPUT UInt)

  Potlife time setpoint (min)

mixPressureTolPct (OUTPUT UInt)

  Mix pressure tolerance (%)

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### ReadUserID

Read the current User ID. See SendDCS for state codes.

mixUnitNum (INPUT USInt)

  Mix unit number (1-2)

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

userID (OUTPUT STRING[9])

  User ID

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### SendDCS

Send a dynamic command structure (DCS) to the PD2K. See the operation manual for more details regarding the DCS.

cmdID (INPUT USInt)

  Command ID

arg0 (INPUT DWord)

  Argument 0

arg1 (INPUT DWord)

  Argument 1

arg2 (INPUT DWord)

  Argument 2

arg3 (INPUT DWord)

  Argument 3

arg4 (INPUT DWord)

  Argument 4

arg5 (INPUT DWord)

  Argument 5

arg6 (INPUT DWord)

  Argument 6

arg7 (INPUT DWord)

  Argument 7

arg8 (INPUT DWord)

  Argument 8

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

ret0 (OUTPUT DWord)

  Return 0

ret1 (OUTPUT DWord)

  Return 1

ret2 (OUTPUT DWord)

  Return 2

ret3 (OUTPUT DWord)

  Return 3

ret4 (OUTPUT DWord)

  Return 4

ret5 (OUTPUT DWord)

  Return 5

ret6 (OUTPUT DWord)

  Return 6

ret7 (OUTPUT DWord)

  Return 7

ret8 (OUTPUT DWord)

  Return 8

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

#### State codes

- 16#2000 - Command completed

- 16#4000 - Command was aborted

- 16#8000 - Error, command ID must be non-zero

- 16#8001 - Error, device number is invalid

- 16#8002 - Internal error

- 16#8003 - Error, timed out waiting for DCS registers to be available

- 16#8004 - Error, DCS command failed

- 16#8005 - Error, timed out waiting for acknowledge signal

### WriteFlushSequence

Write the parameters for a given flush sequence number. See SendDCS for state codes.

flushSeqNum (INPUT USInt)

  Flush sequence number (1-5)

gunPurgeTime (INPUT UInt)

  Gun purge time (0-999 s)

initFlushVol (INPUT UInt)

  Initial flush volume (0-9999 cc)

finalFlushVol (INPUT UInt)

  Final flush volume (0-9999 cc)

numWashCycles (INPUT USInt)

  Number of wash cycles (0-99)

strokesPerWashCycle (INPUT USInt)

  Number of strokes per wash cycle (0-99)

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### WriteMaterialReadyFlag

Write a value for the material ready flag. See SendDCS for state codes.

mixUnitNum (INPUT USInt)

  Mix unit number (1-2)

materialReadyFlag (INPUT Bool)

  Material ready flag

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### WriteRecipe

Write the parameters for a given recipe number. See SendDCS for state codes.

mixUnitNum (INPUT USInt)

  Mix unit number (1-2)

recipeNum (INPUT USInt)

  Recipe number (0-21)

matNumA (INPUT USInt)

  Material number for component A (0-30)

matNumB (INPUT USInt)

  Material number for component B (0, 31-34)

flushSeqNumA (INPUT USInt)

  Flush sequence number for component A (1-5)

flushSeqNumB (INPUT USInt)

  Flush sequence number for component B (1-5)

mixRatioSP (INPUT UInt)

  Mix ratio setpoint (0-5000, A*100 : B)

potLifeTimeSP (INPUT UInt)

  Potlife time setpoint (0-999 min)

mixPressureTolPct (INPUT UInt)

  Mix pressure tolerance (%)

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

### WriteUserID

Write a value for the user ID. See SendDCS for state codes.

mixUnitNum (INPUT USInt)

  Mix unit number (1-2)

userID (INPUT STRING[9])

  User ID

execute (INOUT Bool)

  Execute command

target (INOUT TypeTarget)

  Target to operate on

state (OUTPUT `GracoCore_TypeExecuteCmdState`_)

  Command state

## UDTs

### TypeMixUnit

eventFlag (Bool)

safetyInterlockStatus (Bool)

inStandby (Bool)

systemMode (USInt)

  System mode

systemModeFlags (TypeSystemModeFlags)

  System status flags

actualMixFlow (UInt)

  Actual mix flow/pressure (cc/min in flow mode, psi in pressure mode)

actualMixRatio (UInt)

  Actual mix ratio (A*100 : B)

actualPotLifeRemaining (UInt)

  Actual pot life time remaining (sec)

activeRecipeNum (USInt)

  Active recipe number

activeMatNumA (USInt)

  Active material number for component A

activeMatNumB (USInt)

  Active material number for component B

activeFlushSeqNumA (USInt)

  Active flush sequence number for component A

activeFlushSeqNumB (USInt)

  Active flush sequence number for component B

activeRatioSP (UInt)

  Active mix ratio setpoint (A*100 : B)

activePotLifeSP (UInt)

  Active pot life setpoint (min)

currentJobNum (UInt)

currentJobSprayVolA (UInt)

currentJobSprayVolB (UInt)

currentJobSolventVol (UInt)

### TypePd2kStatus

PD2K Integrated status data. See StatusToUDT.

mixUnit1 (TypeMixUnit)

mixUnit2 (TypeMixUnit)

gun1Trigger (Bool)

  Gun 1 trigger status

gun2Trigger (Bool)

  Gun 2 trigger status

pump1 (TypePump)

  Pump 1 status

pump2 (TypePump)

  Pump 2 status

pump3 (TypePump)

  Pump 3 status

pump4 (TypePump)

  Pump 4 status

dcsAck (USInt)

  DCS acknowledge

dcsAckFlags (`GracoCore_TypeDcsAckFlags`_)

  DCS acknowledge flags

dcsRet0 (DWord)

  DCS return 0

dcsRet1 (DWord)

  DCS return 1

dcsRet2 (DWord)

  DCS return 2

dcsRet3 (DWord)

  DCS return 3

dcsRet4 (DWord)

  DCS return 4

dcsRet5 (DWord)

  DCS return 5

dcsRet6 (DWord)

  DCS return 6

dcsRet7 (DWord)

  DCS return 7

dcsRet8 (DWord)

  DCS return 8

### TypePump

status (USInt)

  Pump status

statusFlags (TypePumpStatusFlags)

  Pump status flags

materialNum (USInt)

actualFlowRate (UInt)

  Actual pump flow rate (cc/min)

actualPressure (UInt)

  Actual pump pressure (psi)

### TypePumpControls

Pump control inputs. See PumpControl.

powerOnCmd (Bool)

  Power on command

powerOffCmd (Bool)

  Power off command

quickStopCmd (Bool)

  Quick stop command

recipeChangeCmd (Bool)

  Recipe change command

clearAlarm (Bool)

  Clear alarm command

completeJob (Bool)

  Complete job command

mixCmd (Bool)

  Mix mode command

mixFillCmd (Bool)

  Mix fill mode command

recipePurgeCmd (Bool)

  Recipe purge command

standbyCmd (Bool)

  Standby mode command

mixCtrlModeSP (Bool)

  Mix control mode setpoint (0=flow mode, 1=pressure mode)

mixCtrlSP (UInt)

  Mix control setpoint (cc/min for flow mode, psi for pressure mode)

mixFillCtrlSP (UInt)

  Mix fill control setpoint (cc/min for flow mode, psi for pressure mode)

nextRecipeNum (UInt)

  Next recipe number

### TypePumpStatusFlags

Pump status flags

off (Bool)

  Pump is off

standby (Bool)

  Pump is in standby

busy (Bool)

  Pump is busy

flushing (Bool)

  Pump is flushing

priming (Bool)

  Pump is priming

### TypeSystemModeFlags

System mode flags

pumpOff (Bool)

  System is off

colorChange (Bool)

  Color change is active

colorChangePurgeA (Bool)

  Color change is active, purging component A

colorChangePurgeB (Bool)

  Color change is active, purging component B

colorChangeFilling (Bool)

  Color change is active, filling

mixFill (Bool)

  System in mix fill mode

mix (Bool)

  System in mix mode

mixIdle (Bool)

  System in mix idle mode

purgeA (Bool)

  Purging component A

purgeB (Bool)

  Purging component B

standbyMixReady (Bool)

  Standby, mix ready

standbyFillReady (Bool)

  Standby, ready for fill

standbyMixNotReady (Bool)

  Standby, mix is not ready

standbyAlarm (Bool)

  Standby, alarm is active

lineFillingFlushing (Bool)

  Line is filling/flushing

pumpPrimeFlush (Bool)

  Priming/flushing a pump

maintenance (Bool)

  Maintenance

solventPush (Bool)

  Solvent push

### TypeTarget

Defines a target Profinet device. See Using TypeTarget.

simulate (Bool)

  Simulation mode select (1=on)

pnDeviceNum1 (UInt)

  Profinet device number for CGM 1

pnDeviceNum2 (UInt)

  Profinet device number for CGM 2

simData1 (Array[1..56] of DWord)

  Simulation data for CGM 1

simData2 (Array[1..56] of DWord)

  Simulation data for CGM 2