Zpl2.c //
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2_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 *
* *
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
/******************************************************************************
* *
* 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 "XLED.h"
#include "XText.h"
#include "XTask.h"
#include "XTimer.h"
#include "XPrtEng.h"
#include "XProFile.h"
#include "XDisplay.h"
#include "..\Parser.h"
#include "..\ParserUtil.h"
#include "Zpl2Func.h"
#include "Zpl2Util.h"
#include "Zpl2Format.h"
#include "Zpl2Field.h"
#include "Zpl2FieldData.h"
#include "Zpl2Object.h"
#include "Zpl2Control.h"
#include "Zpl2.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(ZPL2)
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
STATIC VOID Zpl2HeadClose(VOID);
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
STATIC CONST _EntryLink Zpl2FormatLink[] =
{
{"B", EntryFormatB},
{"C", EntryFormatC},
{"D", EntryFormatD},
{"E", EntryFormatE},
{"F", EntryFormatF},
{"G", EntryFormatG},
{"H", EntryFormatH},
{"I", EntryFormatI},
{"J", EntryFormatJ},
{"K", EntryFormatK},
{"L", EntryFormatL},
{"M", EntryFormatM},
{"N", EntryFormatN},
{"P", EntryFormatP},
{"S", EntryFormatS},
{"T", EntryFormatT},
{"W", EntryFormatW},
{"X", EntryFormatX},
{"Z", EntryFormatZ},
{(CHAR *)_NULL, _NULL}
};
STATIC _CmdEntry Zpl2FormatEntry[] =
{
{"A", FormatA},
{"B", FormatB},
{"C", FormatC},
{"D", FormatD},
{"E", FormatE},
{"F", FormatF},
{"G", FormatG},
{"H", FormatH},
{"I", FormatI},
{"J", FormatJ},
{"K", FormatK},
{"L", FormatL},
{"M", FormatM},
{"N", FormatN},
{"P", FormatP},
{"S", FormatS},
{"T", FormatT},
{"W", FormatW},
{"X", FormatX},
{"Z", FormatZ},
{(CHAR *)_NULL, _NULL}
};
STATIC CONST _EntryLink Zpl2ControlLink[] =
{
{"C", EntryControlC},
{"D", EntryControlD},
{"E", EntryControlE},
{"H", EntryControlH},
{"J", EntryControlJ},
{"K", EntryControlK},
{"N", EntryControlN},
{"P", EntryControlP},
{"R", EntryControlR},
{"S", EntryControlS},
{"T", EntryControlT},
{"W", EntryControlW},
{(CHAR *)_NULL, _NULL}
};
STATIC _CmdEntry Zpl2ControlEntry[] =
{
{"C", ControlC},
{"D", ControlD},
{"E", ControlE},
{"H", ControlH},
{"J", ControlJ},
{"K", ControlK},
{"N", ControlN},
{"P", ControlP},
{"R", ControlR},
{"S", ControlS},
{"T", ControlT},
{"W", ControlW},
{(CHAR *)_NULL, _NULL}
};
/******************************************************************************
* *
* 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 INT IgnoreZPL(VOID)
{
return _ERROR;
}
BOOL InitialZpl2(VOID)
{
CHAR Buf[256];
FLOAT data;
if (GetProfileString("IGNORE ZPL FORMAT", Buf))
SyntaxIgnoreCommand(Buf, Zpl2FormatEntry, Zpl2FormatLink, IgnoreZPL);
if (GetProfileString("IGNORE ZPL CONTROL", Buf))
SyntaxIgnoreCommand(Buf, Zpl2ControlEntry, Zpl2ControlLink, IgnoreZPL);
PrintRateBase = 0;
if (GetProfileInt("PRINT RATEBASE", &data))
PrintRateBase = (SHORT)data;
FormatStart = FALSE;
ConfigurationUpdata(RECALL_LAST_SAVED_VALUES);
InitialFieldDefault();
InitialField();
InitialFieldData();
InitialFieldNumber();
InitialVariableArea();
InitialSerialization();
InitialFormat();
SelectEncoding(&EncodingFile);
#if defined(CARRIAGE_OPEN_MODEL)
SetCarriageCloseCallback(Zpl2HeadClose);
#endif
return TRUE;
}
BOOL ZebraSyntaxParsing(VOID)
{
_CmdEntry *CmdEntry;
CHAR Data;
ClearParserPool();
Data = ZebraNextByte(NEXT_ANY);
// Format commands use the caret(^) prefix.
// An "RS"(HEX 1E) can be substituted for the(^).
if (Data == CaretChar || Data == RS_CHAR)
{
do Data = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(Data) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(Data), Zpl2FormatEntry))
{
if (CmdEntry->func() == _SUCCESS)
return TRUE;
}
}
// Contorl commands use the tilde(~) prefix.
// An "DLE"(HEX 10) can be substituted for the(~).
else if (Data == TildeChar || Data == DLE_CHAR)
{
do Data = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(Data) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(Data), Zpl2ControlEntry))
{
if (CmdEntry->func() == _SUCCESS)
return TRUE;
}
}
// ^XA command can also be issued as a single ASCII control code STX
else if (Data == STX_CHAR)
{
if (FormatXA() == _SUCCESS) // Start Format
return TRUE;
}
// ^XZ command can also be issued as a single ASCII control code ETX
else if (Data == ETX_CHAR)
{
if (FormatXZ() == _SUCCESS) // End Format
return TRUE;
}
// ^FS command can also be issued as a single ASCII control code SI
else if (Data == SI_CHAR)
{
if (FormatFS() == _SUCCESS) // Field Separator
return TRUE;
}
if (!BackParsePool())
return TRUE;
return FALSE;
}
VOID CheckAutoFmt(VOID)
{
if (RunFile(DRAM_DEVICE, "AUTOEXEC.ZPL", 0, EndFormat) == _NULL)
if (RunFile(CARD_DEVICE, "AUTOEXEC.ZPL", 0, EndFormat) == _NULL)
if (RunFile(FLASH_DEVICE, "AUTOEXEC.ZPL", 0, EndFormat) == _NULL)
return;
StartFormat();
}
STATIC TASK(HeadClose, arg)
{
#if defined(MONO_LED)
StartPeriodFunc(FlashLED3);
#elif defined(POLY_LED)
// StartPeriodFunc(FlashRedLED); // ch_20211221
StartPeriodFunc(FlashBlueRedLED); // ch_20211221
#endif
#if defined(LCD_MODEL)
SetDisplayStatus(DIS_CARRIAGE_RECOVER);
#endif
StopKeyFunc();
while (!GetKey(FEED_KEY))
NutSleep(10);
StartKeyFunc(TRUE);
#if defined(LCD_MODEL)
ClrDisplayStatus(DIS_CARRIAGE_RECOVER);
#endif
#if defined(MONO_LED)
CancelPeriodFunc(FlashLED3);
ShowLED(HID_LED_IDLE, HID_LED_ON, HID_LED_OFF);
#elif defined(POLY_LED)
// CancelPeriodFunc(FlashRedLED); // ch_20211221
CancelPeriodFunc(FlashBlueRedLED); // ch_20211221
ShowLED(HID_LED_GREEN);
#endif
if (FeedCloseHead == 'F')
ControlPH();
if (FeedCloseHead == 'C')
ControlJC();
if (FeedCloseHead == 'L')
ControlJL();
if (arg) *(BOOL *)arg = FALSE;
TaskExit();
}
STATIC VOID Zpl2HeadClose(VOID)
{
STATIC BOOL created = FALSE;
if (FeedCloseHead != 'N' && GetJobState() == JOB_NULL && !created)
{
created = TRUE;
TaskCreate(HeadClose, &created, TASK_CAL_STACK);
}
}
VOID Zpl2MediaPowerUp(VOID)
{
if (FeedPowerUp == 'F')
ControlPH();
if (FeedPowerUp == 'C')
ControlJC();
if (FeedPowerUp == 'L')
ControlJL();
}
VOID Zpl2PrefixRule(CHAR *fmt)
{
CHAR prefix[16];
PrefixRule(prefix);
strcat(fmt, prefix);
}
VOID Zpl2SingleCharacterSet(BYTE Set)
{
STATIC BYTE SingleSet = 0;
SingleSet = Set;
SetCodePageCross(LANG_ZPL, &SingleSet, ZplRemapChar[Set]);
}
#endif
Zpl2.h ///
#ifndef ZPL2_H
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2_H
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/******************************************************************************
* *
* G L O B A L D E F I N E S *
* *
******************************************************************************/
/******************************************************************************
* *
* S T R U C T U R E D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - N O I N I T I A L I Z E R S *
* *
******************************************************************************/
#ifdef ZPL2_C
#define EXTERN
#else
#define EXTERN extern
#endif
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - I N I T I A L I Z E R S *
* *
******************************************************************************/
/******************************************************************************
* *
* F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
BOOL InitialZpl2(VOID);
BOOL ZebraSyntaxParsing(VOID);
VOID CheckAutoFmt(VOID);
VOID Zpl2MediaPowerUp(VOID);
VOID Zpl2PrefixRule(CHAR *);
VOID Zpl2SingleCharacterSet(BYTE);
#undef EXTERN
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif
Zpl2Control.c
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2CONTROL_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 *
* *
******************************************************************************/
#include <stdlib.h>
#include <string.h>
/******************************************************************************
* *
* 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 "XTimer.h"
#include "XFunction.h"
#include "..\Parser.h"
#include "..\ParserUtil.h"
#include "Zpl2Control.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(ZPL2)
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
*
* Function:
* LoadPrintControl
*
* Description:
*
*
* Input:
*
*
* Output:
* None.
*
******************************************************************************/
STATIC VOID LoadPrintControl(_ZebraCfg *pZebraCfg)
{
INT set, i;
// Power-up Initial
HeadWarn = 'n';
MediaDarkness = 0;
MeasureUnit = 'D';
ConvertDPI = 1;
MapClear = 'Y';
LabelMirror = 'N';
LabelOrientation = 'N';
CodeValidation = 'N';
AdvancedCounter1 = pPrintRec->DotMilage;
AdvancedCounter2 = pPrintRec->DotMilage;
CharacterSet = 0;
for (set = 0; set < sizeof(ZplRemapChar) / 256; set++)
{
for (i = 0; i < 256; i++)
ZplRemapChar[set][i] = (BYTE)i;
}
SetCodePageCross(LANG_ZPL, &CharacterSet, ZplRemapChar[CharacterSet]);
// Print Config
MediaTracking = ToMediaTracking(pPrintCfg->SensorMode);
MediaType = pPrintCfg->RibbonFlag ? 'T' : 'D';
LabelLength = (SHORT)pPrintCfg->fPaperSize;
// Zebra Config
EncodingFile.Device = pZebraCfg->EncodingDevice;
memcpy(EncodingFile.Name, pZebraCfg->EncodingName, 13);
MemoryAlias.B = pZebraCfg->MemoryAliasB;
MemoryAlias.E = pZebraCfg->MemoryAliasE;
MemoryAlias.R = pZebraCfg->MemoryAliasR;
MemoryAlias.A = pZebraCfg->MemoryAliasA;
DotsMillimeter = pZebraCfg->DotsMillimeter;
CaretChar = pZebraCfg->CaretChar;
TildeChar = pZebraCfg->TildeChar;
DelimiterChar = pZebraCfg->DelimiterChar;
MaxLabelLength = pZebraCfg->MaxLabelLength;
MaxLogPaperOut = pZebraCfg->MaxLogPaperOut;
MaxPhysPaperOut = pZebraCfg->MaxPhysPaperOut;
MaxRibbonOut = pZebraCfg->MaxRibbonOut;
AdjustPosition = pZebraCfg->AdjustPosition;
PrintDarkness = pZebraCfg->PrintDarkness;
PrintSpeed = pZebraCfg->PrintSpeed;
SlewSpeed = pZebraCfg->SlewSpeed;
BackfeedSpeed = pZebraCfg->BackfeedSpeed;
BackfeedSequence = pZebraCfg->BackfeedSequence;
PrintMode = pZebraCfg->PrintMode;
Prepeel = pZebraCfg->Prepeel;
FeedPowerUp = pZebraCfg->FeedPowerUp;
FeedCloseHead = pZebraCfg->FeedCloseHead;
AutoDetectType = pZebraCfg->AutoDetectType;
LabelHome.X = pZebraCfg->LabelHomeX;
LabelHome.Y = pZebraCfg->LabelHomeY;
LabelWidth = pZebraCfg->LabelWidth;
LabelShift = pZebraCfg->LabelShift;
LabelTop = pZebraCfg->LabelTop;
LabelReverse = pZebraCfg->LabelReverse;
}
STATIC VOID SavePrintControl(_ZebraCfg *pZebraCfg)
{
pZebraCfg->EncodingDevice = EncodingFile.Device;
memcpy(pZebraCfg->EncodingName, EncodingFile.Name, 13);
pZebraCfg->MemoryAliasB = MemoryAlias.B;
pZebraCfg->MemoryAliasE = MemoryAlias.E;
pZebraCfg->MemoryAliasR = MemoryAlias.R;
pZebraCfg->MemoryAliasA = MemoryAlias.A;
pZebraCfg->DotsMillimeter = DotsMillimeter;
pZebraCfg->CaretChar = CaretChar;
pZebraCfg->TildeChar = TildeChar;
pZebraCfg->DelimiterChar = DelimiterChar;
pZebraCfg->MaxLabelLength = MaxLabelLength;
pZebraCfg->MaxLogPaperOut = MaxLogPaperOut;
pZebraCfg->MaxPhysPaperOut = MaxPhysPaperOut;
pZebraCfg->MaxRibbonOut = MaxRibbonOut;
pZebraCfg->AdjustPosition = AdjustPosition;
pZebraCfg->PrintDarkness = PrintDarkness;
pZebraCfg->PrintSpeed = PrintSpeed;
pZebraCfg->SlewSpeed = SlewSpeed;
pZebraCfg->BackfeedSpeed = BackfeedSpeed;
pZebraCfg->BackfeedSequence = BackfeedSequence;
pZebraCfg->PrintMode = PrintMode;
pZebraCfg->Prepeel = Prepeel;
pZebraCfg->FeedPowerUp = FeedPowerUp;
pZebraCfg->FeedCloseHead = FeedCloseHead;
pZebraCfg->AutoDetectType = AutoDetectType;
pZebraCfg->LabelHomeX = LabelHome.X;
pZebraCfg->LabelHomeY = LabelHome.Y;
pZebraCfg->LabelWidth = LabelWidth;
pZebraCfg->LabelShift = LabelShift;
pZebraCfg->LabelTop = LabelTop;
pZebraCfg->LabelReverse = LabelReverse;
}
VOID ConfigurationUpdata(CHAR my_Active)
{
_ZebraCfg *pZebraCfg = GrabZebraConfig();
_ZebraCfg *pZebraDef = GrabZebraDefault();
if (my_Active == RELOAD_FACTORY_VALUES)
LoadPrintControl(pZebraDef);
else if (my_Active == RECALL_LAST_SAVED_VALUES)
LoadPrintControl(pZebraCfg);
else if (my_Active == SAVE_CURRENT_SETTINGS)
SavePrintControl(pZebraCfg);
}
VOID SaveEncoding(_ObjFile *pFile)
{
_ZebraCfg *pZebraCfg = GrabZebraConfig();
pZebraCfg->EncodingDevice = pFile->Device;
memcpy(pZebraCfg->EncodingName, pFile->Name, 13);
EncodingFile = *pFile;
}
BOOL SelectEncoding(_ObjFile *pFile)
{
STATIC USHORT *Table = _NULL;
_FileHandle *Handle;
LONG Length;
INT i;
if ((Handle = Fopen(ToFileDevice(pFile->Device), pFile->Name, "r")) != _NULL)
{
if (Table)
free(Table);
Length = FileLength(FileNo(Handle)) / 4 * 4;
if ((Table = malloc(Length)) != _NULL)
{
for (i = 0; i < Length / sizeof(USHORT); i++)
*(Table + i) = Fgetc(Handle) * 256 + Fgetc(Handle);
InstallEncodingTable(Table, Length);
}
Fclose(Handle);
return TRUE;
}
return FALSE;
}
VOID SetLabelLength(SHORT Length)
{
if (pPrintCfg->fPaperSize != (FLOAT)Length)
{
pPrintCfg->fPaperSize = (FLOAT)Length;
ReallocImageBuffer(&sImageBuffer, Length);
InitialCalibration();
}
}
VOID SetMediaTracking(SHORT Tracking)
{
_eSensorMode SensorMode = ToSensorMode(Tracking);
if (pPrintCfg->SensorMode != SensorMode)
{
if (SensorMode == CONTINUE_MODE_T)
DetectContinuousInten(pPrintCfg);
pPrintCfg->SensorMode = SensorMode;
}
}
VOID ProgrammablePause(VOID)
{
PrinterPause();
}
VOID PrintStart(VOID)
{
PrinterStart();
}
#endif
Zpl2Control.h //
#ifndef ZPL2CONTROL_H
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2CONTROL_H
/******************************************************************************
* *
* 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 "Zpl2Type.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/******************************************************************************
* *
* G L O B A L D E F I N E S *
* *
******************************************************************************/
#define RELOAD_FACTORY_VALUES 'F'
#define RECALL_LAST_SAVED_VALUES 'R'
#define SAVE_CURRENT_SETTINGS 'S'
/******************************************************************************
* *
* S T R U C T U R E D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - N O I N I T I A L I Z E R S *
* *
******************************************************************************/
#ifdef ZPL2CONTROL_C
#define EXTERN
#else
#define EXTERN extern
#endif
EXTERN CHAR CaretChar;
EXTERN CHAR TildeChar;
EXTERN CHAR DelimiterChar;
EXTERN BYTE CharacterSet;
EXTERN BYTE ZplRemapChar[37][256];
EXTERN _ObjFile EncodingFile;
EXTERN _MemoryAlias MemoryAlias;
EXTERN CHAR DotsMillimeter;
EXTERN CHAR MeasureUnit;
EXTERN SHORT ConvertDPI;
EXTERN CHAR CodeValidation;
EXTERN ULONG AdvancedCounter1;
EXTERN ULONG AdvancedCounter2;
EXTERN SHORT MaxLabelLength;
EXTERN SHORT MaxLogPaperOut;
EXTERN SHORT MaxPhysPaperOut;
EXTERN SHORT MaxRibbonOut;
EXTERN CHAR PrintSpeed;
EXTERN CHAR SlewSpeed;
EXTERN CHAR BackfeedSpeed;
EXTERN SHORT AdjustPosition;
EXTERN SHORT PrintDarkness;
EXTERN CHAR BackfeedSequence;
EXTERN CHAR PrintMode;
EXTERN CHAR Prepeel;
EXTERN CHAR HeadWarn;
//EXTERN _PrintCtrl PrintCtrl;
EXTERN CHAR FeedPowerUp;
EXTERN CHAR FeedCloseHead;
EXTERN CHAR AutoDetectType;
EXTERN CHAR MediaTracking;
EXTERN CHAR MediaType;
EXTERN SHORT MediaDarkness;
//EXTERN _Media Media;
EXTERN _Axis LabelHome;
EXTERN SHORT ContLabelLength;
EXTERN SHORT LabelLength;
EXTERN SHORT LabelWidth;
EXTERN SHORT LabelShift;
EXTERN SHORT LabelTop;
EXTERN CHAR LabelReverse;
EXTERN CHAR LabelMirror;
EXTERN CHAR LabelOrientation;
EXTERN CHAR MapClear;
//EXTERN _Label Label;
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - I N I T I A L I Z E R S *
* *
******************************************************************************/
/******************************************************************************
* *
* F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
VOID ConfigurationUpdata(CHAR);
VOID SaveEncoding(_ObjFile *);
BOOL SelectEncoding(_ObjFile *);
VOID SetLabelLength(SHORT);
VOID SetMediaTracking(SHORT);
VOID ProgrammablePause(VOID);
VOID PrintStart(VOID);
#undef EXTERN
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif
Zpl2Field.c //
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FIELD_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 *
* *
******************************************************************************/
#include <string.h>
/******************************************************************************
* *
* 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 "..\Parser.h"
#include "..\ParserUtil.h"
#include "Zpl2Image.h"
#include "Zpl2Format.h"
#include "Zpl2FieldData.h"
#include "Zpl2Object.h"
#include "Zpl2Control.h"
#include "Zpl2Field.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(ZPL2)
#define NUMBER_NOT_SPECIFIED -1
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
STATIC VOID FieldDefault(VOID);
STATIC VOID FieldNumber(VOID);
STATIC BOOL GiveFieldLink(_Field *);
STATIC _Field *TakeFieldLink(SHORT);
STATIC _FieldData *FieldAllocate(_Field *, _FieldData *);
STATIC VOID DoField(_Field *, _FieldData *);
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
*
* Function:
*
*
* Description:
*
*
* Input:
* None.
*
* Output:
* None.
*
******************************************************************************/
VOID InitialField(VOID)
{
Field.Number = NUMBER_NOT_SPECIFIED;
Field.Allocate = 0;
Field.Origin.X = 0;
Field.Origin.Y = 0;
Field.Block.Use = FALSE;
Field.Parameter.Direction = 'H';
Field.Parameter.CharacterGap = 0;
Field.Typeset = FALSE;
Field.Reverse = FALSE;
Field.FontSet = FALSE;
Field.DataType = FIELD_DATA;
Field.Serialization = SERIALIZATION_NULL;
strcpy(Field.Mask, "");
strcpy(Field.Increment, "");
Field.LeadingZero = 'N';
Field.HexIndicator = 0;
memset(Field.ClockIndicator, 0, sizeof(Field.ClockIndicator));
Field.DrawType = DRAW_NULL;
}
VOID InitialFieldDefault(VOID)
{
// Initial Value at power-up: A
FieldDef.Font.ID = 'A';
// Initial Value at power-up: 9
FieldDef.Font.Height = 0;
// Initial Value at power-up: 5 or last permanent saved value
FieldDef.Font.Width = 0;
// Initial Value at power-up: 2
FieldDef.Barcode.Width = 2;
// This parameter has no effect on fixed-ratio bar codes.
FieldDef.Barcode.Ratio = (FLOAT)3.0;
// Initial Value at power-up: 10
FieldDef.Barcode.Height = 10;
// Default Value: R
FieldDef.FontFile.Device = MemoryAlias.R;
// Default Value: if an invalid or no name is entered, the default set by ^CF is used.
// If no font has been specified in ^CF, font A is used.
strcpy(FieldDef.FontFile.Name, FontIdentifier(FieldDef.Font.ID)->Name);
FieldDef.Orientation = 'N';
}
VOID InitialFieldNumber(VOID)
{
INT i;
for (i = 0; i < sizeof(FieldLink) / sizeof(_Field); i++)
FieldLink[i].Number = NUMBER_NOT_SPECIFIED;
}
extern INT AAAAAAAAA;
VOID FieldSeparator(VOID)
{
if(AAAAAAAAA)
{
AAAAAAAAA = 0;
}
FieldDefault();
FieldNumber();
InitialField();
InitialFieldData();
}
STATIC VOID FieldDefault(VOID)
{
if (Field.DrawType == DRAW_NULL)
{
Field.DrawType = DRAW_FONT;
Field.Draw.Font.File = *FontIdentifier(FieldDef.Font.ID);
Field.Draw.Font.Orientation = FieldDef.Orientation;
Field.Draw.Font.Height = FieldDef.Font.Height;
Field.Draw.Font.Width = FieldDef.Font.Width;
}
}
STATIC VOID FieldNumber(VOID)//FieldSeparator
{
_Field *pField;
if (Field.Number != NUMBER_NOT_SPECIFIED &&
(Field.DrawType == DRAW_FONT || Field.DrawType == DRAW_BARCODE))
{
if (FieldData.Length)
{
if ((pField = TakeFieldLink(Field.Number)) != _NULL)
{
do DoField(pField, FieldAllocate(pField, &FieldData));
while ((pField = TakeFieldLink(Field.Number)) != _NULL);
}
else
DoField(&Field, &FieldData);
}
else
GiveFieldLink(&Field);
}
else
DoField(&Field, &FieldData);
}
STATIC BOOL GiveFieldLink(_Field *pField)
{
INT i;
for (i = 0; i < sizeof(FieldLink) / sizeof(_Field); i++)
{
if (FieldLink[i].Number == NUMBER_NOT_SPECIFIED)
{
FieldLink[i] = *pField;
return TRUE;
}
}
return FALSE;
}
STATIC _Field *TakeFieldLink(SHORT number)
{
INT i;
for (i = 0; i < sizeof(FieldLink) / sizeof(_Field); i++)
{
if (FieldLink[i].Number == number)
{
FieldLink[i].Number = NUMBER_NOT_SPECIFIED;
return &FieldLink[i];
}
}
return _NULL;
}
STATIC _FieldData *FieldAllocate(_Field *pField, _FieldData *pData)
{
STATIC _FieldData Data;
if (pField->Allocate)
{
Data = *pData;
if (pField->Allocate > Data.Length)
memset(&Data.Content[Data.Length], ' ', pField->Allocate - Data.Length);
Data.Length = pField->Allocate;
Data.Content[Data.Length] = '\0';
return &Data;
}
return pData;
}
STATIC VOID DoField(_Field *pField, _FieldData *pData)
{
_DrawArea sDrawArea = {{0,0},0,0};
Format.Print |= OutField(pField, pData, &sDrawArea);
if (pField->DrawType == DRAW_FONT || pField->DrawType == DRAW_BARCODE)
{
if (pField->Serialization != SERIALIZATION_NULL)
StoreSerialization(pField, pData, &sDrawArea);
else if (pField->DataType == FIELD_VARIABLE)
StoreVariableArea(&sDrawArea);
}
}
#endif
Zpl2Field.h ///
#ifndef ZPL2FIELD_H
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FIELD_H
/******************************************************************************
* *
* 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 "Zpl2Type.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/******************************************************************************
* *
* G L O B A L D E F I N E S *
* *
******************************************************************************/
/******************************************************************************
* *
* S T R U C T U R E D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - N O I N I T I A L I Z E R S *
* *
******************************************************************************/
#ifdef ZPL2FIELD_C
#define EXTERN
#else
#define EXTERN extern
#endif
// Initial Value at Power-up
EXTERN _FieldDefault FieldDef;
EXTERN _Field Field;
EXTERN _Field FieldLink[50];
EXTERN _Axis TypesetOrigin;
//EXTERN _Axis MultiOrigin[60];
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - I N I T I A L I Z E R S *
* *
******************************************************************************/
/******************************************************************************
* *
* F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
VOID InitialFormat(VOID);
VOID InitialFieldDefault(VOID);
VOID InitialFieldNumber(VOID);
VOID FieldSeparator(VOID);
#undef EXTERN
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif
Zpl2FieldData.c ///
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FIELDDATA_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 *
* *
******************************************************************************/
#include <ctype.h>
#include <string.h>
/******************************************************************************
* *
* 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 "..\Parser.h"
#include "..\ParserUtil.h"
#include "Zpl2Image.h"
#include "Zpl2FieldData.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(ZPL2)
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
#if defined(__HITACHI__)
#pragma section HeapArea
#endif
STATIC _Serialization Serial[20];
#if defined(__HITACHI__)
#pragma section
#endif
STATIC _DrawArea VarArea[50];
STATIC INT Carry;
/******************************************************************************
*
* Function:
*
*
* Description:
*
*
* Input:
* None.
*
* Output:
* None.
*
******************************************************************************/
VOID InitialFieldData(VOID)
{
FieldData.Length = 0;
strcpy(FieldData.Content, "");
}
VOID InitialSerialization(VOID)
{
INT i;
for (i = 0; i < sizeof(Serial) / sizeof(_Serialization); i++)
Serial[i].Use = FALSE;
}
VOID InitialVariableArea(VOID)
{
INT i;
for (i = 0; i < sizeof(VarArea) / sizeof(_DrawArea); i++)
{
VarArea[i].Origin.X = 0;
VarArea[i].Origin.Y = 0;
VarArea[i].Width = 0;
VarArea[i].Height = 0;
}
}
BOOL StoreSerialization(_Field *pField, _FieldData *pData, _DrawArea *pDrawArea)
{
INT i;
for (i = 0; i < sizeof(Serial) / sizeof(_Serialization); i++)
{
if (!Serial[i].Use)
{
Serial[i].Use = TRUE;
Serial[i].Field = *pField;
Serial[i].Data = *pData;
Serial[i].Area = *pDrawArea;
return TRUE;
}
}
return FALSE;
}
BOOL StoreVariableArea(_DrawArea *pDrawArea)
{
INT i;
for (i = 0; i < sizeof(VarArea) / sizeof(_DrawArea); i++)
{
if (VarArea[i].Width == 0 || VarArea[i].Height == 0)
{
VarArea[i] = *pDrawArea;
return TRUE;
}
}
return FALSE;
}
STATIC VOID EraseArea(_ImgBuf *pImgBuf, _DrawArea *pArea)
{
_BarAttr sBarAttr;
sBarAttr.iType = DRAW_ERASE;
sBarAttr.psImageBuffer = pImgBuf;
sBarAttr.sCoord.iX = pArea->Origin.X;
sBarAttr.sCoord.iY = pArea->Origin.Y;
sBarAttr.iWidth = pArea->Width;
sBarAttr.iHeight = pArea->Height;
DrawBar(&sBarAttr);
}
VOID EraseSerialization(_ImgBuf *pImgBuf, BOOL Adding)
{
INT i;
for (i = 0; i < sizeof(Serial) / sizeof(_Serialization); i++)
{
if (Serial[i].Use && Serial[i].Area.Width && Serial[i].Area.Height)
{
if (Serial[i].Field.DataType == FIELD_VARIABLE || Adding)
EraseArea(pImgBuf, &Serial[i].Area);
}
}
}
VOID EraseVariableArea(_ImgBuf *pImgBuf)
{
INT i;
for (i = 0; i < sizeof(VarArea) / sizeof(_DrawArea); i++)
if (VarArea[i].Width && VarArea[i].Height)
EraseArea(pImgBuf, &VarArea[i]);
}
STATIC INT Addometer(INT Mask, INT Augend, INT Addend, BOOL Sign)
{
// Mask String placeholders:
// D or d - Decimal numeric 0-9
// H or h - Hexadecimal 0-9 plus a-f or A-F
// O or o - Octal 0-7
// A or a - Alphabetic A-Z or a-z
// N or n - Alphanumeric 0-9 plus A-Z or a-z
// % - Ignore character or skip
if (toupper(Mask) == 'D' && isdigit(Augend))
{
if (!isdigit(Addend))
Addend = '0';
Addend -= '0';
if (Sign)
Addend = 0 - Addend;
Augend -= '0';
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 10) // to carry
{
Augend -= 10;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 10;
Carry -= 1;
}
Augend += '0';
}
if (Mask == 'H' && (isdigit(Augend) || (Augend >= 'A' && Augend <= 'F')))
{
if (!isdigit(Addend) && (Addend < 'A' || Addend > 'F'))
Addend = '0';
Addend -= (isdigit(Addend) ? '0' : 'A' - 10);
if (Sign)
Addend = 0 - Addend;
Augend -= (isdigit(Augend) ? '0' : 'A' - 10);
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 16) // to carry
{
Augend -= 16;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 16;
Carry -= 1;
}
Augend += (Augend < 10 ? '0' : 'A' - 10);
}
if (Mask == 'h' && (isdigit(Augend) || (Augend >= 'a' && Augend <= 'f')))
{
if (!isdigit(Addend) && (Addend < 'a' || Addend > 'f'))
Addend = '0';
Addend -= (isdigit(Addend) ? '0' : 'a' - 10);
if (Sign)
Addend = 0 - Addend;
Augend -= (isdigit(Augend) ? '0' : 'a' - 10);
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 16) // to carry
{
Augend -= 16;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 16;
Carry -= 1;
}
Augend += (Augend < 10 ? '0' : 'a' - 10);
}
if (toupper(Mask) == 'O' && Augend >= '0' && Augend <= '7')
{
if (Addend < '0' || Addend > '7')
Addend = '0';
Addend -= '0';
if (Sign)
Addend = 0 - Addend;
Augend -= '0';
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 8) // to carry
{
Augend -= 8;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 8;
Carry -= 1;
}
Augend += '0';
}
if (Mask == 'A' && isupper(Augend))
{
if (!isupper(Addend))
Addend = 'A';
Addend -= 'A';
if (Sign)
Addend = 0 - Addend;
Augend -= 'A';
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 26) // to carry
{
Augend -= 26;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 26;
Carry -= 1;
}
Augend += 'A';
}
if (Mask == 'a' && islower(Augend))
{
if (!islower(Addend))
Addend = 'a';
Addend -= 'a';
if (Sign)
Addend = 0 - Addend;
Augend -= 'a';
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 26) // to carry
{
Augend -= 26;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 26;
Carry -= 1;
}
Augend += 'a';
}
if (Mask == 'N' && (isdigit(Augend) || isupper(Augend)))
{
if (!isdigit(Addend) && !isupper(Addend))
Addend = '0';
Addend -= (isdigit(Addend) ? '0' : 'A' - 10);
if (Sign)
Addend = 0 - Addend;
Augend -= (isdigit(Augend) ? '0' : 'A' - 10);
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 36) // to carry
{
Augend -= 36;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 36;
Carry -= 1;
}
Augend += (Augend < 10 ? '0' : 'A' - 10);
}
if (Mask == 'n' && (isdigit(Augend) || islower(Augend)))
{
if (!isdigit(Addend) && !islower(Addend))
Addend = '0';
Addend -= (isdigit(Addend) ? '0' : 'a' - 10);
if (Sign)
Addend = 0 - Addend;
Augend -= (isdigit(Augend) ? '0' : 'a' - 10);
Augend += Addend + Carry;
Carry = 0;
if (Augend >= 36) // to carry
{
Augend -= 36;
Carry += 1;
}
if (Augend < 0) // to borrow
{
Augend += 36;
Carry -= 1;
}
Augend += (Augend < 10 ? '0' : 'a' - 10);
}
return Augend;
}
STATIC VOID StepSerializationField(_Serialization *pSerial)
{
BOOL Sign = FALSE;
CHAR *pStep;
CHAR *pMask;
CHAR *pCont;
INT StepLen;
INT ContLen;
StepLen = strlen(pSerial->Field.Increment);
ContLen = strlen(pSerial->Field.Mask);
ContLen = MIN(ContLen, pSerial->Data.Length);
pStep = pSerial->Field.Increment + StepLen - 1;
pMask = pSerial->Field.Mask + ContLen - 1;
pCont = pSerial->Data.Content + ContLen - 1;
if (pSerial->Field.Increment[0] == '-')
Sign = TRUE;
Carry = 0;
// The default value is equivalent to a decimal value of one.
if (StepLen == 0)
Carry = 1;
while (ContLen && (StepLen || Carry))
{
*pCont = Addometer(*pMask, *pCont, (StepLen ? *pStep : 0), Sign);
if (StepLen)
{
pStep -= 1;
StepLen -= 1;
}
pCont -= 1;
pMask -= 1;
ContLen -= 1;
}
}
STATIC VOID StepSerializationData(_Serialization *pSerial)
{
BOOL Sign = FALSE;
CHAR StepBuf[13] = "1"; // Default Value: 1
CHAR *pStep;
CHAR *pCont;
INT StepLen;
INT ContLen;
// A maximum of 12 of the right-most integers are subject to indexing.
StepLen = 0;
pStep = pSerial->Field.Increment;
while (*pStep != '\0')
{
// To indicate a decrement value, precede the value with a minus (-) sign.
if (*pStep == '-' && StepLen == 0)
Sign = TRUE;
if (isdigit(*pStep) && StepLen < 12) // 12-digit maximum
StepBuf[StepLen++] = *pStep;
else if (StepLen > 0)
break;
pStep += 1;
}
if (StepLen == 0)
StepLen = 1;
StepBuf[StepLen] = '\0';
// The first integer found when scanning from right to left
// starts the indexing portion of the data field.
ContLen = pSerial->Data.Length;
pCont = pSerial->Data.Content + ContLen - 1;
while (ContLen)
{
if (isdigit(*pCont))
break;
pCont -= 1;
ContLen -= 1;
}
// The data is scanned, character by character, from right to left until
// a numeric character is encountered.
// Serialization takes place using the value of the first number found.
StepLen = 0;
while (ContLen - StepLen)
{
// If the alphanumeric field to be indexed ends with an alpha character.
if (!isdigit(*(pCont - StepLen)))
break;
StepLen += 1;
}
if (StepLen > strlen(StepBuf))
StepLen = strlen(StepBuf);
pStep = StepBuf + StepLen - 1;
Carry = 0;
while (ContLen && (StepLen || Carry))
{
// If the alphanumeric field to be indexed ends with an alpha character.
if (!isdigit(*pCont))
break;
// D - Decimal numeric 0-9
*pCont = Addometer('D', *pCont, (StepLen ? *pStep : 0), Sign);
if (StepLen)
{
pStep -= 1;
StepLen -= 1;
}
pCont -= 1;
ContLen -= 1;
}
}
STATIC VOID StepSerialization(_Serialization *pSerial)
{
if (pSerial->Field.Serialization == SERIALIZATION_FIELD)
StepSerializationField(pSerial);
if (pSerial->Field.Serialization == SERIALIZATION_DATA)
StepSerializationData(pSerial);
}
VOID DoSerialization(VOID)
{
INT i;
for (i = 0; i < sizeof(Serial) / sizeof(_Serialization); i++)
{
if (Serial[i].Use)
{
StepSerialization(&Serial[i]);
OutField(&Serial[i].Field, &Serial[i].Data, &Serial[i].Area);
}
}
}
BOOL IsSerialization(VOID)
{
INT i;
for (i = 0; i < sizeof(Serial) / sizeof(_Serialization); i++)
if (Serial[i].Use)
return TRUE;
return FALSE;
}
#endif
Zpl2FieldData.h //
#ifndef ZPL2FIELDDATA_H
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FIELDDATA_H
/******************************************************************************
* *
* 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 "Zpl2Type.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/******************************************************************************
* *
* G L O B A L D E F I N E S *
* *
******************************************************************************/
#define FIELD_DATA 'D'
#define FIELD_VARIABLE 'V'
#define SERIALIZATION_NULL 0
#define SERIALIZATION_FIELD 'F'
#define SERIALIZATION_DATA 'N'
/******************************************************************************
* *
* S T R U C T U R E D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - N O I N I T I A L I Z E R S *
* *
******************************************************************************/
#ifdef ZPL2FIELDDATA_C
#define EXTERN
#else
#define EXTERN extern
#endif
EXTERN _FieldData FieldData;
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - I N I T I A L I Z E R S *
* *
******************************************************************************/
/******************************************************************************
* *
* F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
VOID InitialFieldData(VOID);
VOID InitialSerialization(VOID);
VOID InitialVariableArea(VOID);
BOOL StoreSerialization(_Field *, _FieldData *, _DrawArea *);
BOOL StoreVariableArea(_DrawArea *);
VOID EraseSerialization(_ImgBuf *, BOOL);
VOID EraseVariableArea(_ImgBuf *);
VOID DoSerialization(VOID);
BOOL IsSerialization(VOID);
#undef EXTERN
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif
Zpl2Format.c ///
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FORMAT_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 *
* *
******************************************************************************/
#include <stdlib.h>
#include <string.h>
/******************************************************************************
* *
* 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 "XFunction.h"
#include "..\Parser.h"
#include "..\ParserUtil.h"
#include "Zpl2Util.h"
#include "Zpl2Field.h"
#include "Zpl2FieldData.h"
#include "Zpl2Object.h"
#include "Zpl2Control.h"
#include "Zpl2Format.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(ZPL2)
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
*
* Function:
*
*
* Description:
*
*
* Input:
* None.
*
* Output:
* None.
*
******************************************************************************/
VOID InitialFormat(VOID)
{
Format.Print = FALSE;
Format.SuppressBack = FALSE;
Format.Quantity = 1; // Default Value: 1
Format.PauseCut = 0; // Default Value: 0(no pause)
Format.Replicate = 0; // Default Value: 0(no replicate)
Format.Override = 'N'; // Default Value: N
Format.SaveType = SAVE_NULL;
TypesetOrigin.X = 0;
TypesetOrigin.Y = 0;
ContLabelLength = LabelLength;
}
VOID StartFormat(VOID)
{
FormatStart = TRUE;
if (Whether(MapClear))
ClearImageBuffer(&sImageBuffer);
InitialFieldNumber();
InitialVariableArea();
InitialSerialization();
InitialFormat();
}
VOID EndFormat(VOID)
{
FormatStart = FALSE;
FieldSeparator();
if (Format.Print)
{
if (Format.SaveType == SAVE_PRINT || Format.SaveType == SAVE_IMAGE)
ImageSave(&Format.ImageFile, &sImageBuffer, LabelWidth);
if (Format.SaveType != SAVE_IMAGE)
PrintFormat();
// for byte order mark (BOM)
SetCodePageCross(LANG_ZPL, &CharacterSet, ZplRemapChar[CharacterSet]);
}
}
BOOL EnlargeFormat(_PrintCfg *cfg, _ImgBuf *dstimg, _ImgBuf *srcimg)
{
INT offset = (XAxis(0) - LabelHome.X) / 8;
INT n;
if (cfg->SensorMode == CONTINUE_MODE_T)
{
cfg->fPaperSize *= 2;
dstimg->iHeight *= 2;
}
if (IsEnoughImageBuffer(srcimg, dstimg))
{
while (!AllocImageBuffer(dstimg))
NutSleep(10);
memset(dstimg->pBuffer, 0, offset);
for (n = 0; n < (dstimg->iHeight - 1) / 2; n++)
{
BYTE *src = srcimg->pBuffer + offset + srcimg->iByteWidth * n;
BYTE *dst = dstimg->pBuffer + offset + dstimg->iByteWidth * n * 2;
LineMultiple(src, dst, dstimg->iWidth / 2, 2, 2, 0);
}
dstimg->iFirstLine *= 2;
dstimg->iLastLine = (dstimg->iLastLine + 1) * 2 - 1;
if (dstimg->iLastLine > dstimg->iHeight - 3)
dstimg->iLastLine = dstimg->iHeight - 3;
return TRUE;
}
return FALSE;
}
VOID PrintFormat(VOID)
{
_ePrintOutMode PrintOut = ToPrintOut(PrintMode, Format.SuppressBack);
_PrintCfg FmtCfg = *pPrintCfg;
ULONG BatchNo = 0;
LONG PrintQuantity, PrintReplicate;
INT PrintLength, DspTotal, DspBase;
ToPrintConfig(&FmtCfg);
PrintLength = FmtCfg.fPaperSize;
if (FmtCfg.SensorMode == GAP_MODE) // this should fix the problem of coordinate origin in web sensing
PrintLength += FmtCfg.fGapSize - (3 * MM_DOT);
// FIXME: coordinate origin is wrong in ^POI and ^MNM
PrintQuantity = Format.Quantity;
PrintReplicate = Format.Replicate ? Format.Replicate : 1;
// if don't have serialization
if (!IsSerialization())
PrintReplicate = PrintQuantity;
DspTotal = PrintQuantity;
while (PrintQuantity > 0)
{
_ImgBuf FmtImg = sImageBuffer;
BOOL Enlarge = FALSE;
if (PrintReplicate > PrintQuantity)
PrintReplicate = PrintQuantity;
// cutter batch
if (PrintOut == CUTTER_MODE && Format.PauseCut == 0)
{
if (PrintQuantity == PrintReplicate) // last batch
{
FmtCfg.PrintOutMode = CUTTER_MODE;
FmtCfg.CutterPieces = PrintReplicate;
}
else
FmtCfg.PrintOutMode = OFF_MODE;
}
if (IsEnlargeFormat(DotsMillimeter))
Enlarge = EnlargeFormat(&FmtCfg, &FmtImg, &sImageBuffer);
//sysprintf("PB_7\n"); //PC打印不进来
DspBase = PrintQuantity - PrintReplicate;
BatchNo = PrintBatch(BatchNo, PrintReplicate, &FmtCfg, &FmtImg, FALSE, PrintLength, DspTotal, DspBase, _NULL);
if (BatchNo == 0 && Enlarge == TRUE)
FreeImageBuffer(&FmtImg);
if (BatchNo == 0)
break;
PrintQuantity -= PrintReplicate;
pPrintRec->LabelMilage += PrintReplicate;
if (Enlarge == FALSE)
{
while (!AllocImageBuffer(&sImageBuffer))
NutSleep(10);
}
if (!Whether(MapClear) || PrintQuantity > 0)
{
if (Enlarge == FALSE)
memcpy(sImageBuffer.pBuffer, FmtImg.pBuffer, sImageBuffer.iByteWidth * sImageBuffer.iHeight);
EraseSerialization(&sImageBuffer, PrintQuantity > 0);
}
if (PrintQuantity <= 0)
break;
DoSerialization();
}
if (!Whether(MapClear))
EraseVariableArea(&sImageBuffer);
}
#endif
Zpl2Format.h //
#ifndef ZPL2FORMAT_H
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FORMAT_H
/******************************************************************************
* *
* 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 "Zpl2Type.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/******************************************************************************
* *
* G L O B A L D E F I N E S *
* *
******************************************************************************/
/******************************************************************************
* *
* S T R U C T U R E D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - N O I N I T I A L I Z E R S *
* *
******************************************************************************/
#ifdef ZPL2FORMAT_C
#define EXTERN
#else
#define EXTERN extern
#endif
EXTERN BOOL FormatStart;
EXTERN _Format Format;
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - I N I T I A L I Z E R S *
* *
******************************************************************************/
/******************************************************************************
* *
* F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
VOID InitialField(VOID);
VOID StartFormat(VOID);
VOID EndFormat(VOID);
VOID PrintFormat(VOID);
#undef EXTERN
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif
Zpl2Func.h /
#ifndef ZPL2FUNC_H
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FUNC_H
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include "Zpl2Type.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/******************************************************************************
* *
* G L O B A L D E F I N E S *
* *
******************************************************************************/
/******************************************************************************
* *
* S T R U C T U R E D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - N O I N I T I A L I Z E R S *
* *
******************************************************************************/
#ifdef ZPL2FUNCFMT_C
#define EXTERN
#else
#define EXTERN extern
#endif
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - I N I T I A L I Z E R S *
* *
******************************************************************************/
extern _CmdEntry EntryFormatB[];
extern _CmdEntry EntryFormatC[];
extern _CmdEntry EntryFormatD[];
extern _CmdEntry EntryFormatE[];
extern _CmdEntry EntryFormatF[];
extern _CmdEntry EntryFormatG[];
extern _CmdEntry EntryFormatH[];
extern _CmdEntry EntryFormatI[];
extern _CmdEntry EntryFormatJ[];
extern _CmdEntry EntryFormatK[];
extern _CmdEntry EntryFormatL[];
extern _CmdEntry EntryFormatM[];
extern _CmdEntry EntryFormatN[];
extern _CmdEntry EntryFormatP[];
extern _CmdEntry EntryFormatS[];
extern _CmdEntry EntryFormatT[];
extern _CmdEntry EntryFormatW[];
extern _CmdEntry EntryFormatX[];
extern _CmdEntry EntryFormatZ[];
extern _CmdEntry EntryControlC[];
extern _CmdEntry EntryControlD[];
extern _CmdEntry EntryControlE[];
extern _CmdEntry EntryControlH[];
extern _CmdEntry EntryControlJ[];
extern _CmdEntry EntryControlK[];
extern _CmdEntry EntryControlN[];
extern _CmdEntry EntryControlP[];
extern _CmdEntry EntryControlR[];
extern _CmdEntry EntryControlS[];
extern _CmdEntry EntryControlT[];
extern _CmdEntry EntryControlW[];
/******************************************************************************
* *
* F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
INT FormatA(VOID);
INT FormatB(VOID);
INT FormatB0(VOID);
INT FormatB1(VOID);
INT FormatB2(VOID);
INT FormatB3(VOID);
INT FormatB4(VOID);
INT FormatB5(VOID);
INT FormatB7(VOID);
INT FormatB8(VOID);
INT FormatB9(VOID);
INT FormatBA(VOID);
INT FormatBB(VOID);
INT FormatBC(VOID);
INT FormatBD(VOID);
INT FormatBE(VOID);
INT FormatBF(VOID);
INT FormatBI(VOID);
INT FormatBJ(VOID);
INT FormatBK(VOID);
INT FormatBL(VOID);
INT FormatBM(VOID);
INT FormatBP(VOID);
INT FormatBQ(VOID);
INT FormatBR(VOID);
INT FormatBS(VOID);
INT FormatBT(VOID);
INT FormatBU(VOID);
INT FormatBX(VOID);
INT FormatBY(VOID);
INT FormatBZ(VOID);
INT FormatC(VOID);
INT FormatCC(VOID);
INT FormatCD(VOID);
INT FormatCF(VOID);
INT FormatCI(VOID);
INT FormatCM(VOID);
INT FormatCO(VOID);
INT FormatCT(VOID);
INT FormatCV(VOID);
INT FormatCW(VOID);
INT FormatD(VOID);
INT FormatDF(VOID);
INT FormatE(VOID);
INT FormatEF(VOID);
INT FormatEG(VOID);
INT FormatF(VOID);
INT FormatFA(VOID);
INT FormatFB(VOID);
INT FormatFC(VOID);
INT FormatFD(VOID);
INT FormatFH(VOID);
INT FormatFM(VOID);
INT FormatFN(VOID);
INT FormatFO(VOID);
INT FormatFP(VOID);
INT FormatFR(VOID);
INT FormatFS(VOID);
INT FormatFT(VOID);
INT FormatFV(VOID);
INT FormatFW(VOID);
INT FormatFX(VOID);
INT FormatG(VOID);
INT FormatGB(VOID);
INT FormatGC(VOID);
INT FormatGD(VOID);
INT FormatGE(VOID);
INT FormatGF(VOID);
INT FormatGS(VOID);
INT FormatH(VOID);
INT FormatHF(VOID);
INT FormatHG(VOID);
INT FormatHH(VOID);
INT FormatHW(VOID);
INT FormatHY(VOID);
INT FormatHZ(VOID);
INT FormatI(VOID);
INT FormatID(VOID);
INT FormatIL(VOID);
INT FormatIM(VOID);
INT FormatIS(VOID);
INT FormatJ(VOID);
INT FormatJB(VOID);
INT FormatJI(VOID);
INT FormatJJ(VOID);
INT FormatJM(VOID);
INT FormatJS(VOID);
INT FormatJT(VOID);
INT FormatJU(VOID);
INT FormatJW(VOID);
INT FormatJZ(VOID);
INT FormatK(VOID);
INT FormatKD(VOID);
INT FormatKL(VOID);
INT FormatKN(VOID);
INT FormatKP(VOID);
INT FormatL(VOID);
INT FormatLH(VOID);
INT FormatLL(VOID);
INT FormatLR(VOID);
INT FormatLS(VOID);
INT FormatLT(VOID);
INT FormatM(VOID);
INT FormatMC(VOID);
INT FormatMD(VOID);
INT FormatMF(VOID);
INT FormatML(VOID);
INT FormatMM(VOID);
INT FormatMN(VOID);
INT FormatMP(VOID);
INT FormatMT(VOID);
INT FormatMU(VOID);
INT FormatMW(VOID);
INT FormatN(VOID);
INT FormatNI(VOID);
INT FormatNS(VOID);
INT FormatP(VOID);
INT FormatPF(VOID);
INT FormatPH(VOID);
INT FormatPM(VOID);
INT FormatPO(VOID);
INT FormatPP(VOID);
INT FormatPQ(VOID);
INT FormatPR(VOID);
INT FormatPW(VOID);
INT FormatS(VOID);
INT FormatSC(VOID);
INT FormatSE(VOID);
INT FormatSF(VOID);
INT FormatSL(VOID);
INT FormatSN(VOID);
INT FormatSO(VOID);
INT FormatSP(VOID);
INT FormatSQ(VOID);
INT FormatSR(VOID);
INT FormatSS(VOID);
INT FormatST(VOID);
INT FormatSX(VOID);
INT FormatSZ(VOID);
INT FormatT(VOID);
INT FormatTO(VOID);
INT FormatW(VOID);
INT FormatWD(VOID);
INT FormatX(VOID);
INT FormatXA(VOID);
INT FormatXB(VOID);
INT FormatXF(VOID);
INT FormatXG(VOID);
INT FormatXZ(VOID);
INT FormatZ(VOID);
INT FormatZZ(VOID);
INT ControlC(VOID);
INT ControlCC(VOID);
INT ControlCD(VOID);
INT ControlCT(VOID);
INT ControlD(VOID);
INT ControlDB(VOID);
INT ControlDE(VOID);
INT ControlDG(VOID);
INT ControlDN(VOID);
INT ControlDS(VOID);
INT ControlDT(VOID);
INT ControlDU(VOID);
INT ControlDY(VOID);
INT ControlE(VOID);
INT ControlEF(VOID);
INT ControlEG(VOID);
INT ControlH(VOID);
INT ControlHB(VOID);
INT ControlHD(VOID);
INT ControlHI(VOID);
INT ControlHM(VOID);
INT ControlHS(VOID);
INT ControlHU(VOID);
INT ControlJ(VOID);
INT ControlJA(VOID);
INT ControlJB(VOID);
INT ControlJC(VOID);
INT ControlJD(VOID);
INT ControlJE(VOID);
INT ControlJF(VOID);
INT ControlJG(VOID);
INT ControlJI(VOID);
INT ControlJL(VOID);
INT ControlJN(VOID);
INT ControlJO(VOID);
INT ControlJP(VOID);
INT ControlJQ(VOID);
INT ControlJR(VOID);
INT ControlJS(VOID);
INT ControlJX(VOID);
INT ControlK(VOID);
INT ControlKB(VOID);
INT ControlN(VOID);
INT ControlNC(VOID);
INT ControlNR(VOID);
INT ControlNT(VOID);
INT ControlP(VOID);
INT ControlPH(VOID);
INT ControlPP(VOID);
INT ControlPR(VOID);
INT ControlPS(VOID);
INT ControlR(VOID);
INT ControlRO(VOID);
INT ControlS(VOID);
INT ControlSD(VOID);
INT ControlT(VOID);
INT ControlTA(VOID);
INT ControlW(VOID);
INT ControlWC(VOID);
#undef EXTERN
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif
Zpl2FuncCtrl.c ///
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define ZPL2FUNCCTRL_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 *
* *
******************************************************************************/
#include <ctype.h>
#include <string.h>
/******************************************************************************
* *
* 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 "XComm.h"
#include "XFileSys.h"
#include "XDisplay.h"
#include "XFunction.h"
#include "..\Parser.h"
#include "..\ParserUtil.h"
#include "Zpl2Util.h"
#include "Zpl2Object.h"
#include "Zpl2Control.h"
#include "Zpl2Report.h"
#include "Zpl2Func.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(ZPL2)
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
_CmdEntry EntryControlC[] =
{
{"C", ControlCC},
{"D", ControlCD},
{"T", ControlCT},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlD[] =
{
{"B", ControlDB},
{"E", ControlDE},
{"G", ControlDG},
{"N", ControlDN},
{"S", ControlDS},
{"T", ControlDT},
{"U", ControlDU},
{"Y", ControlDY},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlE[] =
{
{"F", ControlEF},
{"G", ControlEG},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlH[] =
{
{"B", ControlHB},
{"D", ControlHD},
{"I", ControlHI},
{"M", ControlHM},
{"S", ControlHS},
{"U", ControlHU},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlJ[] =
{
{"A", ControlJA},
{"B", ControlJB},
{"C", ControlJC},
{"D", ControlJD},
{"E", ControlJE},
{"F", ControlJF},
{"G", ControlJG},
{"I", ControlJI},
{"L", ControlJL},
{"N", ControlJN},
{"O", ControlJO},
{"P", ControlJP},
{"Q", ControlJQ},
{"R", ControlJR},
{"S", ControlJS},
{"X", ControlJX},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlK[] =
{
{"B", ControlKB},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlN[] =
{
{"C", ControlNC},
{"R", ControlNR},
{"T", ControlNT},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlP[] =
{
{"H", ControlPH},
{"P", ControlPP},
{"R", ControlPR},
{"S", ControlPS},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlR[] =
{
{"O", ControlRO},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlS[] =
{
{"D", ControlSD},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlT[] =
{
{"A", ControlTA},
{(CHAR *)_NULL, _NULL}
};
_CmdEntry EntryControlW[] =
{
{"C", ControlWC},
{(CHAR *)_NULL, _NULL}
};
/******************************************************************************
* *
* 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 *
* *
******************************************************************************/
/******************************************************************************
*
******************************************************************************/
INT ControlC(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlC))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ^CC ~~CC
* Change Carets
*
* Description:
* The ^CC and ~~CC commands is used to change the format command prefix.
* The default prefix is the caret(^).
*
* Format:
* ^CCx or ~~CCx
*
* Parameters:
* x = caret character change
*
******************************************************************************/
INT ControlCC(VOID)
{
// Accepted Values: any ASCII character
// Default Value: a parameter is required. If a parameter is not entered,
// the next character received is the new prefix character.
CaretChar = ZebraNextByte(NEXT_ANY);
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ^CD ~~CD
* Change Delimiter
*
* Description:
* The ^CD and ~~CD commands is used to change the delimiter character. This
* character is used to separate parameter values associated with several
* ZPL II commands. The default delimiter is a comma(,).
*
* Format:
* ^CDa or ~~CDa
*
* Parameters:
* a = delimiter character change
*
******************************************************************************/
INT ControlCD(VOID)
{
// Accepted Values: any ASCII character
// Default Value: a parameter is required. If a parameter is not entered,
// the next character received is the new prefix character.
DelimiterChar = ZebraNextByte(NEXT_ANY);
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ^CT ~~CT
* Change Tilde
*
* Description:
* The ^CT and ~~CT commands is used to change the control command prefix.
* The default prefix is the tilde(~~).
*
* Format:
* ^CTa or ~~CTa
*
* Parameters:
* a = change control command character
*
******************************************************************************/
INT ControlCT(VOID)
{
// Accepted Values: any ASCII character
// Default Value: a parameter is required. If a parameter is not entered,
// the next character received is the new control character.
TildeChar = ZebraNextByte(NEXT_ANY);
return _SUCCESS;
}
/******************************************************************************
*
******************************************************************************/
INT ControlD(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlD))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~DB
* Download Bitmap Font
*
* Description:
*
* Format:
* ~~DBd:o,x,a,h,w,base,space,#char,c,data
*
* Parameters:
* d = device to dtore font
* o = name of font
* x = extension
* a = orientation of native font
* h = maximum height of cell(in dots)
* w = maximum width of cell(in dots)
* base = dots from top of cell to character baseline
* space = width of space or non-existent characters
* #char = number of characters in font
* c = copyright holder
* data = structured ASCII data that defines each character in the font
* #xxxx.h.w.x.y.i.data
* #xxxx = character code
* h = bitmap height(in dot rows)
* w = bitmap width(in dot rows)
* x = x-offset(in dots)
* y = y-offset(in dots)
* i = typesetting motion displacement(width including intercharacter
* gap of a particular character in the font)
* data = hexadecimal bitmap description
*
******************************************************************************/
INT ControlDB(VOID)
{
INT state;
_ObjFile File;
CHAR Orientation = 'N'; // Fixed Value: normal
SHORT MaxHeight = 0; // Default Value: a value must be specified
SHORT MaxWidth = 0; // Default Value: a value must be specified
SHORT BaseLine = 0; // Default Value: a value must be specified
SHORT SpaceWidth = 0; // Default Value: a value must be specified
SHORT CharNum = 0; // Default Value: a value must be specified
_FieldData CopyrightHolder;
// Default Value: a value must be specified
CopyrightHolder.Length = 0;
strcpy(CopyrightHolder.Content, "");
File.Device = MemoryAlias.R; // Default Value: R
strcpy(File.Name, "UNKNOWN.FNT"); // Default Value: UNKNOWN.FNT
while (1)
{
// Accepted Values: R:, E:, B: and A:
if (state = ParamDevice(&File.Device))
break;
// Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .FNT
if (state = ParamName(File.Name, 1, "FNT"))
break;
// Fixed Value: normal
if (state = ParamChar(&Orientation, "N", TRUE))
break;
// Accepted Values: 0 to 32000
if (state = ParamNumber(&MaxHeight, PARAM_NUMBER_SHORT, 0, 32000))
break;
// Accepted Values: 0 to 32000
if (state = ParamNumber(&MaxWidth, PARAM_NUMBER_SHORT, 0, 32000))
break;
// Accepted Values: 0 to 32000
if (state = ParamNumber(&BaseLine, PARAM_NUMBER_SHORT, 0, 32000))
break;
// Accepted Values: 0 to 32000
if (state = ParamNumber(&SpaceWidth, PARAM_NUMBER_SHORT, 0, 32000))
break;
// Accepted Values: 1 to 256
if (state = ParamNumber(&CharNum, PARAM_NUMBER_SHORT, 1, 256))
break;
// Accepted Values: 1 to 63 alphanumeric characters
if (state = ParamData(&CopyrightHolder, "", "\x0\x0\x0", FALSE))
break;
break;
}
if (state == PARAM_NULL)
{
if (MaxHeight && MaxWidth && BaseLine && SpaceWidth && CharNum)
DownloadBitmapFont(&File, MaxHeight, MaxWidth, BaseLine, SpaceWidth, CharNum);
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~DE
* Download Encoding
*
* Description:
*
* Format:
* ~~DEd:o.x,s,data
*
* Parameters:
* d = location of table
* o = name of table
* x = extension
* s = table size
* data = data string
*
******************************************************************************/
INT ControlDE(VOID)
{
INT state;
_ObjFile File;
LONG TableSize = 0; // not specified
File.Device = MemoryAlias.R; // Default Value: R
strcpy(File.Name, "UNKNOWN.DAT"); // Default Value: UNKNOWN.DAT
while (1)
{
// Accepted Values: R:, E:, B: and A:
if (state = ParamDevice(&File.Device))
break;
// Accepted Values: any valid name, up to 8 characters, extension fixed value: .DAT
if (state = ParamName(File.Name, 1, "DAT"))
break;
// Accepted Values: ...
if (state = ParamNumber(&TableSize, PARAM_NUMBER_LONG, 1, 16 * 1024 * 1024))
break;
break;
}
if (state == PARAM_NULL)
{
if (TableSize)
{
DownloadObjects(&File, TableSize, OBJECT_ASCII);
if (SelectEncoding(&File))
SaveEncoding(&File);
}
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~DG
* Download Graphic
*
* Description:
*
* Format:
* ~~DGd:o.x,t,w,data
*
* Parameters:
* d = device to store image
* o = image name
* x = extension
* t = total number of bytes in graphic
* w = number of bytes per row
* data = ASCII hexadecimal string defines image
*
******************************************************************************/
INT ControlDG(VOID)
{
INT state;
_ObjFile File;
LONG TotalByte = 0; // not specified
SHORT RowByte = 0; // not specified
File.Device = MemoryAlias.R; // Default Value: R
strcpy(File.Name, "UNKNOWN.GRF"); // Default Value: UNKNOWN.GRF
while (1)
{
// Accepted Values: R:, E:, B: and A:
if (state = ParamDevice(&File.Device))
break;
// Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .GRF
if (state = ParamName(File.Name, 1, "GRF"))
break;
// Accepted Values: ...
if (state = ParamNumber(&TotalByte, PARAM_NUMBER_LONG, 1, IMAGE_BUFFER_SIZE))
break;
// Accepted Values: ...
if (state = ParamNumber(&RowByte, PARAM_NUMBER_SHORT, 1, 32000))
break;
break;
}
if (state == PARAM_NULL)
{
if (TotalByte && RowByte)
DownloadGraphic(&File, TotalByte, RowByte);
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~DN
* Abort Download Graphic
*
* Description:
*
* Format:
* ~~DN
*
* Parameters:
*
******************************************************************************/
INT ControlDN(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~DS
* Download Scalable Font
*
* Description:
* The ~~DS command is used to set the printer to receive a downloadable
* scalable font and defines the size of the font in bytes.
*
* Format:
* ~~DSd:o.x,s,data
*
* Parameters:
* d = device to store image
* o = image name
* x = extension
* s = size of font in bytes
* data = ASCII hexadecimal string that defines font
*
******************************************************************************/
INT ControlDS(VOID)
{
INT state;
_ObjFile File;
LONG FontSize = 0; // not specified
File.Device = MemoryAlias.R; // Default Value: R
strcpy(File.Name, "UNKNOWN.FNT"); // Default Value: UNKNOWN.FNT
while (1)
{
// Accepted Values: R:, E:, B: and A:
if (state = ParamDevice(&File.Device))
break;
// Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .FNT
if (state = ParamName(File.Name, 1, "FNT"))
break;
// Accepted Values: ...
if (state = ParamNumber(&FontSize, PARAM_NUMBER_LONG, 1, 16 * 1024 * 1024))
break;
break;
}
if (state == PARAM_NULL)
{
if (FontSize)
{
// Not supported this format
}
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~DT
* Download Bounded TrueType Font
*
* Description:
* Use ZTools to convert a TrueType font to a Zebra-downloadable format. that
* has less than 256 characters in it.
*
* Format:
* ~~DTd:o.x,s,data
*
* Parameters:
* d = font location
* o = font name
* x = extension
* s = font size
* data = data string
*
******************************************************************************/
INT ControlDT(VOID)
{
INT state;
_ObjFile File;
LONG FontSize = 0; // not specified
File.Device = MemoryAlias.R; // Default Value: R
strcpy(File.Name, "UNKNOWN.FNT"); // Default Value: UNKNOWN.FNT
while (1)
{
// Accepted Values: R:, E:, B: and A:
if (state = ParamDevice(&File.Device))
break;
// Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .FNT
if (state = ParamName(File.Name, 1, "FNT"))
break;
// Accepted Values: ...
if (state = ParamNumber(&FontSize, PARAM_NUMBER_LONG, 1, 16 * 1024 * 1024))
break;
break;
}
if (state == PARAM_NULL)
{
if (FontSize)
{
// Not supported this format
}
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~DU
* Download Unbounded TrueType Font
*
* Description:
* Some international fonts, such as Asian fonts, have more than
* 256 printable characters. These fonts are supported as large TrueType
* fonts and are downloaded to the printer with the ~~DU command.
*
* Format:
* ~~DUd:o.x,s,data
*
* Parameters:
* d = font location
* o = font name
* x = extension
* s = font size
* data = data string
*
******************************************************************************/
INT ControlDU(VOID)
{
INT state;
_ObjFile File;
LONG FontSize = 0; // not specified
File.Device = MemoryAlias.R; // Default Value: R
strcpy(File.Name, "UNKNOWN.FNT"); // Default Value: UNKNOWN.FNT
while (1)
{
// Accepted Values: R:, E:, B: and A:
if (state = ParamDevice(&File.Device))
break;
// Accepted Values: 1 to 8 alphanumeric characters, extension fixed value: .FNT
if (state = ParamName(File.Name, 1, "FNT"))
break;
// Accepted Values: ...
if (state = ParamNumber(&FontSize, PARAM_NUMBER_LONG, 1, 16 * 1024 * 1024))
break;
break;
}
if (state == PARAM_NULL)
{
if (FontSize)
{
strcpy(strchr(File.Name, '.'), ".TTF");
DownloadObjects(&File, FontSize, OBJECT_ASCII);
}
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~DY
* Download Objects
*
* Description:
* The ~~DY command downloads to the printer graphic objects or fonts in any
* supported format. This command can be used in place of ~~DG for more saving
* and loading options.
*
* Format:
* ~~DYf,b,x,t,w,data
*
* Parameters:
* d = file location
* f = font name
* b = format downloaded in data field
* x = extension of stored file
* t = total number of bytes in file
* w = total number of bytes per row
* data = data
*
******************************************************************************/
INT ControlDY(VOID)
{
INT state;
_ObjFile File;
CHAR Format = _NULL; // a value must be specified
_FieldData Extension;
LONG TotalByte = 0; // not specified
SHORT RowByte = 0; // not specified
// a value other than the accepted values defaults to .GRF
Extension.Length = 1;
strcpy(Extension.Content, "G");
File.Device = MemoryAlias.R; // Default Value: R
strcpy(File.Name, "UNKNOWN.GRF"); // Default Value: UNKNOWN
while (1)
{
// Accepted Values: R:, E:, B: and A:
if (state = ParamDevice(&File.Device))
break;
// Accepted Values: 1 to 8 alphanumeric characters
if (state = ParamName(File.Name, 1, "ext"))
break;
// Accepted Values: A, B, C or P
if (state = ParamChar(&Format, "ABCP", TRUE))
break;
// Accepted Values: B(BMP), E(TTE), G(GRF), P(PNG), T(TTF), X(PCX), NRD, PAC, C, F or H
if (state = ParamData(&Extension, "", "\x0\x0\x0", FALSE))
break;
// Accepted Values: ...
if (state = ParamNumber(&TotalByte, PARAM_NUMBER_LONG, 1, 16 * 1024 * 1024))
break;
// Accepted Values: ...
if (state = ParamNumber(&RowByte, PARAM_NUMBER_SHORT, 1, TPH_WIDTH_BYTE))
break;
break;
}
if (state == PARAM_NULL)
{
if (strcmp(Extension.Content, "B") == 0) // bitmap
strcpy(strchr(File.Name, '.'), ".BMP");
if (strcmp(Extension.Content, "E") == 0) // TrueType Extension (.TTE)
strcpy(strchr(File.Name, '.'), ".TTE");
if (strcmp(Extension.Content, "G") == 0) // raw bitmap (.GRF)
strcpy(strchr(File.Name, '.'), ".GRF");
if (strcmp(Extension.Content, "P") == 0) // store as compressed (.PNG)
strcpy(strchr(File.Name, '.'), ".PNG");
if (strcmp(Extension.Content, "T") == 0) // TrueType (.TTF) or OpenType (.OTF)
strcpy(strchr(File.Name, '.'), ".TTF");
if (strcmp(Extension.Content, "X") == 0) // Paintbrush (.PCX)
strcpy(strchr(File.Name, '.'), ".PCX");
if (strcmp(Extension.Content, "NRD") == 0) // Non Readable File (.NRD)
strcpy(strchr(File.Name, '.'), ".NRD");
if (strcmp(Extension.Content, "PAC") == 0) // Protected Access Credential (.PAC)
strcpy(strchr(File.Name, '.'), ".PAC");
if (strcmp(Extension.Content, "C") == 0) // User defined menu file (WML)
strcpy(strchr(File.Name, '.'), ".WML");
if (strcmp(Extension.Content, "F") == 0) // User defined webpage file (HTM)
strcpy(strchr(File.Name, '.'), ".HTM");
if (strcmp(Extension.Content, "H") == 0) // Printer feedback file (GET)
strcpy(strchr(File.Name, '.'), ".GET");
// ASCII hexadecimal or ZB64
if (Format == 'A' || Format == 'P')
{
if (strcmp(Extension.Content, "G") == 0) // raw bitmap (.GRF)
{
if (TotalByte && RowByte)
DownloadGraphic(&File, TotalByte, RowByte);
}
else if (TotalByte)
{
DownloadObjects(&File, TotalByte, OBJECT_ASCII);
}
}
// binary
if (Format == 'B' || Format == 'C')
{
if (TotalByte)
DownloadObjects(&File, TotalByte, OBJECT_BINARY);
}
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
******************************************************************************/
INT ControlE(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlE))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~EF
* Erase Stored Formats
*
* Description:
* The ~~EF command erase all stored formats.
*
* Format:
* ~~EF
*
* Parameters:
*
******************************************************************************/
INT ControlEF(VOID)
{
ObjectDelete('R', "*.ZPL");
ObjectDelete('B', "*.ZPL");
ObjectDelete('E', "*.ZPL");
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~EG
* Erase Download Graphics
*
* Description:
*
* Format:
* ~~EG
*
* Parameters:
*
******************************************************************************/
INT ControlEG(VOID)
{
ObjectDelete('R', "*.GRF");
ObjectDelete('B', "*.GRF");
ObjectDelete('E', "*.GRF");
return _SUCCESS;
}
/******************************************************************************
*
******************************************************************************/
INT ControlH(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlH))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~HB
* Battery Status
*
* Description:
* When the ~~HB command is sent to the printer, a data string is sent back
* to the host. The string starts with an <STX> control code sequence and
* is terminated by an <ETX><CR><LF> control code sequence.
*
* Format:
* ~~HB
*
* Parameters:
*
******************************************************************************/
INT ControlHB(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~HD
* Head Temperature Information
*
* Description:
*
* Format:
* ~~HD
*
* Parameters:
*
******************************************************************************/
INT ControlHD(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~HI
* Host Identification
*
* Description:
*
* Format:
* ~~HI
*
* Parameters:
*
******************************************************************************/
INT ControlHI(VOID)
{
HostIdentification();
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~HM
* Host RAM Status
*
* Description:
*
* Format:
* ~~HM
*
* Parameters:
*
******************************************************************************/
INT ControlHM(VOID)
{
HostRamStatus();
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~HS
* Host Status Return
*
* Description:
*
* Format:
* ~~HS
*
* Parameters:
*
******************************************************************************/
INT ControlHS(VOID)
{
HostStatusReturn();
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~HU
* Return ZebraNet AlertConfiguration
*
* Description:
*
* Format:
* ~~HU
*
* Parameters:
*
******************************************************************************/
INT ControlHU(VOID)
{
SendPrintf("\x02\x03");
return _SUCCESS;
}
/******************************************************************************
*
******************************************************************************/
INT ControlJ(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlJ))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~JA
* Cancel All
*
* Description:
*
* Format:
* ~~JA
*
* Parameters:
*
******************************************************************************/
INT ControlJA(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JB
* Reset Optional Memory
*
* Description:
*
* Format:
* ~~JB
*
* Parameters:
*
******************************************************************************/
INT ControlJB(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JC
* Set Media Sensor Calibration
*
* Description:
*
* Format:
* ~~JC
*
* Parameters:
*
******************************************************************************/
INT ControlJC(VOID)
{
#ifdef DEBUG_PRNT
sysprintf("Enter ControlJC()...\n"); // ch_20211208
#endif
#if defined(LCD_MODEL)
SetDisplayStatus(DIS_CALIBRATION);
#endif
#if defined(TTP243PP_PCB)
if (pPrintCfg->SensorMode == GAP_MODE)
DetectSensorInten(pPrintCfg, TRUE, FALSE, 0, 0);
#elif defined(DIVIDE_INTENSION)
if (pPrintCfg->SensorMode == GAP_MODE || pPrintCfg->SensorMode == BLINE_MODE)
DetectSensorInten(pPrintCfg, TRUE, Whether(AutoDetectType), 0, 0);
#elif defined(PWM_INTENSION)
if (pPrintCfg->SensorMode == GAP_MODE)
{
if (DetectGapInten(pPrintCfg, FALSE))
DetectLabelSize(pPrintCfg, 2, TEAR_MODE);
}
#endif
MediaTracking = ToMediaTracking(pPrintCfg->SensorMode);
LabelLength = (SHORT)pPrintCfg->fPaperSize;
#if defined(LCD_MODEL)
ClrDisplayStatus(DIS_CALIBRATION);
#endif
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JD
* Enable Communications Diagnostics
*
* Description:
*
* Format:
* ~~JD
*
* Parameters:
*
******************************************************************************/
INT ControlJD(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JE
* Disable Diagnostics
*
* Description:
*
* Format:
* ~~JE
*
* Parameters:
*
******************************************************************************/
INT ControlJE(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JF
* Set Battery Condition
*
* Description:
*
* Format:
* ~~JFp
*
* Parameters:
* p = pause on low voltage
*
******************************************************************************/
INT ControlJF(VOID)
{
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~JG
* Graphing Sensor Calibration
*
* Description:
*
* Format:
* ~~JG
*
* Parameters:
*
******************************************************************************/
INT ControlJG(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JI
* Start ZBI(Zebra BASIC Interpreter)
*
* Description:
*
* Format:
* ~~JI
*
* Parameters:
*
******************************************************************************/
INT ControlJI(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JL
* Set Label Length
*
* Description:
*
* Format:
* ~~JL
*
* Parameters:
*
******************************************************************************/
INT ControlJL(VOID)
{
if (DetectLabelSize(pPrintCfg, 2, TEAR_MODE))
LabelLength = (SHORT)pPrintCfg->fPaperSize;
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JN
* Head Test Fatal
*
* Description:
*
* Format:
* ~~JN
*
* Parameters:
*
******************************************************************************/
INT ControlJN(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JO
* Head Test Non fatal
*
* Description:
*
* Format:
* ~~JO
*
* Parameters:
*
******************************************************************************/
INT ControlJO(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JP
* Pause and Cancel Format
*
* Description:
*
* Format:
* ~~JP
*
* Parameters:
*
******************************************************************************/
INT ControlJP(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JQ
* Terminate Zebra BASIC Interpreter
*
* Description:
*
* Format:
* ~~JQ
*
* Parameters:
*
******************************************************************************/
INT ControlJQ(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JR
* Power On Reset
*
* Description:
*
* Format:
* ~~JR
*
* Parameters:
*
******************************************************************************/
INT ControlJR(VOID)
{
PrinterReboot();
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~JS
* Change Backfeed Sequence
*
* Description:
*
* Format:
* ~~JSb
*
* Parameters:
* b = backfeed order in relation to printing
*
******************************************************************************/
INT ControlJS(VOID)
{
INT state;
CHAR Backfeed = 'N'; // Default Value: N
while (1)
{
// Accepted Values: A, B, N, O or 10 to 90
if (state = ParamChar(&Backfeed, "ABNO", TRUE))
break;
state = ParamEnd();
break;
}
if (state == PARAM_SUCCESS)
{
BackfeedSequence = Backfeed;
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~JX
* Cancel Current Partially Input Format
*
* Description:
*
* Format:
* ~~JX
*
* Parameters:
*
******************************************************************************/
INT ControlJX(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
******************************************************************************/
INT ControlK(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlK))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~KB
* Kill Battery(Battery Discharge Mode)
*
* Description:
*
* Format:
* ~~KB
*
* Parameters:
*
******************************************************************************/
INT ControlKB(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
******************************************************************************/
INT ControlN(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlN))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~NC
* Network Connect
*
* Description:
*
* Format:
* ~~NC###
*
* Parameters:
* ### = network ID number assigned(must be a three-digit entry)
*
******************************************************************************/
INT ControlNC(VOID)
{
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~NR
* Set All Network Printers Transparent
*
* Description:
*
* Format:
* ~~NR
*
* Parameters:
*
******************************************************************************/
INT ControlNR(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~NT
* Set Currently Connected Printer Transparent
*
* Description:
*
* Format:
* ~~NT
*
* Parameters:
*
******************************************************************************/
INT ControlNT(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
******************************************************************************/
INT ControlP(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlP))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~PH
* Slew to Home Position
*
* Description:
*
* Format:
* ~~PH
*
* Parameters:
*
******************************************************************************/
INT ControlPH(VOID)
{
_PrintCfg HomeCfg = *pPrintCfg;
ToPrintConfig(&HomeCfg);
FeedBatch(1, &HomeCfg, TRUE, _NULL);
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~PP
* Programmable Pause
*
* Description:
*
* Format:
* ~~PP
*
* Parameters:
*
******************************************************************************/
INT ControlPP(VOID)
{
ProgrammablePause();
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~PR
* Applicator Reprint
*
* Description:
*
* Format:
* ~~PR
*
* Parameters:
*
******************************************************************************/
INT ControlPR(VOID)
{
return _SUCCESS;
}
/******************************************************************************
*
* ZPL II Commands ~~PS
* Print Start
*
* Description:
*
* Format:
* ~~PS
*
* Parameters:
*
******************************************************************************/
INT ControlPS(VOID)
{
PrintStart();
return _SUCCESS;
}
/******************************************************************************
*
******************************************************************************/
INT ControlR(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlR))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~RO
* Reset Advanced Counter
*
* Description:
*
* Format:
* ~~ROc
*
* Parameters:
* c = counter number
*
******************************************************************************/
INT ControlRO(VOID)
{
INT state;
// Default Values: a value must be specified or the command is ignored
SHORT number = 0;
while (1)
{
// Accepted Values: 1 or 2
if (state = ParamNumber(&number, PARAM_NUMBER_SHORT, 1, 2))
break;
state = ParamEnd();
break;
}
if (state == PARAM_SUCCESS)
{
if (number == 1)
AdvancedCounter1 = pPrintRec->DotMilage;
if (number == 2)
AdvancedCounter2 = pPrintRec->DotMilage;
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
******************************************************************************/
INT ControlS(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlS))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~SD
* Set Darkness
*
* Description:
*
* Format:
* ~~SD##
*
* Parameters:
* ## = desired darkness setting(two-digit number)
*
******************************************************************************/
INT ControlSD(VOID)
{
INT state;
// Default Values: last permanently saved value
SHORT Darkness = PrintDarkness;
while (1)
{
// Accepted Values: 00 to 30
if (state = ParamNumber(&Darkness, PARAM_NUMBER_SHORT, 0, 30))
break;
state = ParamEnd();
break;
}
if (state == PARAM_SUCCESS)
{
PrintDarkness = Darkness;
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
******************************************************************************/
INT ControlT(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlT))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~TA
* Tear-off Adjust Position
*
* Description:
*
* Format:
* ~~TA###
*
* Parameters:
* ### = change in media rest position
*
******************************************************************************/
INT ControlTA(VOID)
{
INT state;
// Default Values: last permanent saved value
SHORT Position = AdjustPosition;
while (1)
{
// Accepted Values: -120 to 120
if (state = ParamNumber(&Position, PARAM_NUMBER_SHORT, -120, 120))
break;
state = ParamEnd();
break;
}
if (state == PARAM_SUCCESS)
{
AdjustPosition = Position;
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
******************************************************************************/
INT ControlW(VOID)
{
_CmdEntry *CmdEntry;
CHAR cmd;
do cmd = ZebraNextByte(NEXT_PARAMETER);
while (CheckSeparate(cmd) == SEP_LINEFEED);
if (CmdEntry = CheckSingleCommand(toupper(cmd), EntryControlW))
{
if (CmdEntry->func() == _SUCCESS)
return _SUCCESS;
}
return _ERROR;
}
/******************************************************************************
*
* ZPL II Commands ~~WC
* Print Configuration Label
*
* Description:
*
* Format:
* ~~WC
*
* Parameters:
*
******************************************************************************/
INT ControlWC(VOID)
{
ConfigLabel(OUTPUT_LABEL);
return _SUCCESS;
}
#endif