---
# System prepended metadata

title: New POS Tablet Design
tags: [NewPOS]

---

---
tags: NewPOS
---

# New POS Tablet Design

## Tablet design
* [Tabletop mode](#Tabletop-mode)
* [Handheld mode](#Handheld-mode)
### Usecase
store broker always connected.
* usemode switch
```plantuml
:user: -r-> (case0)
"Plugging/Unplugging" as (case0)
"store broker:MPOS" as (case1)
"dock broker:New POS" as (case2)
(case0) ..> (case1):<<include>>
(case0) <.. (case2):<<extend>>
"Handheld mode" as (case3)
"Tabletop mode" as (case4)
(case1) <.. (case3):<<include>>
(case2) <.. (case4):<<include>>
```

### activity diagram
[Provided by the main activity-diagram](https://hackmd.io/@tk3c-mpos/B16lfjsAu)

### Usemode switch
* The tablet can only bound one dock at the same time.
* Desktop mode and handheld mode are controlled by plug.
* Use the serial number of the tablet as the topic bound to the dock

#### Tabletop mode
* activity diagram
```plantuml
@startuml
start
:plugin;
:dock publish infomation;
:get dock info and connect dock broker;
:subscribe dock topic;
:send binding message;
if(binding success?) then(yes)
:tablet mode switch;
    stop
else(no)
    :disconnect dock;
    end
endif
@enduml
```

* sequence-diagram
topic list:
    - <font color=blue>SN</font>:tk3c/device/{Serial Number}
    - <font color=blue>dock inbobund</font>:{scope}/dock/{dockUID}
    - <font color=blue>dock outbound</font>:{scope}/dock/{dockUID}/outbound

```plantuml
actor       user       as user
participant Tablet as tablet
participant StoreBroker as store
participant DockBroker as dock
collections topic

tablet <-> store:connected
tablet <- topic:subscribe <font color=blue>SN
user -> dock:plugin(<font color=blue>real/mock</font>)
dock -> topic:publish message to <font color=blue>SN
topic -> tablet:get dock info
tablet -> dock:connected
tablet -> topic:subscribe dock topic
tablet -> topic:publish binding message to <font color=blue>dock inbobund
topic -> dock
dock -> topic:publish binding result to <font color=blue>dock outbound
topic -> tablet

```

##### mock plugin
* Need to be pre-connected to the dock broker
* publish bindtest message
:::info
[bindtest](https://hackmd.io/P7FuhzegRvObKvrjEG0m_Q#2Allocated-Event%E6%B8%AC%E8%A9%A6%E7%94%A8-%E7%84%A1%E9%9C%80%E6%8F%92%E8%A3%9D%E7%BD%AE)
:::


#### Handheld mode
* activity diagram
```plantuml
@startuml
start
:unplug;
:dock publish unbind message(qos=2);
:tablet got message;
:disconnect dock broker;
:tablet mode switch;
@enduml
```

---
### MQTT message adaptor
* usecase
```plantuml
'left to right direction

actor user

usecase (Select POS page and bindding the channels to be used) as case0
user -r-> case0

usecase (Select input device & input data) as case1
case0 <.d. case1:<<extend>>

usecase (message handler) as case2
case1 .r.> case2:<<include>>

usecase (Put the data in the correct place) as case3
case2 ..> case3:<<include>>

```

* sequence-diagram


```plantuml
actor       user       as user
participant posPage as page
participant dock as dock
participant messageHandler as msghandler
collections state as vuex

vuex -> page: page mapping state
user -> dock : input message 
dock -> msghandler : publish message
msghandler -> vuex: change state
note left
    Need to check that the current page 
    has state mapped.
    
    Message discarded if not used.
end note
note right 
    The information 
    entered by the dock 
    is stored in the state.
end note
vuex -> page: 
note left
    put the data to the page .
end note
page -> state:clear state
note right 
    Avoid entering the same data 
    state will not notify.
end note

```

---
### Dock service status tracking

### first connect
* tablet plug in the dock
* mqtt connect to dock
* client publish allocated message to dock
* dock publish svcinfo

### reconnect
* get dock [svcInfo](https://hackmd.io/@tk3c-mpos/ryYoCmSRu/https%3A%2F%2Fhackmd.io%2FP7FuhzegRvObKvrjEG0m_Q#Event) and update state capabilities

### update dock capabilities status
* update dock capabilities when dock publish [dock.info](https://hackmd.io/@tk3c-mpos/ryYoCmSRu/https%3A%2F%2Fhackmd.io%2FP7FuhzegRvObKvrjEG0m_Q#dock-service)
 message to the outbound topic

```plantuml
@startuml

[*] --> State_mqtt: plug in the dock
State_mqtt : mqtt connect to dock
state after_connect {
    State_mqtt -> State_capabilities: update capabilities
    note on link 
  Proactively obtain 
  information(svcInfo)
    end note
    note right of State_capabilities
    If capabilities state is change,
    popup warning message.
    end note
    State_capabilities : dock capabilities(service)

    state "dock service state" as dock {
        [*] --> State_capabilities: update capabilities
        note on link 
          dock outbound message(dock.info)
        end note
    }
}

@enduml
```