FuncIO.c ///
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define FUNCIO_C
/******************************************************************************
* *
* C O M P I L E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include "Common.h"
#include "XCore.h"
#include "XGPIO.h"
#include "XTask.h"
#include "XTimer.h"
#include "XPrtEng.h"
#include "XVarBank.h"
#include "Function.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(GPIO_MODEL)
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L I N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L U N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
STATIC TASK(PrintTask, arg)
{
INT Quantity = ((FUNCARG *)arg)->Number;
#if defined(TSPL)
TsplPrintFunc(Quantity);
#endif
TaskExit();
}
STATIC TASK(CutTask, arg)
{
CutPaper();
TaskExit();
}
STATIC VOID InFuncPauseToggle(VOID *arg)
{
if (CheckJobLock())
PrinterStart();
else
PrinterPause();
}
STATIC VOID InFuncPauseSet(VOID *arg)
{
if (!CheckJobLock())
PrinterPause();
}
STATIC VOID InFuncPauseClr(VOID *arg)
{
if (CheckJobLock())
PrinterStart();
}
STATIC VOID InFuncReprint(VOID *arg)
{
if (!IsMotion() && !CheckJobLock() && !GetJobErrorState())
TaskCreate(PrintTask, arg, TASK_PRINT_STACK);
}
STATIC VOID InFuncReprintACK(VOID *arg)
{
SetReprintKey(TRUE);
}
STATIC VOID InFuncReprintNACK(VOID *arg)
{
SetReprintKey(FALSE);
}
STATIC VOID InFuncPrint(VOID *arg)
{
if (!IsMotion() && !CheckJobLock() && !GetJobErrorState())
TaskCreate(PrintTask, arg, TASK_PRINT_STACK);
}
STATIC VOID InFuncFeed(VOID *arg)
{
_PrintCfg *pFeedCfg = GrabPrintConfig();
INT Quantity = ((FUNCARG *)arg)->Number;
if (!IsMotion() && !CheckJobLock() && !GetJobErrorState())
MotorMove(Quantity, pFeedCfg, MOTOR_FORWARD, _NULL);
}
STATIC VOID InFuncBackfeed(VOID *arg)
{
_PrintCfg *pFeedCfg = GrabPrintConfig();
INT Quantity = ((FUNCARG *)arg)->Number;
if (!IsMotion() && !CheckJobLock() && !GetJobErrorState())
MotorMove(Quantity, pFeedCfg, MOTOR_BACKWARD, _NULL);
}
STATIC VOID InFuncFormFeed(VOID *arg)
{
_PrintCfg *pFeedCfg = GrabPrintConfig();
if (!IsMotion() && !CheckJobLock() && !GetJobErrorState())
FeedBatch(1, pFeedCfg, TRUE, _NULL);
}
STATIC VOID InFuncCut(VOID *arg)
{
if (!IsMotion() && !CheckJobLock() && !GetJobErrorState())
TaskCreate(CutTask, 0, TASK_CUT_STACK);
}
STATIC VOID InFuncInput(VOID *arg)
{
BYTE *data = (BYTE *)((FUNCARG *)arg)->String;
while (*data != 0)
UserDataIn(*data++);
// UserDataIn(CR_CHAR);
}
STATIC BOOL OutFuncPause(VOID)
{
if (CheckJobLock())
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncReprint(VOID)
{
if (GetReprintStatus())
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncTaskLabel(VOID)
{
if (GetJobMonitor() == MONITOR_TAKE_LABEL)
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncIdle(VOID)
{
if (!IsMotion() && GetJobMonitor() == MONITOR_IDLE)
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncFault(VOID)
{
if (GetJobErrorState() & ERROR_JOB_ALL_STATE)
return TRUE;
if (IsMemoryFailed())
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncFaultPaper(VOID)
{
if (GetJobErrorState() & (ERROR_PAPER_JAM | ERROR_PAPER_EMPTY))
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncFaultRibbon(VOID)
{
if (GetJobErrorState() & (ERROR_RIBBON_JAM | ERROR_RIBBON_EMPTY))
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncFaultCarriage(VOID)
{
if (GetJobErrorState() & ERROR_TPH_OPEN)
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncFaultCutter(VOID)
{
if (GetJobErrorState() & ERROR_CUTTER)
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncFaultMemory(VOID)
{
if (IsMemoryFailed())
return TRUE;
return FALSE;
}
STATIC BOOL OutFuncFaultOverHeat(VOID)
{
if (GetJobErrorState() & (ERROR_TPH_OVERHEAT | ERROR_MOTOR_OVERHEAT))
return TRUE;
return FALSE;
}
VOID InitialFuncIO(VOID)
{
_PrintCfg *pFuncCfg = GrabPrintConfig();
INT Channel;
for (Channel = 0; Channel < GPI_TOTAL; Channel++)
GPInFuncSetting(Channel, &pFuncCfg->GPInSetting[Channel]);
for (Channel = 0; Channel < GPO_TOTAL; Channel++)
GPOutFuncSetting(Channel, &pFuncCfg->GPOutSetting[Channel]);
}
VOID GPInFuncSetting(INT ch, _GPISetting *input)
{
INT sig = input->Signal;
INT ps = input->Pulse;
FUNCARG arg = input->Argument;
if (input->FuncID == GPI_FUNC_OFF)
SetGPInputFunc(ch, sig, ps, arg, _NULL, _NULL, _NULL);
if (input->FuncID == GPI_FUNC_PAUSE)
SetGPInputFunc(ch, sig, ps, arg, InFuncPauseToggle, InFuncPauseSet, InFuncPauseClr);
if (input->FuncID == GPI_FUNC_PAUSE_ON)
SetGPInputFunc(ch, sig, ps, arg, InFuncPauseSet, InFuncPauseSet, _NULL);
if (input->FuncID == GPI_FUNC_PAUSE_OFF)
SetGPInputFunc(ch, sig, ps, arg, InFuncPauseClr, InFuncPauseClr, _NULL);
if (input->FuncID == GPI_FUNC_REPRINT)
SetGPInputFunc(ch, sig, ps, arg, InFuncReprint, InFuncReprint, _NULL);
if (input->FuncID == GPI_FUNC_REPRINT_ON)
SetGPInputFunc(ch, sig, ps, arg, InFuncReprintACK, InFuncReprintACK, _NULL);
if (input->FuncID == GPI_FUNC_REPRINT_OFF)
SetGPInputFunc(ch, sig, ps, arg, InFuncReprintNACK, InFuncReprintNACK, _NULL);
if (input->FuncID == GPI_FUNC_PRINT)
SetGPInputFunc(ch, sig, ps, arg, InFuncPrint, InFuncPrint, _NULL);
if (input->FuncID == GPI_FUNC_FEED)
SetGPInputFunc(ch, sig, ps, arg, InFuncFeed, InFuncFeed, _NULL);
if (input->FuncID == GPI_FUNC_BACKFEED)
SetGPInputFunc(ch, sig, ps, arg, InFuncBackfeed, InFuncBackfeed, _NULL);
if (input->FuncID == GPI_FUNC_FORMFEED)
SetGPInputFunc(ch, sig, ps, arg, InFuncFormFeed, InFuncFormFeed, _NULL);
if (input->FuncID == GPI_FUNC_CUT)
SetGPInputFunc(ch, sig, ps, arg, InFuncCut, InFuncCut, _NULL);
if (input->FuncID == GPI_FUNC_INPUT)
SetGPInputFunc(ch, sig, ps, arg, InFuncInput, InFuncInput, _NULL);
}
VOID GPOutFuncSetting(INT ch, _GPOSetting *output)
{
INT sig = output->Signal;
INT td = output->TrueDelay;
INT tp = output->TruePulse;
INT fd = output->FalseDelay;
INT fp = output->FalsePulse;
if (output->FuncID == GPO_FUNC_OFF)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, _NULL);
if (output->FuncID == GPO_FUNC_PAUSE)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncPause);
if (output->FuncID == GPO_FUNC_REPRINT)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncReprint);
if (output->FuncID == GPO_FUNC_TAKELABEL)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncTaskLabel);
if (output->FuncID == GPO_FUNC_IDLE)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncIdle);
if (output->FuncID == GPO_FUNC_FAULT)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncFault);
if (output->FuncID == GPO_FUNC_FAULT_PAPER)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncFaultPaper);
if (output->FuncID == GPO_FUNC_FAULT_RIBBON)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncFaultRibbon);
if (output->FuncID == GPO_FUNC_FAULT_CARRIAGE)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncFaultCarriage);
if (output->FuncID == GPO_FUNC_FAULT_CUTTER)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncFaultCutter);
if (output->FuncID == GPO_FUNC_FAULT_MEMORY)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncFaultMemory);
if (output->FuncID == GPO_FUNC_FAULT_OVERHEAT)
SetGPOutputFunc(ch, sig, td, tp, fd, fp, OutFuncFaultOverHeat);
}
#endif
FuncJob.c /
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define FUNCJOB_C
/******************************************************************************
* *
* C O M P I L E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include "Common.h"
#include "XCore.h"
#include "XPrtEng.h"
#include "XParser.h"
#include "Function.h"
#include "../core/AppMain.h"
extern _CalResult* GetCalResult(VOID); // ch_20220407
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L I N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L U N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
#define DEBUG_PRNT_CFG
#undef DEBUG_PRNT_CFG
extern UCHAR GetCalStatPowerOn(VOID);
/
// ch_20220721
STATIC UCHAR ContinuousCalCnt = 0;
UCHAR GetContinuousCalTimes(VOID) {
return ContinuousCalCnt;
}
/
VOID ConfigToWorkJob(_WorkJob *WorkJob, _PrintCfg *PrtCfg)
{
_CalResult* pCalRslt = NULL; // ch_20220407
WORD Temp1 = 0; // ch_20220603
#ifdef DEBUG_PRNT_CFG
sysprintf("Enter ConfigToWorkJob()...\n"); // ch_20220104
#endif
//
// ch_20220409
if (GetCalibratedStat())
pCalRslt = GetCalResult();
else {
pCalRslt->SensorMode = PrtCfg->SensorMode;
// if (GAP_MODE == pCalRslt->SensorMode) {
// pCalRslt->GapInten = PrtCfg->GapInten;
// pCalRslt->fGapSize = PrtCfg->fGapSize;
// }
// else if (BLINE_MODE == pCalRslt->SensorMode) {
// pCalRslt->BlineInten = PrtCfg->BlineInten;
// pCalRslt->fBlineSize = PrtCfg->fBlineSize;
// }
// else {
// pCalRslt->ContinuousInten = PrtCfg->ContinuousInten;
// }
}
// ch_20220411 判断定标是否结束
if ((!GetCalibratedStat()) &&
(pCalRslt->SensorMode==GAP_MODE && PrtCfg->fPaperSize==508 && PrtCfg->fGapSize==60))
RstCalStatPowerOn();
else
SetCalStatPowerOn();
//
WorkJob->SensorMode = PrtCfg->SensorMode;
//sysprintf("WJ->SM%d\t", WorkJob->SensorMode); // ch_20220226
WorkJob->PrintOutMode = PrtCfg->PrintOutMode;
#ifdef DEBUG_PRNT_CFG
sysprintf("->PrintOutMode = %d\t", WorkJob->PrintOutMode); // ch_20220104
#endif
WorkJob->GapInten = PrtCfg->GapInten; // ch_20220409
// WorkJob->GapInten = pCalRslt->GapInten; // ch_20220409
//#ifdef DEBUG_PRNT_CFG
// sysprintf("->GI%d\t", WorkJob->GapInten); // ch_20220104
//#endif
WorkJob->BlineInten = PrtCfg->BlineInten; // ch_20220409
// WorkJob->BlineInten = pCalRslt->BlineInten; // ch_20220409
#ifdef DEBUG_PRNT_CFG
sysprintf("->BI%d\t", WorkJob->BlineInten); // ch_20220104
#endif
WorkJob->ContinuousInten = PrtCfg->ContinuousInten; // ch_20220409
// WorkJob->ContinuousInten = pCalRslt->ContinuousInten; // ch_20220409
#ifdef DEBUG_PRNT_CFG
sysprintf("->CI%d\t", WorkJob->ContinuousInten); // ch_20220104
#endif
WorkJob->RibbonInten = PrtCfg->RibbonInten;
#ifdef DEBUG_PRNT_CFG
sysprintf("->RibbonInten = %d\n", WorkJob->RibbonInten); // ch_20220104
#endif
WorkJob->GapRef = PrtCfg->GapRef; // ch_20220
//#ifdef DEBUG_PRNT_CFG
// sysprintf("->GapRef%d\t", WorkJob->GapRef); // ch_20220104
//#endif
WorkJob->BlineRef = PrtCfg->BlineRef;
#ifdef DEBUG_PRNT_CFG
sysprintf("->BlineRef = %d\t", WorkJob->BlineRef); // ch_20220104
#endif
WorkJob->ContinuousRef = PrtCfg->ContinuousRef;
#ifdef DEBUG_PRNT_CFG
sysprintf("->ContinuousRef = %d\t", WorkJob->ContinuousRef); // ch_20220104
#endif
WorkJob->RibbonRef = PrtCfg->RibbonRef;
#ifdef DEBUG_PRNT_CFG
sysprintf("->RibbonRef = %d\t", WorkJob->RibbonRef); // ch_20220104
#endif
WorkJob->AutoSensorRef = PrtCfg->AutoSensorRef;
//#ifdef DEBUG_PRNT_CFG
// sysprintf("->AutoRef%d\t", WorkJob->AutoSensorRef); // ch_20220104
//#endif
if (WorkJob->AutoSensorRef)
WorkJob->GapRef = WorkJob->BlineRef = 0;
// WorkJob->fLabelSize = CalculateLabelSize(PrtCfg);
// WorkJob->fLabelSize = CalLabelSizeWithCalRslt(pCalRslt); // ch_20220409
//#ifdef DEBUG_PRNT_CFG
// sysprintf("\n->fLS = %d\t", (WORD)WorkJob->fLabelSize); // ch_20220104
//#endif
WorkJob->fPaperSize = PrtCfg->fPaperSize; // ch_20220409
// WorkJob->fPaperSize = pCalRslt->fPaperSize; // ch_20220409
//#ifdef DEBUG_PRNT_CFG
// sysprintf("->fPS = %d\t", (WORD)WorkJob->fPaperSize); // ch_20220104
//#endif
WorkJob->fGapSize = PrtCfg->fGapSize; // ch_20220407
// WorkJob->fGapSize = pCalRslt->fGapSize; // ch_20220407
//#ifdef DEBUG_PRNT_CFG
// sysprintf("->fGS = %d\t", (WORD)WorkJob->fGapSize); // ch_20220104
//#endif
WorkJob->fGapOffset = PrtCfg->fGapOffset;
#ifdef DEBUG_PRNT_CFG
sysprintf("->fGapOffset = %d\t", (WORD)WorkJob->fGapOffset); // ch_20220104
#endif
WorkJob->fBlineSize = PrtCfg->fBlineSize; // ch_20220409
// WorkJob->fBlineSize = pCalRslt->fBlineSize; // ch_20220409
//#ifdef DEBUG_PRNT_CFG
// sysprintf("->fBS = %d\t", (WORD)WorkJob->fBlineSize); // ch_20220104
//#endif
WorkJob->fBlineOffset = PrtCfg->fBlineOffset;
#ifdef DEBUG_PRNT_CFG
sysprintf("->fBlineOffset = %d\t", (WORD)WorkJob->fBlineOffset); // ch_20220104
#endif
WorkJob->PrintLength = PrtCfg->fPaperSize; // ch_20220409
// WorkJob->PrintLength = pCalRslt->fPaperSize; // ch_20220409
#ifdef DEBUG_PRNT_CFG
sysprintf("->PrintLength = %d\t", WorkJob->PrintLength); // ch_20220104
#endif
WorkJob->IgnoreSize = PrtCfg->IgnoreSize;
#ifdef DEBUG_PRNT_CFG
sysprintf("->IgnoreSize = %d\t", WorkJob->IgnoreSize); // ch_20220104
#endif
WorkJob->ShiftDis = PrtCfg->ShiftDisY;
#ifdef DEBUG_PRNT_CFG
sysprintf("->ShiftDis = %d\t", WorkJob->ShiftDis); // ch_20220104
#endif
WorkJob->OffsetDis = PrtCfg->OffsetDis;
#ifdef DEBUG_PRNT_CFG
sysprintf("->OffsetDis = %d\n", WorkJob->OffsetDis); // ch_20220104
#endif
WorkJob->fLabelSize = WorkJob->fPaperSize + WorkJob->fGapSize; // ch_20220409
// ch_20220409
if (WorkJob->SensorMode == GAP_MODE)
WorkJob->fLabelSize = WorkJob->fPaperSize + WorkJob->fGapSize;
else if (WorkJob->SensorMode == BLINE_MODE)
WorkJob->fLabelSize = WorkJob->fPaperSize + WorkJob->fBlineSize;
else
WorkJob->fLabelSize = WorkJob->fPaperSize;
//#ifdef DEBUG_PRNT_CFG
//sysprintf("WJ->SM%d, ->GI%d, ->BI%d, ->fLS%d, ->fPS%d, ->fGS%d, ->fBS%d, ", WorkJob->SensorMode, WorkJob->GapInten,
// WorkJob->BlineInten, (WORD)WorkJob->fLabelSize, (WORD)WorkJob->fPaperSize, (WORD)WorkJob->fGapSize,
// (WORD)WorkJob->fBlineSize);
//#endif
WorkJob->CutterPieces = PrtCfg->CutterPieces;
WorkJob->PrintKeyCnt = PrtCfg->PrintKeyCnt;
WorkJob->ReprintKeyCnt = PrtCfg->ReprintKeyCnt;
WorkJob->Direction = PrtCfg->Direction;
WorkJob->Mirror = PrtCfg->Mirror;
WorkJob->Measure = PrtCfg->Measure;
WorkJob->Calibrate = PrtCfg->Calibrate;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Calibrate = %d\n", WorkJob->Calibrate); // ch_20220104
#endif
WorkJob->Ribbon = PrtCfg->RibbonFlag;
WorkJob->Reprint = PrtCfg->Reprint;
WorkJob->PrintKey = PrtCfg->PrintKey;
#ifdef DEBUG_PRNT_CFG
sysprintf("->PrintKey = %d\n", WorkJob->PrintKey); // ch_20220104
#endif
WorkJob->ReprintKey = PrtCfg->ReprintKey;
WorkJob->Verifier = PrtCfg->Verifier;
WorkJob->CutterBack = PrtCfg->CutterBack;
WorkJob->SuppressBack = PrtCfg->SuppressBack;
// ch_20220701
WorkJob->Speed = PrtCfg->Speed;
//sysprintf("Speed_%d\n", WorkJob->Speed); // ch_20220610
// WorkJob->Density = (WORD)PrtCfg->fDensity; // ch_20220701 // ch_20220603
//
// ch_20220701
Temp1 = (WORD)PrtCfg->fDensity;
//sysprintf("I_D_%d\n", Temp1); // ch_20220701
switch(Temp1) {
case 1:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 2.5;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 1.5;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity -= 0.5;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 3.5;
break;
case 2:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 2.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 0.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 3.0;
break;
case 3:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 4.0;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 2.0;
break;
case 4:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 4.0;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 2.0;
break;
case 5:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 4.0;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 2.0;
break;
case 6:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 4.0;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 2.0;
break;
case 7:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 4.0;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 2.0;
break;
case 8:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;//5;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 2.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 3.0;
break;
case 9:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 4.0;//6;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 3.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 2.0;
break;
case 10:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 5.0;//7;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 4.0;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 2.0;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 1.0;
break;
case 11:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 4.2;//6.2;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 3.2;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 1.2;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 1.8;
break;
case 12:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 3.4;//5.4;
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 2.4;
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 0.4;
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 2.2;
break;
case 13:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 2.6+2;//4.6; // ch_20220711 : +2
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 1.6+2; // ch_20220711 : +2
else if (3 == WorkJob->Speed)
PrtCfg->fDensity -= 0.4+2; // ch_20220711 : +2
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 3.4+2; // ch_20220711 : +2
break;
case 14:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 1.8+1;//3.8; // ch_20220711 : +1
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 0.8+1; // ch_20220711 : +1
else if (3 == WorkJob->Speed)
PrtCfg->fDensity -= 1.2+1; // ch_20220711 : +1
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 4.2+1; // ch_20220711 : +1
break;
case 15:
if (7 == WorkJob->Speed)
PrtCfg->fDensity += 5.8;//0.8;//2.8; // ch_20220708 : Then density add 5 and changed to 5.8
else if (5 == WorkJob->Speed)
PrtCfg->fDensity += 4.8;//-= 0.2; // ch_20220708 : Then density add 5 and changed to 4.8
else if (3 == WorkJob->Speed)
PrtCfg->fDensity += 2.8;//-= 2.2; // ch_20220708 : Then density add 5 and changed to 2.8
else if (1 == WorkJob->Speed)
PrtCfg->fDensity -= 0.2;//5.2; // ch_20220708 : Then density add 5 and changed to 0.2
break;
default:
break;
}
// sysprintf("O_D_%d\n", (WORD)(PrtCfg->fDensity*10)); // ch_20220701
//
WorkJob->Density =
(WORD)((PrtCfg->fDensity - DensityMin) / (DensityMax - DensityMin + 1) * GetHeatScale() + 0.5);
//#ifdef DEBUG_PRNT_CFG
// sysprintf("->D%d, PrtCfg->fD%d, Scale%d\n", WorkJob->Density, (INT)PrtCfg->fDensity, GetHeatScale()); // ch_20220104
//#endif
//sysprintf("O_D_%d\n", WorkJob->Density); // ch_20220701
// ch_20220701
// WorkJob->Speed = PrtCfg->Speed;
//sysprintf("Speed_%d\n", WorkJob->Speed); // ch_20220610
//sysprintf("B : P_D_%d, W_D_%d\n", (WORD)PrtCfg->fDensity, WorkJob->Density); // ch_20220603
///
// ch_20220610
// ch_20220603
//if (Temp1 < 5)
// WorkJob->Density -= (1*6);
//else if (5 == Temp1)
// WorkJob->Density -= (5*6);
//else if ((Temp1>5)&&(Temp1<=15))
// WorkJob->Density -= (1*6);
// ch_20220701
//if (1 == WorkJob->Speed) {
// if ((Temp1>=1)&&(Temp1<=2)) {
// WorkJob->Density -= (1*6);
// }
// else
// WorkJob->Density -= (3*6);
//}
//else if (3 == WorkJob->Speed) {
// if ((Temp1>=6)&&(Temp1<=7)) {
// WorkJob->Density += 2;
// }
// else if (Temp1>=8) {
// WorkJob->Density += (2*6);
// }
//}
//else if (5 == WorkJob->Speed) {
// if ((Temp1>=1)&&(Temp1<=7)) {
// }
// else
// WorkJob->Density += (3*6);
//}
//else if (7 == WorkJob->Speed) {
// WorkJob->Density += (2*6);
// if (Temp1>=8) {
// }
//}
//sysprintf("O_D_%d\n", WorkJob->Density); // ch_20220701
///
//sysprintf("A : P_D_%d, W_D_%d\n", (WORD)PrtCfg->fDensity, WorkJob->Density); // ch_20220603
#ifdef DEBUG_PRNT_CFG
sysprintf("->Spd = %d\n", WorkJob->Speed); // ch_20220104
#endif
WorkJob->OverHeat = PrtCfg->OverHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->OverHeat = %d\t", WorkJob->OverHeat); // ch_20220104
#endif
WorkJob->PrintHeat = PrtCfg->PrintHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->PrintHeat = %d\t", WorkJob->PrintHeat); // ch_20220104
#endif
WorkJob->MotorOverHeat = PrtCfg->MotorOverHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->MotorOverHeat = %d\t", WorkJob->MotorOverHeat); // ch_20220104
#endif
WorkJob->MotorMoveHeat = PrtCfg->MotorMoveHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->MotorMoveHeat = %d\n", WorkJob->MotorMoveHeat); // ch_20220104
#endif
WorkJob->LimitFeed = PrtCfg->LimitFeed; // ch_20220219
#ifdef DEBUG_PRNT_CFG
sysprintf("->LimitFeed = %d\n", WorkJob->LimitFeed); // ch_20220104
#endif
#ifdef DEBUG_PRNT
sysprintf("Leave ConfigToWorkJob()...\n"); // ch_20220104
#endif
ContinuousCalCnt = 0; // ch_20220721
}
///
// ch_20220308
VOID ConfigToWorkJob4Cal(_WorkJob *WorkJob, _PrintCfg *PrtCfg) //PC下发打印不会进来执行
{
#ifdef DEBUG_PRNT_CFG
sysprintf("Enter ConfigToWorkJob()...\n"); // ch_20220104
#endif
WorkJob->SensorMode = GAP_MODE; //PrtCfg->SensorMode; // ch_20220308 : force to set as GAP_MODE.
#ifdef DEBUG_PRNT_CFG
sysprintf("PrtCfg->SensorMode = %d\n", PrtCfg->SensorMode); // ch_20220226
#endif
WorkJob->PrintOutMode = PrtCfg->PrintOutMode;
#ifdef DEBUG_PRNT_CFG
sysprintf("WorkJob->PrintOutMode = %d\t", WorkJob->PrintOutMode); // ch_20220104
#endif
WorkJob->GapInten = 4; //PrtCfg->GapInten; // ch_20220308 : changed to 4 from PrtCfg->GapInten.
#ifdef DEBUG_PRNT_CFG
sysprintf("->GapInten = %d\t", WorkJob->GapInten); // ch_20220104
#endif
WorkJob->BlineInten = 2; //PrtCfg->BlineInten; // ch_20220308 : changed to 2 from PrtCfg->BlineInten.
#ifdef DEBUG_PRNT_CFG
sysprintf("->BlineInten = %d\t", WorkJob->BlineInten); // ch_20220104
#endif
WorkJob->ContinuousInten = PrtCfg->ContinuousInten;
#ifdef DEBUG_PRNT_CFG
sysprintf("->ContinuousInten = %d\t", WorkJob->ContinuousInten); // ch_20220104
#endif
WorkJob->RibbonInten = PrtCfg->RibbonInten;
#ifdef DEBUG_PRNT_CFG
sysprintf("->RibbonInten = %d\n", WorkJob->RibbonInten); // ch_20220104
#endif
WorkJob->GapRef = 512;//PrtCfg->GapRef; // ch_20220308 : changed to 512 from PrtCfg->GapRef.
#ifdef DEBUG_PRNT_CFG
sysprintf("->GapRef = %d\t", WorkJob->GapRef); // ch_20220104
#endif
WorkJob->BlineRef = 512;//PrtCfg->BlineRef; // ch_20220308 : changed to 512 from PrtCfg->GapRef.
#ifdef DEBUG_PRNT_CFG
sysprintf("->BlineRef = %d\t", WorkJob->BlineRef); // ch_20220104
#endif
WorkJob->ContinuousRef = PrtCfg->ContinuousRef;
#ifdef DEBUG_PRNT_CFG
sysprintf("->ContinuousRef = %d\t", WorkJob->ContinuousRef); // ch_20220104
#endif
WorkJob->RibbonRef = PrtCfg->RibbonRef;
#ifdef DEBUG_PRNT_CFG
sysprintf("->RibbonRef = %d\t", WorkJob->RibbonRef); // ch_20220104
#endif
WorkJob->AutoSensorRef = PrtCfg->AutoSensorRef;
#ifdef DEBUG_PRNT_CFG
sysprintf("->AutoSensorRef = %d\n", WorkJob->AutoSensorRef); // ch_20220104
#endif
if (WorkJob->AutoSensorRef)
WorkJob->GapRef = WorkJob->BlineRef = 0;
WorkJob->fLabelSize = 568;//CalculateLabelSize(PrtCfg); // ch_20220308 : changed to 568.
// WorkJob->fLabelSize = CalculateLabelSize(PrtCfg) * 2; // ch_20220219
#ifdef DEBUG_PRNT_CFG
sysprintf("->fLabelSize = %d\t", (WORD)WorkJob->fLabelSize); // ch_20220104
#endif
WorkJob->fPaperSize = 508;//PrtCfg->fPaperSize; // ch_20220308 : changed to 508
// WorkJob->fPaperSize = PrtCfg->fPaperSize * 2; // ch_20220219
#ifdef DEBUG_PRNT_CFG
sysprintf("->fPaperSize = %d\t", (WORD)WorkJob->fPaperSize); // ch_20220104
#endif
WorkJob->fGapSize = 60;//PrtCfg->fGapSize; // ch_20220308 : changed to 60
// WorkJob->fGapSize = PrtCfg->fGapSize * 2; // ch_20220219
#ifdef DEBUG_PRNT_CFG
sysprintf("->fGapSize = %d\t", (WORD)WorkJob->fGapSize); // ch_20220104
#endif
WorkJob->fGapOffset = PrtCfg->fGapOffset;
#ifdef DEBUG_PRNT_CFG
sysprintf("->fGapOffset = %d\t", (WORD)WorkJob->fGapOffset); // ch_20220104
#endif
WorkJob->fBlineSize = 60;//PrtCfg->fBlineSize; // ch_20220308
// WorkJob->fBlineSize = PrtCfg->fBlineSize * 2; // ch_20220219
#ifdef DEBUG_PRNT_CFG
sysprintf("->fBlineSize = %d\t", (WORD)WorkJob->fBlineSize); // ch_20220104
#endif
WorkJob->fBlineOffset = PrtCfg->fBlineOffset;
#ifdef DEBUG_PRNT_CFG
sysprintf("->fBlineOffset = %d\t", (WORD)WorkJob->fBlineOffset); // ch_20220104
#endif
WorkJob->PrintLength = PrtCfg->fPaperSize; // ch_20220219
// WorkJob->PrintLength = PrtCfg->fPaperSize * 2; // ch_20220219
#ifdef DEBUG_PRNT_CFG
sysprintf("->PrintLength = %d\t", WorkJob->PrintLength); // ch_20220104
#endif
WorkJob->IgnoreSize = PrtCfg->IgnoreSize;
#ifdef DEBUG_PRNT_CFG
sysprintf("->IgnoreSize = %d\t", WorkJob->IgnoreSize); // ch_20220104
#endif
WorkJob->ShiftDis = PrtCfg->ShiftDisY;
#ifdef DEBUG_PRNT_CFG
sysprintf("->ShiftDis = %d\t", WorkJob->ShiftDis); // ch_20220104
#endif
WorkJob->OffsetDis = PrtCfg->OffsetDis;
#ifdef DEBUG_PRNT_CFG
sysprintf("->OffsetDis = %d\n", WorkJob->OffsetDis); // ch_20220104
#endif
WorkJob->CutterPieces = PrtCfg->CutterPieces;
WorkJob->PrintKeyCnt = PrtCfg->PrintKeyCnt;
WorkJob->ReprintKeyCnt = PrtCfg->ReprintKeyCnt;
WorkJob->Direction = PrtCfg->Direction;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Direction = %d\n", WorkJob->Direction); // ch_20220104
#endif
WorkJob->Mirror = PrtCfg->Mirror;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Mirror = %d\n", WorkJob->Mirror); // ch_20220104
#endif
WorkJob->Measure = PrtCfg->Measure;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Measure = %d\n", WorkJob->Measure); // ch_20220104
#endif
WorkJob->Calibrate = PrtCfg->Calibrate;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Calibrate = %d\n", WorkJob->Calibrate); // ch_20220104
#endif
WorkJob->Ribbon = PrtCfg->RibbonFlag;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Ribbon = %d\n", WorkJob->Ribbon); // ch_20220104
#endif
WorkJob->Reprint = PrtCfg->Reprint;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Reprint = %d\n", WorkJob->Reprint); // ch_20220104
#endif
WorkJob->PrintKey = PrtCfg->PrintKey;
#ifdef DEBUG_PRNT_CFG
sysprintf("->PrintKey = %d\n", WorkJob->PrintKey); // ch_20220104
#endif
WorkJob->ReprintKey = PrtCfg->ReprintKey;
#ifdef DEBUG_PRNT_CFG
sysprintf("->ReprintKey = %d\n", WorkJob->ReprintKey); // ch_20220104
#endif
WorkJob->Verifier = PrtCfg->Verifier;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Verifier = %d\n", WorkJob->Verifier); // ch_20220104
#endif
WorkJob->CutterBack = PrtCfg->CutterBack;
WorkJob->SuppressBack = PrtCfg->SuppressBack;
WorkJob->Density =
(WORD)((PrtCfg->fDensity - DensityMin) / (DensityMax - DensityMin + 1) * GetHeatScale() + 0.5);
#ifdef DEBUG_PRNT_CFG
sysprintf("->Density = %d\t", WorkJob->Density); // ch_20220104
#endif
WorkJob->Speed = PrtCfg->Speed;
#ifdef DEBUG_PRNT_CFG
sysprintf("->Speed = %d\n", WorkJob->Speed); // ch_20220104
#endif
WorkJob->OverHeat = PrtCfg->OverHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->OverHeat = %d\t", WorkJob->OverHeat); // ch_20220104
#endif
WorkJob->PrintHeat = PrtCfg->PrintHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->PrintHeat = %d\t", WorkJob->PrintHeat); // ch_20220104
#endif
WorkJob->MotorOverHeat = PrtCfg->MotorOverHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->MotorOverHeat = %d\t", WorkJob->MotorOverHeat); // ch_20220104
#endif
WorkJob->MotorMoveHeat = PrtCfg->MotorMoveHeat;
#ifdef DEBUG_PRNT_CFG
sysprintf("->MotorMoveHeat = %d\n", WorkJob->MotorMoveHeat); // ch_20220104
#endif
WorkJob->LimitFeed = PrtCfg->LimitFeed; // ch_20220219
// WorkJob->LimitFeed = PrtCfg->LimitFeed * 2; // ch_20220219
#ifdef DEBUG_PRNT_CFG
sysprintf("->LimitFeed = %d\n", WorkJob->LimitFeed); // ch_20220104
#endif
#ifdef DEBUG_PRNT
sysprintf("Leave ConfigToWorkJob()...\n"); // ch_20220104
#endif
//
// ch_20220721
ContinuousCalCnt++;
if (ContinuousCalCnt > 3)
ContinuousCalCnt = 3;
//
}
/
UINT MotorMove(LONG Quantity, _PrintCfg *PrtCfg, _eMotorDir Dir, XCALLBACK Callback) //单击按键时开始进来执行1次
{
_WorkJob WorkJob;
//sysprintf("CogTJob...2\n");
ConfigToWorkJob(&WorkJob, PrtCfg);
WorkJob.Type = MOTOR_JOB;
WorkJob.MotorDir = Dir;
WorkJob.BatchNumber = 0;
WorkJob.Quantity = Quantity;
WorkJob.Callback = Callback;
sysprintf("QueueWorkJob_1\n");
return QueueWorkJob(&WorkJob);
}
UINT FeedBatch(LONG Quantity, _PrintCfg *PrtCfg, BOOL PreventJump, XCALLBACK Callback)
{
_WorkJob WorkJob;
#ifdef DEBUG_PRNT
sysprintf("Enter FeedBatch()...\n"); // ch_20211211
#endif
//sysprintf("CogTJob...3\n");
ConfigToWorkJob(&WorkJob, PrtCfg);
WorkJob.Type = FEED_JOB;
WorkJob.Reprint = FALSE;
WorkJob.PrintKey = FALSE;
WorkJob.PrintFullImage = FALSE;
WorkJob.PreventJumpPage = PreventJump;
WorkJob.PrePaper = 0;
WorkJob.PreGapBline = 0;
WorkJob.BatchNumber = 0;
WorkJob.Quantity = Quantity;
WorkJob.Callback = Callback;
#ifdef DEBUG_PRNT
sysprintf("PrtCfg->SensorMod = %d\t->FeedLen = %d\n", PrtCfg->SensorMode, PrtCfg->FeedLength); // ch_20211211
#endif
if (PrtCfg->SensorMode == FEED_CONTINUE_MODE)
WorkJob.fPaperSize = WorkJob.fLabelSize = TPH_DPI;
ClrFeedStepCnt(); // ch_20220527
//sysprintf("QueueWorkJob_2\n");
return QueueWorkJob(&WorkJob);
}
/
//这是一个打印批次函数的实现
/* 1 函数首先创建一个_WorkJob类型的变量WorkJob,并通过ConfigToWorkJob函数将打印配置PrtCfg转换为工作任务的相关字段。
2 代码设置了WorkJob的一些字段,包括任务类型、图像缓冲区、是否打印完整图像、预防跳页、预设纸张、预设间隙和切线、显示总数、显示基础、批次号和打印数量。
同时,将回调函数指针赋值给WorkJob的Callback字段。
3 如果PrtLen不为0,则将其赋值给WorkJob的打印长度字段。
4 最后,将WorkJob添加到任务队列中,并设置等待时间。
5 函数返回批次号BatchNo。
*/
/ //PC打印开始进来执行1次
UINT PrintBatch(UINT BatchNo, LONG Quantity, _PrintCfg *PrtCfg,
_ImgBuf *ImgBuf, BOOL FullImg, INT PrtLen, INT DspTotal, INT DspBase, XCALLBACK Callback) // <--PrintImageLabel(LONG Count, LONG Copy)
{
_WorkJob WorkJob;
ConfigToWorkJob(&WorkJob, PrtCfg);
WorkJob.Type = PRINT_JOB;
WorkJob.ImgBuf = *ImgBuf;
WorkJob.PrintFullImage = FullImg;
WorkJob.PreventJumpPage = TRUE;
WorkJob.PrePaper = 0;
WorkJob.PreGapBline = 0;
WorkJob.DspTotal = DspTotal;
WorkJob.DspBase = DspBase;
WorkJob.BatchNumber = BatchNo;
WorkJob.Quantity = Quantity;
//sysprintf("Q%d\n", Quantity); // ch_20220323
WorkJob.Callback = Callback;
// sysprintf("BN:%d\n", WorkJob.BatchNumber); // ch_20220323 PC端选打印3份时 WorkJob.BatchNumber = 0
if (PrtLen)
WorkJob.PrintLength = PrtLen;
if (PrtCfg->SensorMode == FEED_CONTINUE_MODE)
WorkJob.PrintLength = WorkJob.fPaperSize = WorkJob.fLabelSize =
(WorkJob.ImgBuf.iLastLine + 1) + PrtCfg->ContinuePaperFeed;
//sysprintf("QueueWorkJob_3\n");
BatchNo = QueueWorkJob(&WorkJob);
SetWaitTime(PrtCfg->WaitJobTime);
return BatchNo;
}
/
UINT Calibration(_PrintCfg *PrtCfg, BOOL AutoDetectType, INT PrePaper, INT PreGapBline) //双击定标开始进来执行1次
{
_WorkJob WorkJob;
#ifdef DEBUG_PRNT
sysprintf("Enter Calibration()...\n"); // ch_20211208
#endif
// ConfigToWorkJob(&WorkJob, PrtCfg); // ch_20220308
ConfigToWorkJob4Cal(&WorkJob, PrtCfg); // ch_20220308
WorkJob.Type = CAL_JOB;
WorkJob.AutoDetectType = AutoDetectType;
WorkJob.PrePaper = PrePaper;
WorkJob.PreGapBline = PreGapBline;
WorkJob.BatchNumber = 0;
WorkJob.Quantity = 0;
WorkJob.Callback = _NULL;
//sysprintf("QueueWorkJob_4\n"); //双击定标打印先进来执行
return QueueWorkJob(&WorkJob);
}