Embodiment
Now by reference to the accompanying drawings, preferred embodiment of the present invention is elaborated.
As shown in Figure 1, be applied to the structural representation of the Development Framework of the embedded software product of financial terminal for the present invention.This Development Framework comprises by the end following four levels up, that is: L1, physical drives service layer (PDS, Physical Drivers Service); L2, equipment control service layer (DMS, Drivers Manager Service); L3, terminal application platform layer (TAP, Terminal Applications Platform); And L4, application service layer (APPS, Applications Service).Below, in conjunction with the sub financial terminal ZT2312C of card energising, Development Framework of the present invention is introduced in detail.The multi-functional Jin Yitong of ZT2312C be card energising son be a mainly towards rural area, the financial service terminal in factories and miness, building site and market, community.Its hardware configuration has magnetic bar reader, IC-card readwrite line 11,printer 12, Encryption Keyboard 13,touch display screen 14 etc.The basic function of its support comprises: account inquiries: account balance inquiry, transaction detail query; Transfer accounts, remit money: card card is transferred accounts, account remittance; Bank card activates; Password is revised; Bank card is reported the loss; And strip is printed.The expanded function of its support comprises: Huinong's card business: Huinong's card small amount loan, refund, loan refund tentative calculation; Bill payment: pay on behalf charges for water and electricity, telephone charge, CATV fee, combustion gas expense, tuition fee etc.; IC-card is supplemented with money: mass transit card, water power card, gas cards are supplemented with money; Note is led to business: signing, the signing inquiry of note, signing cancellation; And financial information inquiry and advertising business.
L1, physical drives service layer (PDS): PDS completes the working control to hardware device are unique parts directly related with hardware in whole framework.PDS by one group independently device drives storehouse form, be closely related with concrete ardware model number, provide with operating system.The terminal of each model, realizes according to unit type and " equipment physics service layer drives agreement " the device drives storehouse that the type equipment is corresponding voluntarily.
As the driver of the print module of ZT2312C, the driver partial code example developed is according to demand as follows:
#define FONT_NORMAL 0 // normal font size
#defineFONT_HEIGHT 1 // doubly high
#define FONT_WIDTH 16 // doubly wide
#define FONT_HEIGHT_WIDTH 17 // times high power is wide
/ * #define FONT_NORMAL 0 // normal font size
#define FONT_HEIGHT 16 // English is doubly high
#defineFONT_WIDTH 32 // English is doubly wide
#define FONT_HEIGHT_WIDTH 48 // English times high power is wide
#define FONT_WIDTH2 4 // Chinese is doubly wide
#define FONT_HEIGHT2 8 // Chinese is doubly high
#defineFONT_HEIGHT_WIDTH2 12 // Chinese times high power is wide
*/
#define FONT_NONE 0 // do not have overstriking
#define FONT_BOLD 8 // runic
#define UNDLINE_NONE 0 // do not have underscore
#define UNDLINE_NORMAL 128 // 1 thick underline
#define UNDLINE_BOLD 136 // 2 thick underline
extern "C" PDSPrinter *createPDSPrinter(const char *p_caDeviceType)
{
return new PDSPrinter(p_caDeviceType);
}
/*[method*******************************************************************************
*def: public ivoid PDSPrinter::PDSPrinter(const char *p_caDeviceType)
* func:ZT2312C printer configuration function
*************************************************************************************]*/
PDSPrinter::PDSPrinter(const char *p_caDeviceType) : PDSDevice(p_caDeviceType)
{
// carry out initialization default baud rate and be that it goes without doing revises at this
if( SUCC == this->open() )
blConnect = true;
else
blConnect = false;
The initialization of // actuating equipment
}
/*[method*******************************************************************************
*def: public ivoid PDSPrinter::~PDSPrinter()
* func:ZT2312C printer destructor function
*************************************************************************************]*/
PDSPrinter::~PDSPrinter()
{
}
The hardware device of different financial terminals, only need to drive the interface specification of agreement to drive exploitation according to equipment physics service layer, has developed the rear upper level applications that just can use original exploitation to complete, and realizes the cross-platform of software.
Equipment physics service layer drive agreement, be the equipment of same type is carried out to abstract unification after, the Device-General interface for a certain type of definition.This layer protocol can be used for driven management center (DMC) and calls specific device object in PDS.Driving agreement is virtual concept, mainly refers to according to the equipment of a certain class according to the interface of the definition of equipment general character and encapsulation driving.The all devices that meets this agreement has identical underlying device to drive interface.
L2, equipment control service layer (DMS): DMS are in charge of the access control of application to equipment, upwards provide the application layer access interface of application to equipment, actuating equipment access control instruction downwards.DMS comprises two parts: driven management center (DMC, Drivers Manager Central) 21 and virtual drive collection (VDS, Virtual Drivers Set) 22.Wherein, this DMC is after abstract unification is carried out in the driving of the hardware device to same type in financial terminal, the general-purpose interface of the hardware device for each type of definition.This VDS be the physical equipment general to financial terminal to drive into the further abstract unification of row defined, object is the control of application to hardware device of simplifying upper strata and calls.
DMC is the equipment control service routine of realizing as basis take " equipment physics service layer drives agreement ".The Driver Library that DMC is loaded PDS and provided by the mode of dynamic call is realized the control to equipment.Owing to adopting Dynamic loading technique, therefore can accomplish to use same DMC in the terminal of different models, and can only load as required necessary device drives.
DMC service routine calls the dynamic base of print module, and example code is as follows:
// be written into dynamic base
c_libf_createpdsprinter = (LIBF_CREATEPDSPRINTER )dlsym(c_handle, "createPDSPrinter");
c_printer = c_libf_createpdsprinter(p_caType);
Above-mentioned code is written into printer dynamic base, and calls createPDSPrinter () constructed fuction, and printer is carried out to initialization.Just can pass through afterwards the function of c_printer Member call printer, realize control and the use of DMC to device drives.
DMC can configure the driving and the equipment that need loading by configuration file, and partial configuration file content and configuration format example are as follows:
[pds]
The equipment number that count=5 // needs use
[ctrl]
Port=4150 // listening port
[device_1]
Open=1 // whether open
Port=4100 // listening port
Class=prn // device class
Type=41 // equipment type
Os=linux26 // operating system
Logshow=1 // whether to standard output print log
Maximum number of lines is preserved in logmaxln=1000 // daily record
VDS realizes to such an extent that equipment application layer drives interface take " equipment application layer drives agreement " as basis.Equipment application layer drives agreement, is physics service layer is driven into the further abstract unification of row, to simplify application, the control of equipment is defined as object, and this layer protocol offers the application interface of application call for VDS definition.
The partial code example that VDS realizes is as follows, and code is mainly to send instruction by socket to DMC, and DMC receives to call after instruction and drives the control of Interface realization to underlying device and call, sends instruction return to operating result after completing by socket:
/*[method*************************
*def: public int VDSPrinter::print(const char *p_caStr)
* func: printable character string
* the character string that args:p_caStr need to print
* ret:ret=SUCC success
Ret<0 error code
*********************]*/
int VDSPrinter::print(const char *p_caStr)
{
int iLn=0, iReqId=0, iRet=0;
char *cpBuff=NULL, caBuff[256]={0}, caRetcode[8]={0};
ZTTlv2 tlv1, tlv2;
this->get_header_item(&iReqId, &tlv1, DMC_CMD_PRN_STR, DMC_NEED_RSP);
// parameter
tlv1.set(DMC_TLV_TEXT, p_caStr, -1);
cpBuff = (char*)malloc(strlen(p_caStr)+100);
memset(cpBuff, 0, strlen(p_caStr)+100);
tlv1.seal_vdscmd(cpBuff, &iLn);
this->add_cmd(DMC_NEED_RSP, iReqId, DMC_CMD_PRN_STR, iLn, cpBuff, NULL);
// send order bag to DMC by socket
free(cpBuff);
The response message of // reception DMC
memset(caBuff, 0, sizeof(caBuff));
iRet = this->get_res(iReqId, caBuff);
if( iRet < 0 ) return iRet;
// unpack
iLn = iRet;
memset(caRetcode, 0, sizeof(caRetcode));
tlv2.unseal(caBuff, iLn);
tlv2.get(DMC_TLV_RETCODE, caRetcode);
return atoi(caRetcode);
}
Upper layer application, as the TAP layer in the present embodiment, by calling device drives interface corresponding in VDS, realizes the control to equipment.VDS realizes by dynamic base, and upper layer application can directly be called the dynamic base realization of VDS and call.It is as follows that upper layer application is called bottom layer driving example code by VDS:
// find symbol from library
PFnCreateDeviceWrapper pFnCreateDevice = (PFnCreateDeviceWrapper)lib.resolve("createVDSDevice");
if (pFnCreateDevice == NULL)
{
KLog->DeviceMethodLog(LG_FLOW, true, id, "initialize", "failed. symbol createDevice not found in library [%s]", assembly);
return false;
}
// get deivce
QString configPath(TAP_LIB_CONFIG);
configPath = pConfig->Attribute("config");
printf("configPath = [%s]\n",configPath.toLatin1().data());
m_pDevice = pFnCreateDevice(configPath.toLatin1().data());
Upper level applications, according to " equipment application layer drives agreement ", is written into VDS dynamic base by configuration file, realizes calling that lower floor is driven.
Between DMC and VDS, adopt socket communication modes.For example, in the code that VDS realizes above, this partial code sends data to DMC to socket exactly, receives the data that DMC returns simultaneously:
this->add_cmd(DMC_NEED_RSP, iReqId, DMC_CMD_PRN_STR, iLn, cpBuff, NULL);
// send order bag to DMC by socket
memset(caBuff, 0, sizeof(caBuff));
The response message of // reception DMC
iRet = this->get_res(iReqId, caBuff);
if( iRet < 0 ) return iRet;
In the present embodiment, in order to guarantee dirigibility, the extensibility of communications protocol, the convenience of processing, communications protocol adopts the sub self-defining ZTTLV2 form of card energising.ZTTLV2: be writing a Chinese character in simplified form of SZZT Tag Length Value.What represent is the expression pattern of label, length, value.Wherein, label (TAG): be the numerical value of 4 bytes, use BCD boil down to 2 bytes when transmission.Length (LENGTH): the length that is the value that represents that this label is corresponding; By 2 byte numerals, more than mould that first byte is length, second byte are length; Can represent in theory the data of 65536 byte longs, in practical application, can not reach this length, the mark therefore whether compressing most significant digit as data, 1: represent the data division with BCD compression expression, 0: represent that data division does not compress.Value (VALUE): be the value that represents this label, whether compress by the compression mark of length part and determine.
By VDS and DMC module, can realize the module isolation of upper layer application and bottom layer driving, as long as the platform of transplanting has used same Development Framework and module drive agreement (being that interface is identical), just can realize the cross-platform exploitation of upper layer application and operation.
Simultaneously, due to VDS and DMC employing socket communication, application program can be debugged exploitation on PC, and this process can with the hardware development of financial terminal and drive to develop synchronize carry out, realize cross-platform debugging and remote debugging in software development process, improved the efficiency of project development simultaneously.In the process of equipment investment operation and maintenance, remote debugging also provides very large facility to developer.
Because the existence of VDS, the present invention has realized the perfect unity support to three kinds of application forms: for the powerful high-end devices of handling property, can adopt the application form of VDS+TAP+APPS (HTML5), realize better cross-platform and fast Development characteristic of application program; For low and middle-end equipment, as used single-chip microcomputer or the limited equipment of processor performance, can adopt VDS+APPS (C/C++), realize the compatibility to some existing equipments with this; For the equipment of operation Android operating system, can adopt VDS+TAP+APPS (HTML5), but TAP need to be according to the characteristic of Android, develop realization with java.That is to say, for high-end hardware device, Development Framework of the present invention can adopt this application service layer to call this terminal application platform layer, this terminal application platform layer to call the application form of the virtual drive collection of this equipment control service layer.In the time need to being transplanted to different operating system, according to the characteristic of specific operating system, may need this terminal application platform layer and this application service layer again to develop.For low and middle-end hardware device, this Development Framework can adopt this application service layer to call the application form of the virtual drive collection of this equipment control service layer.
L3, terminal application platform layer (TAP): TAP are mainly the Application Development Solutions for high-end devices; its core concept is the mode with QT+HTML5; the support to JS script being provided by QT; realize the protection to data and core business logic, realize the realization of operation flow and the displaying at interface by HTML5.TAP is injected the compositions such as service (FIS, Function Inject Service)module 31,WEBKIT+ module 32, data acquisition service (DGS) module 33, core business service (CBS)module 34 and primary control program (MC)module 35 by function.Wherein, this DGS is responsible for collection and the preservation of application program sensitive data, and a general controls interface is provided, and only has this FIS can access the general controls interface of this DGS.This CBS be responsible for application program transaction group bag, unpack, communication and other important business logic processing, and provide a general controls interface, only have this FIS can access the general controls interface of this CBS.Specifically have:
1, FIS is responsible for realizing the access interface control of JS to equipment, the control of data acquisition unit interface, the control of core business interface etc.
The configuration file of for example FIS can configure JS accesses the interface of which module, some parameters that simultaneously can also configuration module, and configuration file partial content example is as follows:
<DeviceServiceManager>
<DeviceService id="PrinterService" >
<Device id="ReceiptPrinter" assembly="libvds_prn_linux26.so" config="vds_41.ini" />
</DeviceService>
<DeviceService id="MagicCardService" >
<Device id="SwipeMagic" assembly="libvds_mag_linux26.so" config="vds_46.ini" />
</DeviceService>
……………………
</DeviceServiceManager>
After having configured, JS can control and invocation facility interface (calling bottom layer driving by VDS), and partial code example is as follows:
// the operation of swiping the card
function readCard(sucess,errors)
{
TAP.Device.MagicCardService.SwipeMagic.sigMagReadMagicCompleted.connect(sigMagReadMagicCompleted);
TAP.Device.MagicCardService.SwipeMagic.readMagicAsync(SysConstant.SHUAKA_TIMEOUT);
this.cardsucess=sucess;
this.carderrors=errors;
}
2, WEBKIT+ is important component part of framework, and in the present embodiment, this module is the webkit storehouse of QT encapsulation, can offer HTML, JS as web browser, for finishing service operation control, showing interface etc.
3, DGS designs for the high application of security requirement, and in this type of application, collection and the preservation of sensitive data is responsible in data acquisition service, to avoid revealing deeply grateful data.Data acquisition service only provides general control interface, and specific implementation is realized voluntarily by application program, offers TAP call with the form of dynamic base.
It is as follows that TAP is written into data acquisition service (DGS) example code:
function loadFile(fName)
{
var ret = TAP.Dgs.load(fName);
return ret;
}
After being written into, obtain the corresponding data of preserving in input collector, example code is as follows:
function getValue(skey)
{
var sValue=TAP.Dgs.get(skey);
return sValue;
}
4, CBS also designs for the high application of security requirement, and in this type of application, CBS is that core business service module is responsible for processing transaction group bag, is unpacked, communication and other important business logic processing, to guarantee the safety of process of exchange.The same with DGS, CBS also only provides general control interface, and specific implementation is realized voluntarily by application program, offers TAP call with the form of dynamic base.CBS formulates corresponding data packet group packet format and transaction flow according to business demand, the interface of different business different bank, and the realization of CBS is all different.
TAP calls CBS business core and concludes the business, and example code is as follows:
/ * asynchronous transmission administrative class message
*author ljn
* param tradeId transaction code
* param trdSuccess success callback method
* param trdError failure callback method
*/
function doMgrTradeAsync(tradeId,trdSuccess,trdError,flag)
{
if(flag == null && flag != 0)
{
WriteTime (1); // record sends the message time
}
else
{
WriteTime (0); Whether // record sends the message time, but do not scan stuck
}
doDGSprint();
TAP.Device.CbsService.sigTradeComplete.connect(sigTradeComplete1);
TAP.Device.CbsService.doTradeAsync(tradeId);
this.trdSuccess = trdSuccess;
this.trdError = trdError;
}
L4, application service layer (APPS): application service layer, take TAP, VDS as basis, is realized concrete user items appellative function.In Development Framework of the present invention, can support easily theWEB scheme 41 of the application of three kinds of schemes: HTML5, traditional C/C++/Qt scheme and Android scheme.Concrete what scheme that adopts, is selected by concrete project demands and customer requirement.
Application service layer can be realized concrete function and the driving of operation underlying device by TAP layer, realize the functions such as interface display, interface data are mutual, hardware device control, transaction transmitting-receiving, TAP develops proper page development scheme and the hardware platform that can support most.
The all right compatible traditional Software Development of Development Framework of the present invention,Native App 42 can directly call VDS and realize the access control to bottom layer driving.Therefore Development Framework of the present invention can realize downward compatibility, has good cross-platform characteristic.
The beneficial effect of the Development Framework of the embedded software product that is applied to financial terminal of the present invention comprises:
1, this framework supports the page to realize by the form of HTML5, can cross-platform exploitation and cross-platform use, and the exploitation of modules can walk abreast, and the dependence of reduction project to C/C++ slip-stick artist, alleviates developer's burden.
2, accomplish application and hardware independent truly.Owing to there being the existence of DMS layer, application development is completely irrelevant with concrete ardware model number, can accomplish application and development and terminal concurrent development.
3, reduce compiling, debugging spent time in project development process.The present invention will reduce the quantity of source code in application item to a certain extent, on the other hand, for the project that adopts HTML, substantially no longer there is compilation of source code problem, and the dirigibility of debugging also improves greatly, can skip as required unwanted test link, thereby improve the time efficiency of compiling, debugging.
4, the present invention carries out strict logic and layering physically to software product, improves stability, the reliability of software product.Physics service layer drives completely and separates with application, by more by experience, the slip-stick artist of higher level safeguards, application drives and is also responsible for providing by professional, these mechanism can both guarantee stability, the reliability of equipment use procedure code more to the full extent, thereby effectively improve stability, the reliability of whole product.
5, shorten the construction cycle of new projects.Under traditional development scheme, no longer need to pay close attention to the use of hardware device---provide VDS for directly, only need be absorbed in service logic; The mode of HTML, can accelerate greatly especially the progress of service logic exploitation, thereby shorten the construction cycle of new projects.
6, cross-platform exploitation, the remote equipment of realizing real meaning calls, remote equipment is debugged.Adopt Quick Development Framework of the present invention, between application and driving, adopt socket communication modes, application program may operate on the equipment outside terminal, therefore completely, not only can realize cross-platformly, can also realize that remote equipment calls, remote equipment debugging.The function of remote equipment debugging, when for diagnostic device fault, will be very useful.
7, unified terminal application program, develops the standard of similar WOSA.Under windows, there is WOSA standard at present, each commercial bank has unified terminal applies on this basis, but on embedded product, never has similar standard, and bank is very strong for the demand of unified built-in terminal application, the present invention will provide a reliable and feasible way.
Should be understood that, above embodiment only, in order to technical scheme of the present invention to be described, is not intended to limit, for a person skilled in the art, the technical scheme that can record above-described embodiment is modified, or part technical characterictic is wherein equal to replacement; And these modifications and replacement all should belong to the protection domain of claims of the present invention.