Skip to content

Commit

Permalink
refactoring [v0.3.4]
Browse files Browse the repository at this point in the history
 methods x5
  • Loading branch information
SUNsung committed Sep 11, 2024
1 parent 8b130f0 commit 4c7ddf9
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 55 deletions.
4 changes: 2 additions & 2 deletions 0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ func TestConnect(t *testing.T) {
t.Log("Invalid Connect")
return
}
t.Log(a.Method.GetDeviceSerialNumber())
t.Log(a.Method.Device.Get.SerialNumber())
t.Log(a.Method.Bill.Get.Self())
t.Log(a.Method.Application.Get.PN())
t.Log(a.Method.Get.BootPN())
t.Log(a.Method.GetDeviceType())
t.Log(a.Method.Device.Get.Type())

t.Log(a.Method.Get.BNFStatus().String())

Expand Down
6 changes: 6 additions & 0 deletions methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ type MethodsObj struct {
Bill *MethodsBillObj
CashBox *MethodsCashBoxObj
Coupon *MethodsCouponObj
Device *MethodsDeviceObj
Orientation *MethodsOrientationObj
Variant *MethodsVariantObj
}

type MethodsGetObj struct{ a *MpostObj }
Expand All @@ -46,6 +49,9 @@ func (a *MpostObj) newMethods() *MethodsObj {
obj.Bill = obj.newBill()
obj.CashBox = obj.newCashBox()
obj.Coupon = obj.newCoupon()
obj.Device = obj.newDevice()
obj.Orientation = obj.newOrientation()
obj.Variant = obj.newVariant()

return &obj
}
Expand Down
84 changes: 52 additions & 32 deletions methods_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,30 @@ import (

////////////////////////////////////

func (m *MethodsObj) GetCapDevicePaused() bool {
m.a.Log.Method("GetCapDevicePaused", nil)
return acceptor.Cap.DevicePaused
type MethodsDeviceObj struct {
a *MpostObj
Get MethodDeviceGetObj
}

func (m *MethodsObj) GetCapDeviceSoftReset() bool {
m.a.Log.Method("GetCapDeviceSoftReset", nil)
return acceptor.Cap.DeviceSoftReset
}
type MethodDeviceGetObj struct{ a *MpostObj }

func (m *MethodsObj) GetCapDeviceType() bool {
m.a.Log.Method("GetCapDeviceType", nil)
return acceptor.Cap.DeviceType
}
func (m *MethodsObj) newDevice() *MethodsDeviceObj {
obj := MethodsDeviceObj{}

func (m *MethodsObj) GetCapDeviceResets() bool {
m.a.Log.Method("GetCapDeviceResets", nil)
return acceptor.Cap.DeviceResets
}
obj.a = m.a
obj.Get.a = m.a

func (m *MethodsObj) GetCapDeviceSerialNumber() bool {
m.a.Log.Method("GetCapDeviceSerialNumber", nil)
return acceptor.Cap.DeviceSerialNumber
return &obj
}

func (m *MethodsObj) GetDeviceBusy() bool {
////////////////

func (m *MethodDeviceGetObj) Busy() bool {
m.a.Log.Method("GetDeviceBusy", nil)
return acceptor.Device.State != enum.StateIdling
}

func (m *MethodsObj) GetDeviceCRC() int64 {
func (m *MethodDeviceGetObj) CRC() int64 {
m.a.Log.Method("GetDeviceCRC", nil)

err := acceptor.Verify(true, "DeviceCRC")
Expand Down Expand Up @@ -67,37 +60,37 @@ func (m *MethodsObj) GetDeviceCRC() int64 {
return crc
}

func (m *MethodsObj) GetDeviceFailure() bool {
func (m *MethodDeviceGetObj) Failure() bool {
m.a.Log.Method("GetDeviceFailure", nil)
return acceptor.Device.State == enum.StateFailed
}

func (m *MethodsObj) GetDeviceJammed() bool {
func (m *MethodDeviceGetObj) Jammed() bool {
m.a.Log.Method("GetDeviceJammed", nil)
return acceptor.Device.Jammed
}

func (m *MethodsObj) GetDeviceModel() int {
func (m *MethodDeviceGetObj) Model() int {
m.a.Log.Method("GetDeviceModel", nil)
return acceptor.Device.Model
}

func (m *MethodsObj) GetDevicePaused() bool {
func (m *MethodDeviceGetObj) Paused() bool {
m.a.Log.Method("GetDevicePaused", nil)
return acceptor.Device.Paused
}

func (m *MethodsObj) GetDevicePortName() string {
func (m *MethodDeviceGetObj) PortName() string {
m.a.Log.Method("GetDevicePortName", nil)
return m.a.port.PortName
}

func (m *MethodsObj) GetDevicePowerUp() enum.PowerUpType {
func (m *MethodDeviceGetObj) PowerUp() enum.PowerUpType {
m.a.Log.Method("GetDevicePowerUp", nil)
return acceptor.Device.PowerUp
}

func (m *MethodsObj) GetDeviceResets() int {
func (m *MethodDeviceGetObj) Resets() int {
m.a.Log.Method("GetDeviceResets", nil)

err := acceptor.Verify(acceptor.Cap.DeviceResets, "DeviceResets")
Expand Down Expand Up @@ -128,12 +121,12 @@ func (m *MethodsObj) GetDeviceResets() int {
return resets
}

func (m *MethodsObj) GetDeviceRevision() int {
func (m *MethodDeviceGetObj) Revision() int {
m.a.Log.Method("GetDeviceRevision", nil)
return acceptor.Device.Revision
}

func (m *MethodsObj) GetDeviceSerialNumber() string {
func (m *MethodDeviceGetObj) SerialNumber() string {
m.a.Log.Method("GetDeviceSerialNumber", nil)

err := acceptor.Verify(acceptor.Cap.DeviceSerialNumber, "DeviceSerialNumber")
Expand All @@ -159,17 +152,17 @@ func (m *MethodsObj) GetDeviceSerialNumber() string {
return s
}

func (m *MethodsObj) GetDeviceStalled() bool {
func (m *MethodDeviceGetObj) Stalled() bool {
m.a.Log.Method("GetDeviceStalled", nil)
return acceptor.Device.Stalled
}

func (m *MethodsObj) GetDeviceState() enum.StateType {
func (m *MethodDeviceGetObj) State() enum.StateType {
m.a.Log.Method("GetDeviceState", nil)
return acceptor.Device.State
}

func (m *MethodsObj) GetDeviceType() string {
func (m *MethodDeviceGetObj) Type() string {
m.a.Log.Method("GetDeviceType", nil)

err := acceptor.Verify(acceptor.Cap.DeviceType, "DeviceType")
Expand Down Expand Up @@ -198,3 +191,30 @@ func (m *MethodsObj) GetDeviceType() string {

return ""
}

//

func (m *MethodDeviceGetObj) CapPaused() bool {
m.a.Log.Method("GetCapDevicePaused", nil)
return acceptor.Cap.DevicePaused
}

func (m *MethodDeviceGetObj) CapSoftReset() bool {
m.a.Log.Method("GetCapDeviceSoftReset", nil)
return acceptor.Cap.DeviceSoftReset
}

func (m *MethodDeviceGetObj) CapType() bool {
m.a.Log.Method("GetCapDeviceType", nil)
return acceptor.Cap.DeviceType
}

func (m *MethodDeviceGetObj) CapResets() bool {
m.a.Log.Method("GetCapDeviceResets", nil)
return acceptor.Cap.DeviceResets
}

func (m *MethodDeviceGetObj) CapSerialNumber() bool {
m.a.Log.Method("GetCapDeviceSerialNumber", nil)
return acceptor.Cap.DeviceSerialNumber
}
49 changes: 37 additions & 12 deletions methods_orientation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,60 @@ import (

////////////////////////////////////

func (m *MethodsObj) GetCapOrientationExt() bool {
m.a.Log.Method("GetCapOrientationExt", nil)
return acceptor.Cap.OrientationExt
type MethodsOrientationObj struct {
a *MpostObj
Get MethodsOrientationGetObj
Set MethodsOrientationSetObj
}

func (m *MethodsObj) GetEscrowOrientation() enum.OrientationType {
type MethodsOrientationGetObj struct{ a *MpostObj }
type MethodsOrientationSetObj struct{ a *MpostObj }

func (m *MethodsObj) newOrientation() *MethodsOrientationObj {
obj := MethodsOrientationObj{}

obj.a = m.a
obj.Get.a = m.a
obj.Set.a = m.a

return &obj
}

////////////////

func (m *MethodsOrientationGetObj) Escrow() enum.OrientationType {
m.a.Log.Method("GetEscrowOrientation", nil)
if acceptor.Cap.OrientationExt {
return acceptor.EscrowOrientation
}
return enum.OrientationUnknownOrientation
}

func (m *MethodsObj) GetOrientationControl() enum.OrientationControlType {
func (m *MethodsOrientationGetObj) Control() enum.OrientationControlType {
m.a.Log.Method("GetOrientationControl", nil)
return acceptor.OrientationCtl
}

func (m *MethodsObj) SetOrientationControl(v enum.OrientationControlType) {
m.a.Log.Method("SetOrientationControl", nil)
acceptor.OrientationCtl = v
}

func (m *MethodsObj) GetOrientationCtlExt() enum.OrientationControlType {
func (m *MethodsOrientationGetObj) ControlEscrow() enum.OrientationControlType {
m.a.Log.Method("GetOrientationCtlExt", nil)
return acceptor.OrientationCtlExt
}

func (m *MethodsObj) SetOrientationCtlExt(v enum.OrientationControlType) {
//

func (m *MethodsOrientationGetObj) CapEscrow() bool {
m.a.Log.Method("GetCapOrientationExt", nil)
return acceptor.Cap.OrientationExt
}

////

func (m *MethodsOrientationSetObj) Control(v enum.OrientationControlType) {
m.a.Log.Method("SetOrientationControl", nil)
acceptor.OrientationCtl = v
}

func (m *MethodsOrientationSetObj) ControlEscrow(v enum.OrientationControlType) {
m.a.Log.Method("SetOrientationCtlExt", nil)
acceptor.OrientationCtlExt = v
}
38 changes: 29 additions & 9 deletions methods_variant.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@ import (

////////////////////////////////////

func (m *MethodsObj) GetCapVariantID() bool {
m.a.Log.Method("GetCapVariantID", nil)
return acceptor.Cap.VariantID
type MethodsVariantObj struct {
a *MpostObj
Get MethodVariantGetObj
}

func (m *MethodsObj) GetCapVariantPN() bool {
m.a.Log.Method("GetCapVariantPN", nil)
return acceptor.Cap.VariantPN
type MethodVariantGetObj struct{ a *MpostObj }

func (m *MethodsObj) newVariant() *MethodsVariantObj {
obj := MethodsVariantObj{}

obj.a = m.a
obj.Get.a = m.a

return &obj
}

func (m *MethodsObj) GetVariantNames() []string {
////////////////

func (m *MethodVariantGetObj) Names() []string {
m.a.Log.Method("GetVariantNames", nil)

err := acceptor.Verify(true, "VariantNames")
Expand Down Expand Up @@ -49,7 +57,7 @@ func (m *MethodsObj) GetVariantNames() []string {
return names
}

func (m *MethodsObj) GetVariantID() string {
func (m *MethodVariantGetObj) ID() string {
m.a.Log.Method("GetVariantID", nil)

err := acceptor.Verify(acceptor.Cap.VariantID, "VariantID")
Expand All @@ -73,7 +81,7 @@ func (m *MethodsObj) GetVariantID() string {
return ""
}

func (m *MethodsObj) GetVariantPN() string {
func (m *MethodVariantGetObj) PN() string {
m.a.Log.Method("GetVariantPN", nil)

err := acceptor.Verify(acceptor.Cap.VariantPN, "VariantPN")
Expand All @@ -96,3 +104,15 @@ func (m *MethodsObj) GetVariantPN() string {

return ""
}

//

func (m *MethodVariantGetObj) CapID() bool {
m.a.Log.Method("GetCapVariantID", nil)
return acceptor.Cap.VariantID
}

func (m *MethodVariantGetObj) CapPN() bool {
m.a.Log.Method("GetCapVariantPN", nil)
return acceptor.Cap.VariantPN
}

0 comments on commit 4c7ddf9

Please sign in to comment.