
/********************************************************************************
* File : ZebraDllWin32.h
* Copyright 2014-2015, Raytrex Technology Co., Ltd.	All Rights Reserved.
*
* A Zebra DLL header file, APIs allow application communicating with 
* Zebra capture-card through USB interface.
*
* Author: T.J.Hsu				
* Date: 2014.03.20
* To use, modify, reproduce, and distribute this file is strictly forbidden
* without the prior written permission of Raytrex Technology Co., Ltd.		
********************************************************************************/
#ifndef __ZebraDllWin32_h__
#define __ZebraDllWin32_h__

#include "mipiCntrlDef.h"

typedef  void(*LOG_HOOK_FUNC)(int hZhandle, char *pszLogMsg, unsigned long logCbArg);
typedef  int		__HZHANDLE__;
typedef struct
{
	int				nZebraBoardId;			// set in dip-switch or port - id when without dip-switch on carrier board (<0 port and locked)
	int				nZebraType;				// Zebra4=0, Zebra5=1, ...
	int				nZebraStatus;			// __Zebra_Open_usable__(1), __Zebra_NotYet_Init__(0), __Zebra_InValid__(-1), __Zebra_Removed__(-2)
} __ZEBRA_BOARD_INFO__, *__PZEBRA_BOARD_INFO__;


#define WM_MIPI_DEVICEARRIVAL			WM_USER+1			// zebra USB device connected to PC
#define WM_MIPI_DEVICEREMOVECOMPLETE	WM_USER+2			// zebra USB device dis-connected to PC
#define WM_MIPI_PROGRESS_MONITOR		WM_USER+3

/*
InitMipiUsbNotifyWin - enable an message call back to monitor USB connect/disconnect 
		conditon.
		
hWndApp: A window handle to received the call back message:
			WM_MIPI_DEVICEARRIVAL or WM_MIPI_DEVICEREMOVECOMPLETE received by the window that hWndApp assigned.
idThrdHandle: A thread id to received the call back message.
			WM_MIPI_DEVICEARRIVAL or WM_MIPI_DEVICEREMOVECOMPLETE received by this thread that idThrdHandle assigned.
return 1: succeed,
			 0: fail.
 */
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int InitMipiUsbNotifyWin(HWND hWndApp, DWORD idThrdHandle);


/*
StopMipiUsbNotifyWin - turn off the USB connecting monitor that enabled by InitMipiUsbNotifyWin.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
void StopMipiUsbNotifyWin(void);

/*
lookingViewableZebras - looking for all viewable Zebra on PC and setup Zebra internal information.
return how many zebra found in this PC.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int lookingViewableZebras(void);



/*
freeZebrasInfoListQueue - free all viewable Zebra information that built by lookingViewableZebras().
return how many zebra found in this PC.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
void freeZebrasInfoListQueue(void);



/*
ZebraCardNumber - report all viewable Zebras count that has found by lookingViewableZebras().
return how many zebra found in this PC.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int ZebraCardNumber(void);

/*
getZebraBoardInfo - return assigned Zebra info.
return zebra info structure.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
__PZEBRA_BOARD_INFO__ getZebraBoardInfo(__HZHANDLE__ hZhandle, TCHAR **pUsbPortName);

/*
QueryZebraAppState - return zebra application running or stop status.
return  
		-1: cann't transfer command to Zebra
		-2: USB can't return data to indicate this application state
		-3: USB driver is ready, but application isn't start
		-4: Zebra handle illegal
		1 :  zebra application has attached on zebra USB.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int QueryZebraAppState(__HZHANDLE__ hZhandle);



#define __USB_HANDLE_NOT_INIT__				-20
#define __USB_HANDLE_NOT_FOUND__			-21
#define __USB_DRV_OK_APP_NOT_READY__	-22
/*
bInitUsbDevice - open Zebra USB device to set/get Zebra setting or get picture from Zebra.
return	-1: can't open this device
		-2: can't get USB descriptor.
		-3: can't retrive mipi pipi (end points)
		-4: can't get USB i2c interface.
		-5: can't retrive i2c pipi.
		-6: can't get USB uart interface.
		-7: can't retrive uart pipi.
		-8: can't find zebra from assigned board id
		-9: locked by other process
		__USB_DRV_OK_APP_NOT_READY__
			: USB driver ready, but applcation isn't ready.
		0, 1, ... : hZhandle
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
__HZHANDLE__ bInitUsbDevice(int nZebraIndexInQueue, __HZHANDLE__ *phZhandle);

/*
CloseUsbDevice - close Zebra USB device that enabled by bInitUsbDevice.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
void CloseUsbDevice(__HZHANDLE__ hZhandle);



/*
getActivePortNname - when Zebra connected to PC, report which USB port connected it.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
TCHAR *getActivePortNname(__HZHANDLE__ hZhandle, int *nPortNumber);



/*
qureyZebraTestStepCount - get the test step's count that has downloaded to Zebra card.
return 
	-1: error zebra handle
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int qureyZebraTestStepCount(__HZHANDLE__ hZhandle);


#define __OPT_STREAMING_OFF__		0		// a picture captured by mipi when a KickoffRunStep called. 
#define __OPT_STREAMING_ON__		1		// pictures captured by mipi after a KickoffRunStep called.
/*
KickoffRunStep - run a test step that has downloaded on Zebra.

  iRunId - Test step id (register file id); that base 0.
  ExAct  - reserve for future
  nOption- __OPT_STREAMING_OFF__ or __OPT_STREAMING_ON__

  return USB send status, TRUE succeeds; else fail.
  
  A run state would be got after this API, but without image data been return; 
  image is gotten by “GrabImageRequest” API.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
BOOL KickoffRunStep(__HZHANDLE__ hZhandle, int iRunId, int ExAct, int nOption);



/*
getRunStepstate - polling just run test-step snapping picture status. 
									called after one of KickoffRunStep/ RunStepByAliasName/ RunRegisterFile/ RunTestStepFile function.

 pRunStepState - a pointer of SRUNSTEPSTATE structure to report just run step result.
	.runResultState - executed run-step statue
	.resultType - one of __noMoreData__, __SnapPicture__, and __AppendData__
	  union:
		.snapCnt - snap picture's count when .resultType is __SnapPicture__
		.pSnaPicSiz - every picture size.

		.appDataLen - a append user data length when .resultType is __AppendData__
		.appendBuffer - a append user data buffer, maximun 255.

return get status, TRUE succeeds; else fail.

- if .runResultState reports "__Sta_step_snapping__", it implies pictures are snapping now.
- virtual code as:  

  if (.runResultState == __Sta_step_succeed__)
  {
  	if (.resultType == __AppendData__)	// only test data, no snapping images
  	{
  		// handle text data ....
  	}
  	else if (.resultType == __SnapPicture__)
  	{
  		// data image data has ready,
  		// 
  		// call "GrabImageRequest" then "getPicture2File" or "getPicture2Buffer" to received data
  	}
  	else
  	{
  		
  	}
  }
  else if (.runResultState == __Sta_step_snapping__)
  {
  	if (.resultType == __AppendData__ && .appDataLen == 2)
  	{
  		.appendBuffer[0] :: how many needs to snap
  		.appendBuffer[1] :: how many pictures has snapped
  		.......
  	}
  	else
  	{
  		// other errors ...
  	}
  }
  else if (.runResultState == __Sta_None_Imgage__)
	{
		// handle none image ....
	}
	else if (.runResultState == __Sta_Err_I2cWrite__)
	{
		// read/write register i2c error ...
	}
	else if (.runResultState == __Sta_Invalid__)
	{
		// handle  ....
	}
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getRunStepstate(__HZHANDLE__ hZhandle, PSRUNSTEPSTATE pRunStepState);



/*
GrabImageRequest - issue a fetching image command to Zebra; the images could be a previous snapped;
							then next function 'getPicture2File' or 'getPicture2Buffer' could get the image data.
				           
 imgStartIndx - Which index would be start getting (base 0).
 imgEndIndx -   ending index that is last getting.
 imgGotOpCode - one of getting image operation; it could be __Grab_opt_noneOperation__, __Grab_opt_ImageAvg__, ...
 bWaitSnapped - when run step is snapping to wait it completed then report grabs image.

return get status, TRUE succeeds; else fail.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int GrabImageRequest(__HZHANDLE__ hZhandle, short imgStartIndx, short imgEndIndx, unsigned char imgGotOpCode, unsigned char bWaitSnapped);





#define __ColorBarCmp_Success__			0
#define __ColarBarCmp_Fail__			1		// colar isn't same
#define __ColarBarCmp_NoColarBar__		2		// snapped color bark fail
/*
CompareColorBarInZebra - issue a compare color-bar with image command to Zebra; 
	a just snapped image is to compare with default a color-bar.

return compared result.
	__USB_HANDLE_NOT_FOUND__						--- for Zebra not found
	__Zebra_WritePipeFail__/__Zebra_ReadPipeFail__  --- USB read/write error report
	__Zebra_ErrCmdResult__							--- ilegal command report
	__ColorBarCmp_Success__, __ColarBarCmp_Fail__, __ColarBarCmp_NoColarBar__ are report compare state
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int CompareColorBarInZebra(__HZHANDLE__ hZhandle);

/*
resetZebraFromApp - reset zebra from zebra application.

	resultState - return this reset command status from device 

	return	-1, 0: USB fail, can't send reset command.
			1 : command send succeed.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int resetZebraFromApp(__HZHANDLE__ hZhandle, int *resultState);




/*
resetZebraByUSBDev - reset zebra from zebra USB device layer.

*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
void resetZebraByUSBDev(__HZHANDLE__ hZhandle);



#define  __Zebra_Open_usable__		2	// a Zebra open by me and usable now
#define  __Zebra_Open_DrvNoApp__	1	// a Zebra open but application (sensor) not ready
#define  __Zebra_NotYet_Init__		0	// doesn't init Zebra or a new valid Zebra insert to USB hub-port
#define  __Zebra_InValid__			-1	// No valid Zebra or they have locked by other applications
#define  __Zebra_Removed__			-2	// that open Zebra has removed by user
#define  __Zebra_WritePipeFail__	-3	// Can't write
#define  __Zebra_ReadPipeFail__		-4	// Can't read
/*
getZebraStatus - return zebra application status.

presultStatus - a pointer of SZEBRASTATUS to report got application status.
 .zebraState - zebra application status.

return	-4, -3, ..., 0: USB fail condition, can't send reset command.
		1 : command send succeed.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getZebraStatus(__HZHANDLE__ hZhandle, PSZEBRASTATUS presultStatus);



/*
getZebraSWVersion - return zebra application software version.

psZebraVersion - a pointer of SZEBRAVERSION to report software version
  .zebraMajorVer - 
  .zebraMinorVer - 
  .zebraBuildNumber -
  .zebraRevisionNumber -

return	-1, 0: USB fail, can't send reset command.
	    1 : command send succeed.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getZebraSWVersion(__HZHANDLE__ hZhandle, PSZEBRAVERSION psZebraVersion);



/*
Zebra test step setting is consisted by a test configuration file and some test step files. 
Test step setting could be downloaded to Zebra application then tester host could run it of later. 
The configuration file is a text file,  that includes all test-step files (register file) name with text string; 
test step files (register-files) are text files also; that includes specified key-word to assign I2C read/write register, data, 
clock setting, reset pin condition...

for example:
The user selects a test step confguration that named "RTXCaptureTestSteps.ZebraCfg"; 
API "LoadRegisterFiles" parses this file and gets all test-step files name that would be downloaded to Zebra.  
This "LoadRegisterFiles"  also open these test-step files and then downloads their setting content to Zebra.
*/


/*
LoadRegisterFiles - download a test setting to Zebra.
	Function get these download files name from configuration file then download them to Zebra. 
	
pRegFilesDir - a file name (configuration file) that registers all test steps files;
							when this arg is NULL, function downloads all files that found by SearchingRegisterFiles(). 
							This condition is used in script operation.
log_cbFunc	 - a call back function used to report register(test step) file name that has been downloaded to Zebra.	
LogCbArg – A argument from application passes to callback function, that could be any meaning value by application.

return 	__USB_HANDLE_NOT_FOUND__ --- hZhandle error
				0;						
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int LoadRegisterFiles(__HZHANDLE__ hZhandle, char *pRegFilesDir, LOG_HOOK_FUNC log_cbFunc, unsigned long logCbArg);



/*
SearchingRegisterFiles - Collect all being loaded test step file (register file) names that is used in a test script.
	
pScriptName - a file name that points to a test script.
log_cbFunc  - a call back function used to report register(test step) file name that has been found in script.
LogCbArg – A argument from application passes to callback function, that could be any meaning value by application.

return -1: Can't open script file 
					 - if this function searching a open script file; please make sure script file sharable open to read.
			 n : count of found test steps (register files).
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int SearchingRegisterFiles(__HZHANDLE__ hZhandle, char *pScriptName, LOG_HOOK_FUNC log_cbFunc, unsigned long logCbArg);


/*
getCaptureCardTestProcedures - get the test setting from Zebra application and save it
	as a configure file and test step files.
	
szGotSettingName - user assigned this test set name, to save the test setting, API appends "SysCfg.got.ZebraCfg" as it configuration file.
									 and appends "Step%03d.got.txt" as test step file names.
pCardName - card name information in test set configure and step file.
pSensorName - capture sensor information in test set configure and step file.
pSWVersion - current software version in test set configure and step file.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getCaptureCardTestProcedures(__HZHANDLE__ hZhandle, char *szGotSettingName, char *pCardName, char *pSensorName, char *pSWVersion);


/*
createCaptureTestingTemplate - to create test set template(test configure and test step files) in local directory.

pCardName - card name information in test set configure and step file.
pSensorName - capture sensor information in test set configure and step file.
pSWVersion - current software version in test set configure and step file.
pTstSetName - test setting name for to be created, API appends "SysCfg.Tmp.ZebraCfg" as it configuration file.
							and appends "Step%03d.Tmp.txt" as test step file names.
testSteps - how many test steps in this test set.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
void createCaptureTestingTemplate(char *pCardName, char *pSensorName, char *pSWVersion, char *pTstSetName, int testSteps, ...);


/*
getPicture2File - get a picture data from Zebra application and save it to file; this function is call after GrabImageRequest().
pictureFileName - save name.
errCode	- when image is snapping and report some error code; that is one of __Error_None__, __Error_No_image__, __Error_snapping__
return -1: can't save to file.
	   -2: can't read picture from USB.
		0: succeed.		
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getPicture2File(__HZHANDLE__ hZhandle, char *pictureFileName, UCHAR *errCode);



/*
getPicture2Buffer - Get a picture data from Zebra application; this function is call after GrabImageRequest().
pPicBuffer - a buffer pointer points to a buffer to get picture.
pPicBufSiz - the buffer size of pPicBuffer, it could get from run "getRunStepstate(...)" function.
errCode	- when image is snapping and report some error code; that is one of __Error_None__, __Error_No_image__, __Error_snapping__
return the size of picture that got; when return value is 0, implies an error happen, please check the errCode condition
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
ULONG getPicture2Buffer(__HZHANDLE__ hZhandle, unsigned char *pPicBuffer, ULONG pPicBufSiz, UCHAR *errCode);



#define _10BitI2C_Addr			0x1
#define	_1byteRdSubAddr			0x2
#define	_2bytesRdSubAddr		0x4
#define	_3bytesRdSubAddr		0x6
#define	_IgnoreAckChking		0x8
#define	_ReadI2cDevice			0x80

/*
I2C configure byte::
	b0: (0) - 7 bits address, (1) - 10 bits address
	b2~b1: sub-address when read
		00: No sub address
		01: 1 byte
		10: 2 bytes
		11: 3 bytes
	b3: Ack ignore
	b4~b6: reserve
	b7: read(1), write(0)
*/
/*
I2cRawDataWrite - Write data present by string to i2c device; this function would decode this text string to binary.

cfgByte - I2C configure information
i2cAddr - I2C device address
pTxtWrData - text string of write data, sepearated by ',' - example: "0x1, 2, 0x3, 0x4, 5"
txtLen - the test string data length

return: -1: USB can't write,
		-2: I2C write error.
		-3: not all data write out.
		0 : write succeed.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int I2cRawDataWrite(__HZHANDLE__ hZhandle, UCHAR cfgByte, USHORT i2cAddr, char *pTxtWrData, int txtLen);


/*
I2cRawDataWrite2 - Write binary data to i2c device.

cfgByte - I2C configure information
i2cAddr - I2C device address
pWrData - write binary data buffer.
WrDataLen - how many bytes data to write.

return: -1: USB can't write,
		-2: I2C write error.
		-3: not all data write out.
		0 : write succeed.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int I2cRawDataWrite2(__HZHANDLE__ hZhandle, UCHAR cfgByte, USHORT i2cAddr, UCHAR *pWrData, int WrDataLen);


/*
I2cRawDataRead - read data from i2c device.

cfgByte - I2C configure information
i2cAddr - I2C device address
pTxtSubAddr �V some i2c device has its sub-address, that here present by text string, it configure by cfgByte.
nReadLen �V how many data would be read.
pReadBuffer �V read buffer.
return  -1: USB can't write,
		-2: I2C write error.
		-3: not all data write out.
		-4: USB can't read.
		n : Read length.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int I2cRawDataRead(__HZHANDLE__ hZhandle, UCHAR cfgByte, USHORT i2cAddr, char *pTxtSubAddr, int nReadLen, UCHAR *pReadBuffer);


/*
I2cRawDataRead2 - read data from i2c device.

cfgByte - I2C configure information
i2cAddr - I2C device address
pSubAddr - some i2c device has its sub-address, it configure by cfgByte.
nReadLen �V how many data would be read.
pReadBuffer �V read buffer.

return  -1: USB can't write,
-2: I2C write error.
-3: not all data write out.
-4: USB can't read.
n : Read length.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int I2cRawDataRead2(__HZHANDLE__ hZhandle, UCHAR cfgByte, USHORT i2cAddr, UCHAR *pSubAddr, int nReadLen, UCHAR *pReadBuffer);





/*
Every test step file could include a special key "$ALIAS" to assigned a user readable name for
indicate current step purpose in testing.
For example:
	RtxCaptureStep001.txt includes as :
	...
	$ALIAS = Test UVL function
	...

	The "Test UVL function" could be used as a name of this test step when testing; 
	that is meaning than the RtxCaptureStep001.txt.

	When $ALIAS isn't assigned in test step file; the file name is default $ALIAS name.

	The maximum ALIAS name is less than 64 characters.
	This ALIAS name is built up after download test step operation; and could access by following functions.
	
	Any readable text file name could be used as test step file;
	
	Some functions support using file name as test-step (register file) is ready now.
*/

/*
getMaxAliasRunSteps2AllowDownload - return the maximum test steps alias list count; 
	that would be same as the maximum test steps configured in system-configured file.

return : allowed test steps count.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getMaxAliasRunSteps2AllowDownload(__HZHANDLE__ hZhandle);





/*
getAliasRunStepsCntJustDownload - return the actually download to Zebra test steps count;
that would be less than the test steps configured in configuration file.

return : the current download to Zebra test steps count.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getAliasRunStepsCntJustDownload(__HZHANDLE__ hZhandle);





/*
get1stDownloadStepAliasName - point to the 1st download alias name on alias list..

return : when there isn't any alias name exist that point to NULL.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
char *get1stDownloadStepAliasName(__HZHANDLE__ hZhandle);




/*
getNextDownloadStepAliasName - point to the next download alias name from just got.

return : when there isn't next alias name that points to NULL.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
char *getNextDownloadStepAliasName(__HZHANDLE__ hZhandle);




/*
getRunStepIdFromDownloadAliasList - get a test step id by an assigned test step alias name.
this id could be used by "KickoffRunStep(...)" function to kick off Zebra do testing.

return : the test step id that assinged by alias name; when illegal alias name this function return -1.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getRunStepIdFromDownloadAliasList(__HZHANDLE__ hZhandle, char *pAliasStepName);




/*
RunStepByAliasName - kick off a test step by alias name; this function default to call 
		getRunStepIdFromDownloadAliasList() and then KickoffRunStep() function to run a test step.

return : the test step id that assinged by alias name; when illegal alias name this function return -1.
				 1 is run succeed, and 0 indicates test-step can't run.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int RunStepByAliasName (__HZHANDLE__ hZhandle, char *pAliasStepName, int nOption);




/*
getRegisterStepsCntJustDownload - return the actually download to Zebra test steps count;
that could be less than the test steps configured in configuration file.

return : the current download to Zebra test steps count.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getRegisterStepsCntJustDownload(__HZHANDLE__ hZhandle);



/*
get1stDownloadRegisterStepName - get file name that was 1st downloaded test-step (register) file.

return : when there isn't any file name exist in register-file-directory that point to NULL.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
char *get1stDownloadRegisterStepName(__HZHANDLE__ hZhandle);



/*
getNextDownloadRegisterStepName - point to the next download test-step (register) file name.

return : when there isn't next file name exist in register-file-directory that point to NULL.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
char *getNextDownloadRegisterStepName(__HZHANDLE__ hZhandle);



/*
getRunStepIdFromDownloadRegisterStepList - get a test step id by an assigned test-step/register file name.
this id could be used by "KickoffRunStep(...)" function to kick off Zebra do testing.

return : the test step id that assinged by test-step/register name; when illegal test step register name this function return -1.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getRunStepIdFromDownloadRegisterStepList(__HZHANDLE__ hZhandle, char *pRegisterStepName);




/*
RunTestStepFile - kick off a test step by its test-step name; this function default to call 
		getRunStepIdFromDownloadAliasList() and then KickoffRunStep() function to run a test step.

return : the test step id that assinged by test-step name; when illegal test-step name this function return -1.
				1 is run succeed, and 0 indicates test-step can't run.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int RunTestStepFile(__HZHANDLE__ hZhandle, char *pTestStepName, int nOption);




/*
SetZebraSetting - setup a Zebra setting file name and use this name to matching a register-file as test-step 
	when download phase or RunRegisterFile function.

return : none.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
void SetZebraSetting(__HZHANDLE__ hZhandle, char *pZebraSetting);



/*
RunRegisterFile - kick off a test step by a Zebra setting file (set by SetZebraSetting()) with register register file; 
		this function default to call getRunStepIdFromDownloadRegisterStepList() and then KickoffRunStep() function to run a test step.

return : the test step id that assinged by setting file and register file name; when illegal register name this function return -1.
        1 is run succeed, and 0 indicates test-step can't run.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int RunRegisterFile(__HZHANDLE__ hZhandle, char *pRegisterName, int nOption);


/*
getDllVersion - get current DLL version, that is MajorVersion, MinorVersion, BuildNumber, RevisionNumber.
pDllName – return DLL library name; if this DLL name can't be found, function return a zero length string.(1st  byte is set to 0)
dwMSVer  - includes HIWORD(MajorVersion), LOWORD(MinorVersion); when function fail return 0xffffffff
dwLSVer  - includes HIWORD(BuildNumber), LOWORD(RevisionNumber);when function fail return 0xffffffff
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
void getDllVersion(TCHAR *pDllName, DWORD *dwMSVer, DWORD *dwLSVer);



#define __ZebraType_Z4__					0
#define __ZebraType_Z5__					1
#define __ZebraType_Z4U3__				16


/*
getHardwareType - report current card type.
return Zebra type
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getHardwareType (__HZHANDLE__ hZhandle);




typedef struct {
	UINT	uiPicWidth;
	UINT	uiPicHeight;
} PIC_FRAME_SIZ_INFO, *PPIC_FRAME_SIZ_INFO;

/*
getStepIdPicFrameSizInfo - report picture frame size information.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getStepIdPicFrameSizInfo (__HZHANDLE__ hZhandle, int nTestStepId, PPIC_FRAME_SIZ_INFO pPicFrameSizInfo);


/*
getAliasNamePicFrameSizInfo - report picture frame size information.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getAliasNamePicFrameSizInfo (__HZHANDLE__ hZhandle, char *pAliasStepName, PPIC_FRAME_SIZ_INFO pPicFrameSizInfo);


/*
getTestStepPicFrameSizInfo - report picture frame size information.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getTestStepPicFrameSizInfo (__HZHANDLE__ hZhandle, char *pTestStepName, PPIC_FRAME_SIZ_INFO pPicFrameSizInfo);


/*
getRunRegtrPicFrameSizInfo - report picture frame size information.
*/
#ifdef ZEBRAZ4U3DLLWINXP_EXPORTS
extern "C" __declspec(dllexport)
#else
extern "C" __declspec(dllimport)
#endif
int getRunRegtrPicFrameSizInfo (__HZHANDLE__ hZhandle, char *pRegisterName, PPIC_FRAME_SIZ_INFO pPicFrameSizInfo);


#endif // __ZebraDllWin32_h__