OS.bee Signature Pad

From OS.bee documentation
Revision as of 10:00, 5 April 2018 by Yang (Talk | contribs) (new entity)

Jump to: navigation, search

Signature Pad

Using signature pad for payment process is a new cash payment method.

Basic Functionalities

Basic functionalities of display on signature pad are:

  • Show the advertising slide images on signature pad one after another according to de slide delay predefined in Mcompany( in our example, for company FoodMart, the slide delay is defined as 2000, which means 2 seconds).
  • When the customer signature is required, the display image on the signature pad will switch to the signing image, additional 3 buttons will be shown under the signing image: done, cancle and delete.(these labels could be translated with I18n)

Functionalities after signing

The following image is the signing image in our example.

  • Customer signs, and then select “done”, the signature of customer will be saved as a blob-mapping data, saving as thousands of points with x,y, pressure... the display of signature pad switch to the advertising slide images.
  • Customer signs, and then select “cancle”, the signature process will be broken, switch to the advertising slide images.
  • Customer signs, and then select “clear”, the signature will be deleted, and waiting for the next action of customer.

Technical changes in DSL model

changes in entity

  1. New entity AdvertisingSlide :
    entity AdvertisingSlide extends BaseUUID {
    	persistenceUnit "businessdata"
    	domainKey String slide
    	var Date showFrom properties( key="Date" value="Minute")
    	var Date showUntil properties(key="Date" value="Minute")
    	var BlobMapping image
    	ref Mcompany company opposite slides
    }
    
    • slide: name of this slide.
    • ShowFrom and showUntil: valid date interval for this slide.
    • Image: save this slide as a blobmapping data.
    • Company: which company using this slide.
  2. New properties and references in entity Mcompany:
    entity Mcompany extends BaseUUID { 
    	. . .
    	var BlobMapping signingImage
    	var int slideDelay properties(key="Slider" value="1000:10000")
    	ref AdvertisingSlide[*] slides opposite company properties( key = "Table" value = "" )
    	. . .
    }
    
    • signingImage: save the signing image as a blobmapping data. signingImage is the image which will be displayed on signature pad when customer signes.
    • slideDelay: define the time delay for changing advertising slide image, unit is ms, and this value should be between 1000 and 10000, which means the delay should be between 1 second and 10 seconds.
    • Slides: define a set of advertisingSlides for this company. These advertising slide images will be displayed one after another on the signature pad when no actions on it.
  3. A new Cash Payment Method "signaturePad": If the customer selects this payment way, the signature pad will be active.
  4. New entity CashPaymentPenData :
    entity CashPaymentPenData extends BaseUUID {
    	persistenceUnit "businessdata"
    	var int rdy
    	var int sw
    	var int pressure
    	var int x
    	var int y
    	ref CashPayment payment opposite penData
    }
    
    • The signature image will be saved as a CashPaymentPenData. All this relevant data value is generated from WACOM(mark of signature pad) software. The important values are pressure amount and cursor coordinates x and y. They will be saved save as a blob-mapping data, which including thousands of points with all the important values.
  5. Some new properties and references are defined in entity CashPayment:
    entity CashPayment extends BaseUUID {
    . . .
    	var BlobMapping signatureBitmap
    	ref cascade CashPaymentPenData[*] penData opposite payment 
    }
    

changes in statemachine

  1. New payment method "payment signing"
    It is defined as a new statemachine event "onMethod7".
    A new peripheral is defined in statemachine for it:
    peripheral PeripheralControl {
    	. . .
    	signaturePad SignaturePad
    }
    
    A new button is defined for it in paypad of statemachine:
    keypad PaymentPad event trigger {
    	. . .
    	button method7 image "" event onMethod7 
    }
    
  2. New keypad "PluPad"
    keypad PluPad event identity from 1 until 6  named "plu"
    
  3. Changes in statemachine state "IDLE":
    trigger onStartUp
    actions transition LOCKED{
    	. . .
    	closeSignaturePad @SignaturePad
    	. . .
    }
    
  4. Changes in statemachine state "LOCKED":
    trigger onOk
    actions transition ATTENTIVE{
    	. . .
    	operation loadPLU()
    	operation loadPaymentMethods() 
    	store "false" with paymentterminal.open
    	paymentOpen host dto cashregister.payment_ip port dto cashregister.payment_port @VeriFone
    	labelSignaturePad okLabel "done" clearLabel "clear" cancelLabel "cancel" @SignaturePad
    	store "false" with signaturepad.open
    	openSignaturePad @SignaturePad
    	. . .
    }
    
  5. Changes in statemachine state "ATTENTIVE", new trigger "onSignaturePadOpen" for signaturePad:
    trigger onSignaturePadOpen
    actions {
    	store "true" with signaturepad.open
    	operation initImages()
    	idleSignaturePad @SignaturePad
    }
    
  6. Changes in statemachine state "PAYMENT":
    trigger onBack
    actions transition ATTENTIVE {
    	idleSignaturePad @SignaturePad
    	. . .
    }
    </syntaxhighlight
    #:<syntaxhighlight lang="java">
    trigger onMethod1 onMethod2 onMethod3 onMethod4 onMethod5 onMethod6 onMethod7
    actions {
    	. . .
    	transition SIGNATURE_AUTHORIZATION guard useSignaturePad {
    		visible signaturePadDisplay
    		invisible money
    		invisible method
    		invisible functions
    		store event with paymentMethod.last
    		captureSignaturePad @SignaturePad
    	}
    	idleSignaturePad @SignaturePad
    	. . .
    }
    
  7. In statemachine new state "SIGNATURE_AUTHORIZATION":
    state SIGNATURE_AUTHORIZATION {
    	triggers {
    		trigger onSignatureOk
     		actions transition PAYMENT {
     			idleSignaturePad @SignaturePad
    			operation dopayment(retrieve from paymentMethod.last)
    			operation computePayed()
    			set "0" @paymentGiven
    			clearDevice LineDisplay
    			lineDisplayTextAt translate "total" row 0 column 0 @LineDisplay
    			lineDisplayTextAt translate "remain" row 0 column 10 @LineDisplay
    			lineDisplayTextAt function getPaymentTotal() row 1 column 0 @LineDisplay
    			lineDisplayTextAt function getPaymentRemain() row 1 column 10 @LineDisplay
    			invisible paymentTerminalDisplay
    			invisible signaturePadDisplay
    			visible money
    			visible method
    			visible functions
    			operation givenChanged()
    			transition PRINT_SLIP guard isPayed {
    				invisible total
    				invisible logout
    				invisible PaymentPad
    				invisible paymentFields
    				invisible functions
    				invisible numbers
    				invisible plu
    				invisible money
    				invisible method
    				invisible filterToggle
    				visible receipt
    				visible printreceipt
    				visible noreceipt
    				visible paymentFields
    				clearDevice LineDisplay
    				lineDisplayTextAt translate "total" row 0 column 0 @LineDisplay
    				lineDisplayTextAt translate "change" row 0 column 10 @LineDisplay
    				lineDisplayTextAt function getPaymentTotal() row 1 column 0 @LineDisplay
    				lineDisplayTextAt function getPaymentChange() row 1 column 10 @LineDisplay
    				transition OPEN_DRAWER guard mustOpenDrawer {
    					openDrawer CashDrawer
    				}
    			}
    		}
    		trigger onSignatureCancel
    		actions transition PAYMENT {
    			idleSignaturePad @SignaturePad
    			invisible signaturePadDisplay
    			visible money
    			visible method
    			visible functions
    			operation givenChanged()
    		}
    	}
    }
    

changes in functionlibrary

  1. New guard function "useSignaturePad" in functionlibrary DSL :
    guard useSignaturePad(IStateMachine stateMachine) {
    	var slip =  stateMachine.get("cashslip") as CashSlipDto
    		stateMachine.set("signaturePadDisplayResolution" , 5)
    		stateMachine.set("signaturePadDisplay", slip.register.store.company.signingImage)
    	var paymentMethodDto = stateMachine.getStorage(stateMachine.getLastTrigger(), "dto") as CashPaymentMethodDto
    	var isopen = "true".equals(stateMachine.getStorage("signaturepad", "open") as String)
    	return paymentMethodDto.signaturePad && isopen
    }
    
  2. New operation "initImages" in functionlibrary DSL:
    operation initImages(IStateMachine stateMachine, Object [] params) {
    	var cashregister = stateMachine.get("cashregister") as CashRegisterDto
    	if(cashregister === null) {return false}
    	stateMachine.set("CustomerDisplayImage", cashregister.store.company.companyImage)
    	stateMachine.set("signatureSlideDelay", cashregister.store.company.slideDelay)
    	stateMachine.set("signatureCaptureImage", cashregister.store.company.signingImage)
    	for(slide:cashregister.store.company.slides) {
    		stateMachine.set("signatureAddSlide", slide.image)
    	}	
    	return true
    }
    
  3. New method in operation "dopayment()" for save the signature image:
    var spIsOpen = "true".equals(stateMachine.getStorage("signaturepad", "open") as String)
    if(spIsOpen && paymentMethodDto.signaturePad) {
    	var signatureBlob = stateMachine.get("SignatureBlob") as String
    	paymentPosition.signatureBitmap = signatureBlob
    	stateMachine.set("signaturePadDisplay", signatureBlob)
    	var data = stateMachine.get("PenData") as List<PenData>
    	if(data !== null) {
    		for(pData:data) {
    			var penDataDto 		= new CashPaymentPenDataDto
    			penDataDto.rdy 		= pData.rdy
    			penDataDto.sw 		= pData.sw
    			penDataDto.pressure	= pData.pressure
    			penDataDto.x 		= pData.x
    			penDataDto.y 		= pData.y
    			paymentPosition.addToPenData(penDataDto)
    		}
    	}
    }
    

The detail of entity Mcompany can be set in the following page: In menu--> Master data-->Company: