# 閘門 IotGate spec ## redux state - api 規格 https://amr-api.amrcloud.nr100.cloudns.cl/api/swagger/#/MapBulk/MapBulk_IotGate_update - UI flow https://axxaec.axshare.com/#id=y260zq&p=_c-21_%E9%96%98%E9%96%80-%E8%A8%AD%E7%BD%AE&g=1 - GUI XD https://xd.adobe.com/view/c330d86b-26b4-4845-8d7a-160d32630bf6-9663/screen/90ec3952-fb5c-45bf-9143-d8aa28800cf0/specs/ ``` // IotGate redux state [ { id: uuid/number, tmpId: uuid, // 新增時 post 需要的 tmp_id point1: uuid/number/null, point2: uuid/number/null, insidePoint: uuid/number/null, outsidePoint: uuid/number/null, insidePassageLength: uuid/null, outsidePassageLength: uuid/null, insideWorkingArea: uuid/number/null, outsideWorkingArea: uuid/number/null, name: string, passageLength: number, // 閘門長度 robotWaitDistance: number, // 機器人等候距離 IOChannel: [], // array enableActionList: [], apiType: init/post/put, originalLatLng, [], // point1 與 point2 地圖未旋轉前座標 } ] ``` ## api 新增串接流程 - 流程: maparea -> point -> IOChannel -> IotGate 1. 經由 /api/map/MapBulk/{map_id}/WorkingArea 這支 api 取得新增上去的地圖區塊(maparea)的真實 id ``` // payload { "working_area_list": [ { "working_area_name": "inside area", "area_type": "maparea", "geo_json": {}, // geo_json 座標 "tmp_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6" }, { "working_area_name": "outside area", "area_type": "maparea", "geo_json": {}, // geo_json 座標 "tmp_id": "869701c4-1630-48e1-bb5e-32736bc0e922" }, ] } // api response 裡的 tmp_compare 有 tmp_id 與 id 的對照資料 tmp_compare:{ 3fa85f64-5717-4562-b3fc-2c963f66afa6: d5fa1afb-5dbf-4146-87a1-ae2a27525442, 869701c4-1630-48e1-bb5e-32736bc0e922: be4ec8ef-9712-4f6b-b080-59bb39de42a2 } ``` 2. 將取得的 maparea 真實 id ,放進 /api/map/MapBulk/{map_id}/Point 要新增的 inside_point 與 outside_point,並且取得真實的 point id ``` // payload { "point_list": [ { "point_name": "insidePoint", "point_type": "Iot_gate", "x": 22, "y": 18, "z": 0, "heading": 90, "enable": true, "maparea": "d5fa1afb-5dbf-4146-87a1-ae2a27525442", "tmp_id": "ce819584-ec46-4291-98cd-a99f9c6e781d" }, { "point_name": "outsidePoint", "point_type": "Iot_gate", "x": 32, "y": 48, "z": 0, "heading": 180, "enable": true, "maparea": "be4ec8ef-9712-4f6b-b080-59bb39de42a2", "tmp_id": "string" } ] } // api response 裡的 tmp_compare 有 tmp_id 與 id 的對照資料 tmp_compare:{ ce819584-ec46-4291-98cd-a99f9c6e781d: 152, f40c55f5-a314-440b-9834-73efda4eaad9: 153 } ``` 3. IO Channel 尚未實作先不考慮 4. 透過 /api/map/MapBulk/{map_id}/IotGate 這支 api 將剛剛取取得的 insidePoint 與 outsidePoint id 放進 payload ``` // payload { "iot_gate_list": [ { "id": 0, "inside_point": 152, "outside_point": 153, "inside_working_area": "d5fa1afb-5dbf-4146-87a1-ae2a27525442", "outside_working_area": "be4ec8ef-9712-4f6b-b080-59bb39de42a2", "geo_json": { "name": '閘門01', "passage_length": 0.1, "point1": { lat: 0, lng: 0 }, "point2": { lat: 0, lng: 0 }, }, "iochannel_target": [], "tmp_id": "6213f51b-990c-4de8-aa45-286ee2c7a0d0" }, ] } ```