diff --git a/API/models/schemas/rack_schema.json b/API/models/schemas/rack_schema.json index b2c77f628..8482f9c1b 100644 --- a/API/models/schemas/rack_schema.json +++ b/API/models/schemas/rack_schema.json @@ -15,14 +15,9 @@ "type": "string", "enum": ["mm", "cm", "m", "U", "OU", "f"] }, - "orientation": { + "rotation": { "type": "string", - "enum": [ - "front", - "rear", - "left", - "right" - ] + "$ref": "refs/types.json#/definitions/vector3" }, "posXYZ": { "type": "string", @@ -51,7 +46,7 @@ "required": [ "height", "heightUnit", - "orientation", + "rotation", "posXYUnit", "posXYZ", "size", @@ -65,7 +60,7 @@ "attributes": { "height": "47", "heightUnit": "U", - "orientation": "front", + "rotation": "{\"x\":45 ,\"y\":45 ,\"z\":45}", "posXYUnit": "m", "posXYZ": "{\"x\":4.6666666666667 ,\"y\": -2 ,\"z\":0}", "size": "{\"x\":80 ,\"y\":100.532442}", diff --git a/API/models/schemas/room_schema.json b/API/models/schemas/room_schema.json index 4fc989113..99d7234e3 100644 --- a/API/models/schemas/room_schema.json +++ b/API/models/schemas/room_schema.json @@ -7,10 +7,6 @@ "attributes": { "type": "object", "properties": { - "floorUnit": { - "type": "string", - "enum": ["m", "t", "f"] - }, "height": { "type": "string", "$ref": "refs/types.json#/definitions/float" @@ -53,7 +49,6 @@ } }, "required": [ - "floorUnit", "height", "heightUnit", "posXY", @@ -68,7 +63,6 @@ "examples": [ { "attributes": { - "floorUnit": "t", "height": "2.8", "heightUnit": "m", "axisOrientation": "+x+y", diff --git a/API/models/schemas/room_template_schema.json b/API/models/schemas/room_template_schema.json index 2af70b83b..bb41471a8 100644 --- a/API/models/schemas/room_template_schema.json +++ b/API/models/schemas/room_template_schema.json @@ -7,7 +7,6 @@ "axisOrientation", "sizeWDHm", "slug", - "floorUnit" ], "dependentRequired": { "vertices": ["tileAngle", "center"], @@ -48,14 +47,6 @@ }, "createdDate": { }, - "floorUnit": { - "type": "string", - "enum": [ - "m", - "t", - "f" - ] - }, "id": { "type": "string" }, @@ -218,7 +209,6 @@ "category" : "room", "axisOrientation" : "+x+y", "sizeWDHm" : [9.6,22.8,3], - "floorUnit" : "t", "technicalArea" : [5,0,0,0], "reservedArea" : [3,1,1,3], "separators" : [ diff --git a/API/models/schemas/test_data/KO/rack1.json b/API/models/schemas/test_data/KO/rack1.json index 17f6748a0..04425c602 100644 --- a/API/models/schemas/test_data/KO/rack1.json +++ b/API/models/schemas/test_data/KO/rack1.json @@ -2,7 +2,7 @@ "attributes": { "height": "47", "heightUnit": "u", - "orientation": "rear", + "rotation": "{\"x\":0 ,\"y\": 0, \"z\":0}", "posXYUnit": "m", "posXYZ": "{\"x\":4.6666666666667 ,\"y\": -2}", "size": "{\"x\":80 ,\"y\":100.532442}", diff --git a/API/models/schemas/test_data/KO/room1.json b/API/models/schemas/test_data/KO/room1.json index 86ba33fc2..c53cc02d0 100644 --- a/API/models/schemas/test_data/KO/room1.json +++ b/API/models/schemas/test_data/KO/room1.json @@ -1,6 +1,5 @@ { "attributes": { - "floorUnit": "t", "height": "2.8", "heightUnit": "m", "axisOrientation": "x+y", diff --git a/API/models/schemas/test_data/KO/room_template2.json b/API/models/schemas/test_data/KO/room_template2.json index 9fb6e7177..7f6aa0614 100644 --- a/API/models/schemas/test_data/KO/room_template2.json +++ b/API/models/schemas/test_data/KO/room_template2.json @@ -3,7 +3,6 @@ "category": "room", "axisOrientation": "+x+z", "sizeWDHm": [8.25, -4, -0.53452443], - "floorUnit": "cm", "vertices": [ [0, 0], [8.3, 0], diff --git a/API/models/schemas/test_data/OK/room_template1.json b/API/models/schemas/test_data/OK/room_template1.json index d1bcfb2dc..b52293dbd 100644 --- a/API/models/schemas/test_data/OK/room_template1.json +++ b/API/models/schemas/test_data/OK/room_template1.json @@ -3,7 +3,6 @@ "category": "room", "axisOrientation": "+x+y", "sizeWDHm": [8.25, 4.5, 0.5], - "floorUnit": "t", "center": [4.96, 2.19], "vertices": [ [0, 0], diff --git a/API/models/validateEntity_test.go b/API/models/validateEntity_test.go index 39452eeaf..0dcab99a6 100644 --- a/API/models/validateEntity_test.go +++ b/API/models/validateEntity_test.go @@ -98,7 +98,6 @@ func TestErrorValidateJsonSchema(t *testing.T) { "/axisOrientation value must be one of", "/separators/0/type value must be one of", "/vertices/4 minimum 2 items required, but found 1 items", - "/floorUnit value must be one of", "property 'tileAngle' is required, if 'vertices' property exists", "property 'center' is required, if 'vertices' property exists", }, diff --git a/API/resources/Basic Functionality (MDB).postman_collection.json b/API/resources/Basic Functionality (MDB).postman_collection.json index 3c864cb71..430a6023e 100644 --- a/API/resources/Basic Functionality (MDB).postman_collection.json +++ b/API/resources/Basic Functionality (MDB).postman_collection.json @@ -462,7 +462,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"name\": \"R1\",\n \"id\": null,\n \"parentId\": \"{{BuildingID}}\",\n \"category\": \"room\",\n \"description\": [\n \"First room\"\n ],\n \"domain\": \"DEMO\",\n \"attributes\": {\n \"posXY\": \"{\\\"x\\\":0.0,\\\"y\\\":0.0}\",\n \"posXYUnit\": \"m\",\n \"posXYU\": \"m\",\n \"posZ\": \"0\",\n \"posZUnit\": \"m\",\n \"floorUnit\":\"f\",\n \"template\": \"demo.R1\",\n \"rotation\":\"-99\",\n \"axisOrientation\": \"+N+W\",\n \"size\": \"{\\\"x\\\":22.799999237060548,\\\"y\\\":19.799999237060548}\",\n \"sizeUnit\": \"m\",\n \"sizeU\": \"m\",\n \"height\": \"3\",\n \"heightUnit\": \"m\",\n \"heightU\": \"m\"\n }\n}", + "raw": "{\n \"name\": \"R1\",\n \"id\": null,\n \"parentId\": \"{{BuildingID}}\",\n \"category\": \"room\",\n \"description\": [\n \"First room\"\n ],\n \"domain\": \"DEMO\",\n \"attributes\": {\n \"posXY\": \"{\\\"x\\\":0.0,\\\"y\\\":0.0}\",\n \"posXYUnit\": \"m\",\n \"posXYU\": \"m\",\n \"posZ\": \"0\",\n \"posZUnit\": \"m\",\n \"template\": \"demo.R1\",\n \"rotation\":\"-99\",\n \"axisOrientation\": \"+N+W\",\n \"size\": \"{\\\"x\\\":22.799999237060548,\\\"y\\\":19.799999237060548}\",\n \"sizeUnit\": \"m\",\n \"sizeU\": \"m\",\n \"height\": \"3\",\n \"heightUnit\": \"m\",\n \"heightU\": \"m\"\n }\n}", "options": { "raw": { "language": "json" @@ -2724,7 +2724,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"name\": \"Abandoned Room\",\n \"id\": null,\n \"parentId\": \"{{BuildingID}}\",\n \"category\": \"999\",\n \"description\": [\n \"999\"\n ],\n \"domain\": \"999\",\n \"attributes\": {\n \"posXY\": \"999\",\n \"posXYUnit\": \"m\",\n \"posZ\": \"999\",\n \"posZUnit\": \"m\",\n \"template\": \"999\",\n \"axisOrientation\": \"-N-W\",\n \"size\": \"999\",\n \"floorUnit\":\"t\",\n \"sizeUnit\": \"m\",\n \"height\": \"999\",\n \"heightUnit\": \"m\",\n \"rotation\":\"60\"\n }\n}", + "raw": "{\n \"name\": \"Abandoned Room\",\n \"id\": null,\n \"parentId\": \"{{BuildingID}}\",\n \"category\": \"999\",\n \"description\": [\n \"999\"\n ],\n \"domain\": \"999\",\n \"attributes\": {\n \"posXY\": \"999\",\n \"posXYUnit\": \"m\",\n \"posZ\": \"999\",\n \"posZUnit\": \"m\",\n \"template\": \"999\",\n \"axisOrientation\": \"-N-W\",\n \"size\": \"999\",\n \"sizeUnit\": \"m\",\n \"height\": \"999\",\n \"heightUnit\": \"m\",\n \"rotation\":\"60\"\n }\n}", "options": { "raw": { "language": "json" diff --git a/API/resources/OGREE Basic Script (MDB).postman_collection.json b/API/resources/OGREE Basic Script (MDB).postman_collection.json index c4a89913f..1d56b75ab 100644 --- a/API/resources/OGREE Basic Script (MDB).postman_collection.json +++ b/API/resources/OGREE Basic Script (MDB).postman_collection.json @@ -4768,7 +4768,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"name\": \"R1\",\n \"id\": null,\n \"parentId\": \"{{BuildingID}}\",\n \"category\": \"room\",\n \"description\": [\n \"First room\"\n ],\n \"domain\": \"DEMO\",\n \"attributes\": {\n \"posXY\": \"{\\\"x\\\":0.0,\\\"y\\\":0.0}\",\n \"posXYUnit\": \"m\",\n \"posXYU\": \"m\",\n \"posZ\": \"0\",\n \"posZUnit\": \"m\",\n \"template\": \"demo.R1\",\n \"axisOrientation\": \"+N+W\",\n \"size\": \"{\\\"x\\\":22.799999237060548,\\\"y\\\":19.799999237060548}\",\n \"sizeUnit\": \"m\",\n \"sizeU\": \"m\",\n \"floorUnit\":\"f\",\n \"height\": \"3\",\n \"heightUnit\": \"m\",\n \"heightU\": \"m\",\n \"rotation\":\"60\"\n }\n}", + "raw": "{\n \"name\": \"R1\",\n \"id\": null,\n \"parentId\": \"{{BuildingID}}\",\n \"category\": \"room\",\n \"description\": [\n \"First room\"\n ],\n \"domain\": \"DEMO\",\n \"attributes\": {\n \"posXY\": \"{\\\"x\\\":0.0,\\\"y\\\":0.0}\",\n \"posXYUnit\": \"m\",\n \"posXYU\": \"m\",\n \"posZ\": \"0\",\n \"posZUnit\": \"m\",\n \"template\": \"demo.R1\",\n \"axisOrientation\": \"+N+W\",\n \"size\": \"{\\\"x\\\":22.799999237060548,\\\"y\\\":19.799999237060548}\",\n \"sizeUnit\": \"m\",\n \"sizeU\": \"m\",\n \"height\": \"3\",\n \"heightUnit\": \"m\",\n \"heightU\": \"m\",\n \"rotation\":\"60\"\n }\n}", "options": { "raw": { "language": "json" diff --git a/CLI/ast.go b/CLI/ast.go index cd3386566..bd1b57c2c 100644 --- a/CLI/ast.go +++ b/CLI/ast.go @@ -1034,7 +1034,6 @@ type createRoomNode struct { rotation node size node axisOrientation node - floorUnit node template node } @@ -1096,17 +1095,6 @@ func (n *createRoomNode) execute() (interface{}, error) { } attributes["axisOrientation"] = axisOrientation } - if n.floorUnit != nil { - floorUnitAny, err := n.floorUnit.execute() - if err != nil { - return nil, err - } - floorUnit, ok := floorUnitAny.(string) - if !ok { - return nil, fmt.Errorf("floorUnit should be a string") - } - attributes["floorUnit"] = floorUnit - } err = cmd.GetOCLIAtrributes(path, cmd.ROOM, map[string]any{"attributes": attributes}) if err != nil { return nil, err @@ -1117,8 +1105,9 @@ func (n *createRoomNode) execute() (interface{}, error) { type createRackNode struct { path node pos node + unit node + rotation node sizeOrTemplate node - orientation node } func (n *createRackNode) execute() (interface{}, error) { @@ -1138,16 +1127,42 @@ func (n *createRackNode) execute() (interface{}, error) { if !ok || (len(pos) != 2 && len(pos) != 3) { return nil, fmt.Errorf("position should be a vector2 or a vector3") } - orientationAny, err := n.orientation.execute() + unitAny, err := n.unit.execute() + if err != nil { + return nil, err + } + unit, ok := unitAny.(string) + if !ok { + return nil, fmt.Errorf("unit should be a string") + } + attributes := map[string]any{"posXYZ": pos, "posXYUnit": unit} + rotationAny, err := n.rotation.execute() if err != nil { return nil, err } - orientation, ok := orientationAny.(string) - if !ok || (orientation != "front" && orientation != "rear" && orientation != "left" && orientation != "right") { - return nil, fmt.Errorf("orientation should be a front, rear, left or right") + switch rotation := rotationAny.(type) { + case []float64: + attributes["rotation"] = rotation + case string: + switch rotation { + case "front": + attributes["rotation"] = []float64{0, 180, 0} + case "rear": + attributes["rotation"] = []float64{0, 0, 0} + case "left": + attributes["rotation"] = []float64{0, 0, 90} + case "right": + attributes["rotation"] = []float64{0, 0, -90} + case "top": + attributes["rotation"] = []float64{90, 0, 0} + case "bottom": + attributes["rotation"] = []float64{-90, 0, 0} + default: + return nil, fmt.Errorf( + `orientation should be a vector3, or one of the following keywords : + front, rear, left, right, top, bottom`) + } } - attributes := map[string]any{"posXYZ": pos, "orientation": orientation} - sizeOrTemplateAny, err := n.sizeOrTemplate.execute() if err != nil { return nil, err diff --git a/CLI/controllers/commandController.go b/CLI/controllers/commandController.go index b739f69ec..bb7a95f27 100755 --- a/CLI/controllers/commandController.go +++ b/CLI/controllers/commandController.go @@ -1506,7 +1506,6 @@ func GetOCLIAtrributes(Path string, ent int, data map[string]interface{}) error attr = data["attributes"].(map[string]interface{}) baseAttrs := map[string]interface{}{ - "floorUnit": "t", "posXYUnit": "m", "sizeUnit": "m", "heightUnit": "m"} @@ -1564,15 +1563,13 @@ func GetOCLIAtrributes(Path string, ent int, data map[string]interface{}) error case RACK: attr = data["attributes"].(map[string]interface{}) - parentAttr := parent["attributes"].(map[string]interface{}) - //Save orientation because it gets overwritten by + //Save rotation because it gets overwritten by //GetOCLIAtrributesTemplateHelper() - orientation := attr["orientation"] + rotation := attr["rotation"] baseAttrs := map[string]interface{}{ "sizeUnit": "cm", "heightUnit": "U", - "posXYUnit": parentAttr["floorUnit"], } MergeMaps(attr, baseAttrs, false) @@ -1581,9 +1578,9 @@ func GetOCLIAtrributes(Path string, ent int, data map[string]interface{}) error //and parse into templates GetOCLIAtrributesTemplateHelper(attr, data, ent) - //Restore the orientation overwritten + //Restore the rotation overwritten //by the helper func - attr["orientation"] = orientation + attr["rotation"] = rotation if attr["size"] == "" { if State.DebugLvl > 0 { @@ -1884,13 +1881,6 @@ func GetOCLIAtrributesTemplateHelper(attr, data map[string]interface{}, ent int) attr["pillars"] = string(tmp) } - CopyAttr(attr, tmpl, "floorUnit") - if _, ok := attr["floorUnit"]; ok { - if floorUnit, ok := attr["floorUnit"].(string); ok { - attr["floorUnit"] = floorUnit - } - } - CopyAttr(attr, tmpl, "tiles") if _, ok := attr["tiles"]; ok { tmp, _ = json.Marshal(attr["tiles"]) diff --git a/CLI/other/LangReference.md b/CLI/other/LangReference.md index 138d4d0db..31bac77ae 100644 --- a/CLI/other/LangReference.md +++ b/CLI/other/LangReference.md @@ -262,17 +262,15 @@ Placeholder values are assigned to the object upon creation so as to satisfy the [pos] is a Vector2 [x,y] (m,m) [size] is a Vector3 [width,length,height] (m,m,m) [template] is the name of the room template [orientation] is more precise than the building's one: you have to specify the direction of the rows/columns: [+/-X][+/-Y]. eg: +E+N or -W+S -[floorUnit] is optional: by default set to "t" (tiles), can also be m (meters) or f (feet) ``` -+room:path/to/roomName@[pos]@[size]@[orientation]@[floorUnit] ++room:path/to/roomName@[pos]@[size]@[orientation] +room:path/to/roomName@[pos]@[template] -+ro:path/to/roomName@[pos]@[size]@[orientation]@[floorUnit] ++ro:path/to/roomName@[pos]@[size]@[orientation] +ro:path/to/roomName@[pos]@[template] +room:path/to/roomName@[pos] +ro:path/to/roomName@[pos] ``` Placeholder values are assigned to the object upon creation so as to satisfy the object requirements: -- floorUnit = "t" - orientation = "+N+E" - posXYUnit = "m" - sizeUnit = "m" @@ -282,17 +280,15 @@ Placeholder values are assigned to the object upon creation so as to satisfy the #### Create a Rack ``` -+rack:path/to/roomName@[pos]@[size] -+rack:path/to/roomName@[pos]@[template] -+rk:path/to/roomName@[pos]@[size] -+rk:path/to/roomName@[pos]@[template] ++rack:[path]@[pos]@[unit]@[rotation]@[size] ++rack:[path]@[pos]@[unit]@[rotation]@[template] ++rk:[path]@[pos]@[unit]@[rotation]@[size] ++rk:[path]@[pos]@[unit]@[rotation]@[template] ``` Placeholder values are assigned to the object upon creation so as to satisfy the object requirements: - sizeUnit = "m" - height = 0 - heightUnit = "m" -- posXYUnit = "t" -- orientation = "front" - domain = Tenant's Name #### Create a Device diff --git a/CLI/other/man/plus.md b/CLI/other/man/plus.md index 51b2ee690..7d1ad2e92 100644 --- a/CLI/other/man/plus.md +++ b/CLI/other/man/plus.md @@ -40,9 +40,9 @@ Where the ROTATION (rotation attribute) must be a numerical value (ie 45) Where TEMPLATE refers to the bldg template name (which must be already existing) -+ro:PATH/ROOM_NAME@POSITION@ROTATION@SIZE@AXISORIENTATION@FLOORUNIT -+room:PATH/ROOM_NAME@POSITION@ROTATION@SIZE@AXISORIENTATION@FLOORUNIT -User must specify the path, ROOM_NAME, ROTATION, POSITION, SIZE, ORIENTATION and FLOORUNIT ++ro:PATH/ROOM_NAME@POSITION@ROTATION@SIZE@AXISORIENTATION ++room:PATH/ROOM_NAME@POSITION@ROTATION@SIZE@AXISORIENTATION +User must specify the path, ROOM_NAME, ROTATION, POSITION, SIZE and ORIENTATION Where POSITION (posXY attribute) must be a 2 element array/vector of coordinates (ie [1,2]) @@ -53,8 +53,6 @@ Where ROTATION must be a numerical value (ie 36) Where AXISORIENTATION refers to the cardinal directions and can only be of the following format: {[+/-][N/E/W/S][+/-][N/E/W/S]} (ie +N-E) -Where FLOORUNIT refers to the measurement unit for the floor which can only be: {f,m,t} - +ro:PATH/ROOM_NAME@POSITION@ROTATION@SIZE@AXISORIENTATION +room:PATH/ROOM_NAME@POSITION@ROTATION@SIZE@AXISORIENTATION @@ -82,26 +80,22 @@ Where ROTATION must be a numerical value (ie 36) Where TEMPLATE refers to the room template name (which must be already existing) -+rk:PATH/RACK_NAME@POSITION@SIZE@ORIENTATION -+rack:PATH/RACK_NAME@POSITION@SIZE@ORIENTATION -User must specify the path, RACK_NAME, POSITION and SIZE and ORIENTATION ++rack:PATH@POSITION@UNIT@ROTATION@SIZE ++rack:PATH@POSITION@UNIT@ROTATION@TEMPLATE ++rk:PATH@POSITION@UNIT@ROTATION@SIZE ++rk:PATH@POSITION@UNIT@ROTATION@TEMPLATE + +User must specify the PATH, POSITION, UNIT, ROTATION and SIZE/TEMPLATE Where POSITION (posXY attribute) must be a 2 or a 3 element array/vector of coordinates (ie [1,2]) -Where SIZE is a 3 numerical element array/vector (ie [1,2,3]) - -Where ORIENTATION is a string and can only be of the following values: {front,rear,left,right} +Where UNIT must be t, m or f +Where ROTATION is either a string with one of the following values: {front,rear,left,right} or a vector3 of angles in degrees -+rk:PATH/RACK_NAME@POSITION@TEMPLATE@ORIENTATION -+rack:PATH/RACK_NAME@POSITION@TEMPLATE@ORIENTATION -User must specify the path, RACK_NAME, POSITION and SIZE and ORIENTATION and TEMPLATE - -Where POSITION (posXY attribute) must be a 2 or a 3 element array/vector of coordinates (ie [1,2]) - -Where TEMPLATE refers to the rack template name (which must be already existing) +Where SIZE is a 3 numerical element array/vector (ie [1,2,3]) -Where ORIENTATION is a string and can only be of the following values: {front,rear,left,right} +Where TEMPLATE is a path to a template file +dv:PATH/DEVICE_NAME@SLOT_OR_POSU@SIZEUNIT diff --git a/CLI/parser.go b/CLI/parser.go index 9d265cdfa..913a8c263 100644 --- a/CLI/parser.go +++ b/CLI/parser.go @@ -950,14 +950,10 @@ func (p *parser) parseCreateRoom() node { p.expect("@") sizeOrTemplate := p.parseStringOrVec("sizeOrTemplate") if !p.parseExact("@") { - return &createRoomNode{path, posXY, rotation, nil, nil, nil, sizeOrTemplate} + return &createRoomNode{path, posXY, rotation, nil, nil, sizeOrTemplate} } axisOrientation := p.parseString("axisOrientation") - if !p.parseExact("@") { - return &createRoomNode{path, posXY, rotation, sizeOrTemplate, axisOrientation, nil, nil} - } - floorUnit := p.parseString("floorUnit") - return &createRoomNode{path, posXY, rotation, sizeOrTemplate, axisOrientation, floorUnit, nil} + return &createRoomNode{path, posXY, rotation, sizeOrTemplate, axisOrientation, nil} } func (p *parser) parseCreateRack() node { @@ -966,10 +962,12 @@ func (p *parser) parseCreateRack() node { p.expect("@") pos := p.parseExpr("position") p.expect("@") - sizeOrTemplate := p.parseStringOrVec("sizeOrTemplate") + unit := p.parseString("unit") p.expect("@") - orientation := p.parseString("orientation") - return &createRackNode{path, pos, sizeOrTemplate, orientation} + rotation := p.parseStringOrVec("rotation") + p.expect("@") + sizeOrTemplate := p.parseStringOrVec("sizeOrTemplate") + return &createRackNode{path, pos, unit, rotation, sizeOrTemplate} } func (p *parser) parseCreateDevice() node {