20170424_jeffrey - silenceuncrio/diary GitHub Wiki

0920

上禮拜五下班前把 M300 的 RTC 電池拔起來並把 M300 的電源拔掉

今天上電的結果觀察到時間日期停留在上禮拜五

### module <system> init
...
root@Mobile Router:~# date
Fri Apr 21 23:49:20 TAIPEI 2017
root@Mobile Router:~# date
Fri Apr 21 23:49:33 TAIPEI 2017
...

不過後續的幾次拔電上電發現時間日期都從類似的時間開始起跳

並不是上電了 RTC 就會 Keep 住時間

0945

review

engineering notebook

1000

M300 週會

先幫 Ariel 補一下 SIM PUK 的 WEB UI

不過先等 aaron 把目前的 develop branch 切一條到 release branch 再說

因為 SIM PUK 的 WEB UI 預計是要加到這一次的 release

1135

關於我這禮拜五要跟工規顧問討論的 Link failover 的 survey

我可以參考 areil 做的比較表來抓幾個比較對象看他們做了什麼 Link failover 的功能

  • Moxa (OnCell 5004/OnCell 5104-HSPA)
  • Westermo (MRD-405)
  • RUGGEDCOM (RM1224)
  • Hirchmann (OWL LTE M12)

先看 Moxa 的

OnCell 5004/5104-HSPA Series

上禮拜 survey 的 fail redundancy 有以下的功能

  • STP - Spanning Tree Protocol
  • RSTP - Rapid Spanning Tree Protocol
  • MSTP - Multiple Spanning Tree Protocol
  • LACP - Link Aggregation Control Protocol‎
  • ERPS - Ethernet Ring Protection Switching
  • VRRP - Virtual Router Redundancy Protocol
  • WAN Failover - Load Balancing and Failover for multi-WAN Routers

先從 MOXA 的 Datasheet 看起

  • STP - no
  • RSTP - no
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - yes(Cellular link redundancy with dual-SIM GuaranLink support)

掃一下 manual 看看有沒有漏掉的... 沒有

不過也沒在 manual 看到任何關於 GuaranLink 的描述

繼續 Industrial 4G LTE Gateway/Router - MRD-405

先看 Datasheet

  • STP - no
  • RSTP - no
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - no

全部都沒有

1300

RM1224 - Mobile wireless router for high bandwidth remote communication

這台也是全部都沒有

OWL LTE M12 Industrial Cellular Router

  • STP - no
  • RSTP - no
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - yes
  • WAN Failover - yes(Dual-SIM fail over functionality)

問題來了

那到底甚麼樣的機種才會有呢?

就從 MOXA 來看好了

1320

先看 Industrial Ethernet Switches 系列

找幾台跟我們相似的機種來看看

IKS-G6524A/G6824A Series - 24G-port Layer 2 / Layer 3 full Gigabit managed Ethernet switches

  • STP - yes
  • RSTP - yes
  • MSTP - yes
  • LACP - yes
  • ERPS - yes
  • VRRP - yes
  • WAN Failover - no

試著找更便宜但有相似功能的機種

IM-6700A Series - Fast Ethernet modules

  • STP - no
  • RSTP - no
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - no

太便宜嗎

SDS-3008 Series - Industrial 8-port smart Ethernet switches

  • STP - yes
  • RSTP - yes
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - no

EDS-405A/408A Series - 5 and 8-port entry-level managed Ethernet switches

  • STP - yes
  • RSTP - yes
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - no

EDS-P506A-4PoE Series - 6-port managed Ethernet switches with 4 IEEE 802.3af/at PoE+ ports

  • STP - yes
  • RSTP - yes
  • MSTP - yes
  • LACP - yes
  • ERPS - yes(Turbo Ring and Turbo Chain)
  • VRRP - no
  • WAN Failover - no

EDS-P506A-4PoE Series - 12G-port full gigabit PoE+ managed Ethernet switches

  • STP - yes
  • RSTP - yes
  • MSTP - yes
  • LACP - yes
  • ERPS - yes(Turbo Ring and Turbo Chain)
  • VRRP - no
  • WAN Failover - no

PT-G503-PHR-PTP Series - IEC 61850-3/62439-3 3-port full Gigabit managed redundancy boxes

  • STP - yes
  • RSTP - yes
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - no

這一款有特別標榜 PRP/HSR

The PT-G503-PHR-PTP series redundancy boxes (RedBoxes) are compliant with the latest standardized redundancy protocols for industrial automation networks, IEC 62439-3 Clause 4 (Parallel Redundancy Protocol, PRP) and IEC 62439-3 Clause 5 (Highavailability Seamless Redundancy, HSR).

PRP/HSR ensures the highest system availability and data integrity for mission-critical applications in electrical substation and/or process automation systems that require zero recovery time redundancy.

The redundant protocols Coupling and QuadBox are also supported.

With Coupling and QuadBox, HSR rings can be connected to make the redundant network more versatile.

The PT-G503-PHR-PTP series comes with three 10/100/1000BaseT(X) and 100/1000BaseSFP slot combo ports.

1410

看一下 Industrial Cellular Solutions - Cellular Router/Gateway/IP Modem 系列

我們就挑兩個有 LTE 的系列

看一下 redundancy 有啥

  • STP - yes
  • RSTP - yes
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - yes(Cellular link redundancy with dual-SIM GuaranLink support)

1420

Industrial Wireless LAN (WLAN) Solutions - Wireless AP/Bridge/Client 系列

就挑 AWK-5232-RCC Series - Industrial IEEE 802.11a/b/g/n dual-radio wireless AP/bridge/client

  • STP - yes
  • RSTP - yes
  • MSTP - no
  • LACP - no
  • ERPS - no
  • VRRP - no
  • WAN Failover - na

1430

Industrial Secure Routers 系列

EDR-810 Series - 8+2G multiport industrial secure router with switch/firewall/NAT/VPN

  • STP - yes
  • RSTP - yes
  • MSTP - no
  • LACP - no
  • ERPS - yes(Turbo Ring)
  • VRRP - yes
  • WAN Failover - na

出現了一個最相似的候選人

router 上支援 lan 端的 redundancy

這個系列值得深入研究一下

1435

Industrial Ethernet Gateways Solution 方案

唯一出現的 redundant 字眼 - Redundant dual DC power inputs and relay output

1430

Network Management Software 方案

這個方案不列入比較

1440

針對 MOXA 的 Industrial Ethernet Solutions

看看那些 section 有提到我這次 survey care 的 redundancy 字眼

Section Redundancy functions Products
Industrial Ethernet Switches STP, RSTP, MSTP, Turbo Ring v1/v2, Turbo Chain, LACP EDS-P506A-4PoE Series
PRP/HSR, RSTP Transparent PT-G503-PHR-PTP Series
Industrial Wireless LAN STP, RSTP AWK-5232-RCC Series
Industrial Cellular dual-SIM GuaranLink OnCell G3470A-LTE Series
Industrial Secure Routers STP, RSTP, Turbo Ring V2, Ring Coupling, Dual Homing, VRRP EDR-810 Series
Industrial Ethernet Gateways
Network Management

我想我禮拜五就根據這張表大致的介紹一下每個 redundancy function 是什麼就好了

至於我們公司要怎麼來發展我們的 redundancy function 就讓 老闆 和 工規顧問 來決定吧

1520

這禮拜預計要 release 的版本目前在 relwase/v1.4 這個 branch

➜  prosrc git:(release/v1.4) git branch
  develop
  feature/lan
  hotfix/user_manual
  jeffreytmp
  master
  nandflash
* release/v1.4

我要在這個 branch 上面來實作 SIM PUK 的 WEB UI

1555

SIM PUK 的 WEB UI 已完工... 上 code

1600

review 上禮拜五對於 monkeyjj GroupBuying 資料庫的進度

目前計有 6 個 table

  • Users
  • Directors
  • Groups
  • GroupOrders
  • Products
  • OrderProducts

上禮拜五看了 Users, Directors, GroupsProducts

不過 Products 只看到最基本的 SELECT * FROM Products

如果使用者想知道是誰開了這一團的話

需要一併參考 Users, DirectorsGroups

等於是 Users, Directors, GroupsProducts 四個 table 一起使用了

SELECT p.ProductId, p.Name, p.Cost, g.GroupId, g.Name, g.PeriodStart, g.PeriodEnd, u.UserId, u.UserName, u.Email
FROM Products p
INNER JOIN Groups g on p.GroupId = g.GroupId
INNER JOIN Directors d on g.DirectorId = d.DirectorId 
INNER JOIN Users u on d.UserId = u.UserId
ProductId Name Cost GroupId Name PeriodStart PeriodEnd UserId UserName Email
1 皇冠熊 220 1 輕鬆熊一團 2017­04­12 2017­04­18 1 jenny [email protected]
2 熊哥 220 1 輕鬆熊一團 2017­04­12 2017­04­18 1 jenny [email protected]
3 熊妹 220 1 輕鬆熊一團 2017­04­12 2017­04­18 1 jenny [email protected]
4 幸運草熊 220 1 輕鬆熊一團 2017­04­12 2017­04­18 1 jenny [email protected]

1615

再來是 GroupOrders

SELECT * FROM GroupOrders
GroupOrderId DateOrdered UserId GroupId
1 2017­04­13 2 1
2 2017­04­13 3 1
3 2017­04­14 4 1
4 2017­04­15 5 1
5 2017­04­16 6 1
6 2017­04­17 7 1
7 2017­04­17 8 1

一步一步前進

先把 UsersGroups 拉進來一起看

SELECT gor.GroupOrderId, gor.DateOrdered, u.UserName, u.Email, g.Name
FROM GroupOrders gor
INNER JOIN Users u on gor.UserId = u.UserId
INNER JOIN Groups g on gor.GroupId = g.GroupId
GroupOrderId DateOrdered UserName Email Name
1 2017­04­13 謝嘎 [email protected] 輕鬆熊一團
2 2017­04­13 Minie Heidi [email protected] 輕鬆熊一團
3 2017­04­14 Li Ying Wei [email protected] 輕鬆熊一團
4 2017­04­15 邱佩萱 [email protected] 輕鬆熊一團
5 2017­04­16 Huei Wun [email protected] 輕鬆熊一團
6 2017­04­17 Tina Wang [email protected] 輕鬆熊一團
7 2017­04­17 劉羿伶 [email protected] 輕鬆熊一團

1630

再來是 OrderProducts

SELECT * FROM OrderProducts
OrderProductId Quantity TotalCost GroupOrderId ProductId
1 1 220 1 4
2 1 220 2 4
3 1 220 3 2
4 1 220 3 1
5 2 440 3 4
6 1 220 4 2
7 1 220 4 3
8 1 220 5 4
9 1 220 6 3
10 1 220 6 4
11 1 220 7 1
12 1 220 7 2
13 1 220 7 4

先把 Products.Name 帶進來吧

SELECT op.GroupOrderId, op.Quantity, p.Name, op.TotalCost
FROM OrderProducts op
INNER JOIN Products p on op.ProductId = p.ProductId
GroupOrderId Quantity Name TotalCost
1 1 幸運草熊 220
2 1 幸運草熊 220
3 2 幸運草熊 440
5 1 幸運草熊 220
6 1 幸運草熊 220
7 1 幸運草熊 220
3 1 熊哥 220
4 1 熊哥 220
7 1 熊哥 220
4 1 熊妹 220
6 1 熊妹 220
3 1 皇冠熊 220
7 1 皇冠熊 220

再在 GroupOrdersUsers 帶進來

這樣就可以知道誰在什麼時候買了什麼

SELECT u.UserName, gor.DateOrdered, op.Quantity, p.Name, op.TotalCost
FROM OrderProducts op
INNER JOIN Products p on op.ProductId = p.ProductId
INNER JOIN GroupOrders gor on op.GroupOrderId = gor.GroupOrderId
inner JOIN Users u on gor.UserId = u.UserId
UserName DateOrdered Quantity Name TotalCost
謝嘎 2017­04­13 1 幸運草熊 220
Minie Heidi 2017­04­13 1 幸運草熊 220
Li Ying Wei 2017­04­14 2 幸運草熊 440
Huei Wun 2017­04­16 1 幸運草熊 220
Tina Wang 2017­04­17 1 幸運草熊 220
劉羿伶 2017­04­17 1 幸運草熊 220
Li Ying Wei 2017­04­14 1 熊哥 220
邱佩萱 2017­04­15 1 熊哥 220
劉羿伶 2017­04­17 1 熊哥 220
邱佩萱 2017­04­15 1 熊妹 220
Tina Wang 2017­04­17 1 熊妹 220
Li Ying Wei 2017­04­14 1 皇冠熊 220
劉羿伶 2017­04­17 1 皇冠熊 220

我們可以為了每個 user 出一張購買清單

比如 謝嘎 這個 User

SELECT u.UserName, gor.DateOrdered, op.Quantity, p.Name, op.TotalCost
FROM OrderProducts op
INNER JOIN Products p on op.ProductId = p.ProductId
INNER JOIN GroupOrders gor on op.GroupOrderId = gor.GroupOrderId
INNER JOIN Users u on gor.UserId = u.UserId
WHERE `UserName` LIKE '謝嘎'
UserName DateOrdered Quantity Name TotalCost
謝嘎 2017­04­13 1 幸運草熊 220

這個 User 只有一筆

找個多筆的 User

例如 劉羿伶

SELECT u.UserName, gor.DateOrdered, op.Quantity, p.Name, op.TotalCost
FROM OrderProducts op
INNER JOIN Products p on op.ProductId = p.ProductId
INNER JOIN GroupOrders gor on op.GroupOrderId = gor.GroupOrderId
INNER JOIN Users u on gor.UserId = u.UserId
WHERE `UserName` LIKE '劉羿伶'
UserName DateOrdered Quantity Name TotalCost
劉羿伶 2017­04­17 1 皇冠熊 220
劉羿伶 2017­04­17 1 熊哥 220
劉羿伶 2017­04­17 1 幸運草熊 220

那怎麼利用 SQL 來把這三筆紀錄的 TotalCost 作加總呢?

SELECT u.UserName, gor.DateOrdered, SUM(op.TotalCost) TotalCost
FROM OrderProducts op
INNER JOIN Products p on op.ProductId = p.ProductId
INNER JOIN GroupOrders gor on op.GroupOrderId = gor.GroupOrderId
INNER JOIN Users u on gor.UserId = u.UserId
GROUP BY u.UserName
UserName DateOrdered TotalCost
Huei Wun 2017­04­16 220
Li Ying Wei 2017­04­14 880
Minie Heidi 2017­04­13 220
Tina Wang 2017­04­17 440
劉羿伶 2017­04­17 660
謝嘎 2017­04­13 220
邱佩萱 2017­04­15 440

哇... 真方便阿

看來得跟 SQL 多親近親近才行

1730

不過發現我需要新增一個 attribute 來追蹤每個 User 的付款狀況

那就在 GroupOrders 新增一個 attribute Payment

CREATE TABLE GroupOrders (
  GroupOrderId int(11) NOT NULL AUTO_INCREMENT,
  DateOrdered date NOT NULL,

  Payment tinyint(1) NOT NULL DEFAULT '0',

  UserId int(11) NOT NULL,
  GroupId int(11) NOT NULL,

  PRIMARY KEY (GroupOrderId),
  FOREIGN KEY UserId (UserId)
    REFERENCES Users (UserId) 
    ON UPDATE CASCADE ON DELETE RESTRICT,
  FOREIGN KEY GroupId (GroupId)
    REFERENCES Groups (GroupId) 
    ON UPDATE CASCADE ON DELETE RESTRICT,
  INDEX DateOrdered (DateOrdered)
);

有了這個 attribute 之後

試著利用下述的 SQL Command

SELECT gor.GroupOrderId, gor.DateOrdered, gor.Payment, u.UserName,  SUM(op.TotalCost) TotalCost
FROM OrderProducts op
INNER JOIN Products p on op.ProductId = p.ProductId
INNER JOIN GroupOrders gor on op.GroupOrderId = gor.GroupOrderId
INNER JOIN Users u on gor.UserId = u.UserId
GROUP BY u.UserName  
ORDER BY gor.GroupOrderId ASC

可以得到一個表格

方便團購的團主來盤誰付款 (payment) 了沒

GroupOrderId DateOrdered Payment UserName TotalCost
1 2017­04­13 0 謝嘎 220
2 2017­04­13 0 Minie Heidi 220
3 2017­04­14 0 Li Ying Wei 880
4 2017­04­15 0 邱佩萱 440
5 2017­04­16 0 Huei Wun 220
6 2017­04­17 0 Tina Wang 440
7 2017­04­17 0 劉羿伶 660

1800

回到 redundancy functions survey

參考 Communication Redundancy User’s Manual

從中可以對 MOXA 的 redundancy functions STP/RSTP/MSTP, Turbo RingTurbo Chain 有基本的認識

參考 Moxa Managed Ethernet Switch (UI_2.0_FW_4.x) User’s Manual 可以了解什麼是 LACP

參考 Layer 3 Routing User’s Manual (UI 2.0) 可以了解什麼是 VRRP

⚠️ **GitHub.com Fallback** ⚠️