Skip to content

Commit

Permalink
rack rotation replaces orientation
Browse files Browse the repository at this point in the history
removes room floorUnit
  • Loading branch information
GeremWD committed Jun 8, 2023
1 parent 69b6847 commit 688954d
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 104 deletions.
13 changes: 4 additions & 9 deletions API/models/schemas/rack_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -51,7 +46,7 @@
"required": [
"height",
"heightUnit",
"orientation",
"rotation",
"posXYUnit",
"posXYZ",
"size",
Expand All @@ -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}",
Expand Down
6 changes: 0 additions & 6 deletions API/models/schemas/room_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"attributes": {
"type": "object",
"properties": {
"floorUnit": {
"type": "string",
"enum": ["m", "t", "f"]
},
"height": {
"type": "string",
"$ref": "refs/types.json#/definitions/float"
Expand Down Expand Up @@ -53,7 +49,6 @@
}
},
"required": [
"floorUnit",
"height",
"heightUnit",
"posXY",
Expand All @@ -68,7 +63,6 @@
"examples": [
{
"attributes": {
"floorUnit": "t",
"height": "2.8",
"heightUnit": "m",
"axisOrientation": "+x+y",
Expand Down
10 changes: 0 additions & 10 deletions API/models/schemas/room_template_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"axisOrientation",
"sizeWDHm",
"slug",
"floorUnit"
],
"dependentRequired": {
"vertices": ["tileAngle", "center"],
Expand Down Expand Up @@ -48,14 +47,6 @@
},
"createdDate": {
},
"floorUnit": {
"type": "string",
"enum": [
"m",
"t",
"f"
]
},
"id": {
"type": "string"
},
Expand Down Expand Up @@ -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" : [
Expand Down
2 changes: 1 addition & 1 deletion API/models/schemas/test_data/KO/rack1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
1 change: 0 additions & 1 deletion API/models/schemas/test_data/KO/room1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"attributes": {
"floorUnit": "t",
"height": "2.8",
"heightUnit": "m",
"axisOrientation": "x+y",
Expand Down
1 change: 0 additions & 1 deletion API/models/schemas/test_data/KO/room_template2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"category": "room",
"axisOrientation": "+x+z",
"sizeWDHm": [8.25, -4, -0.53452443],
"floorUnit": "cm",
"vertices": [
[0, 0],
[8.3, 0],
Expand Down
1 change: 0 additions & 1 deletion API/models/schemas/test_data/OK/room_template1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
1 change: 0 additions & 1 deletion API/models/validateEntity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
53 changes: 34 additions & 19 deletions CLI/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,6 @@ type createRoomNode struct {
rotation node
size node
axisOrientation node
floorUnit node
template node
}

Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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
Expand Down
18 changes: 4 additions & 14 deletions CLI/controllers/commandController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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"])
Expand Down
16 changes: 6 additions & 10 deletions CLI/other/LangReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
32 changes: 13 additions & 19 deletions CLI/other/man/plus.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 688954d

Please sign in to comment.