Communication Protocols

This page describes the communication protocols used by the MTDomeCSC to communicate with the Lower Level Components.

Command Protocol

Using JSON, this is how the command string should be constructed:

  • The various components are grouped in key, value pairs.

  • Any value may be another collection of key, value pairs.

  • For any command, the string “command” is a key and the name of the command the value. There also is the non-zero, non-negative “commandId” key with a unique, increasing value. Each time any command is sent, the value of “commandId” is increased, even if the same command is repeated. This will be followed by a “parameters” key and the value will be the command parameters as a collection of key, value pairs. If a command doesn’t take any parameters then the value will be empty. In that case, the parameters key may also be omitted.

  • Any command will immediately result in a reply. The reply will always contain three key, value pairs. One key will be “response” with a numeric response code as value. The second key will be “commandId” with the value copied from the command for which the response is sent. The third key will be “timeout” with the timeout as a non-negative numeric value, with 0 meaning “the command is already done”. The list of response codes and their meaning can be found here: Software Response Codes.

    • If the reply is 0 (meaning OK) then it should be accompanied by a timeout value indicating how long it will take to execute the command.

      • The reply to a status command should be given immediately and the timeout value will omitted. The lower level component status returned with the reply will be part of the same message and should be added as a separate key, value pair with the short name of the lower level component as key and a collection of the status parameters with their values as value.

    • If the reply is larger than 0 (meaning ERROR) then the value indicates the error code and the timeout should be set to -1.

  • Strings should be enclosed in single or double quotes. Numerical values should not be enclosed in quotes.

  • Any resulting protocol string should be terminated by CR+LF (’rn’).

For example, commands should be constructed like this (the commandId values are arbitrary):

{
  "commandId": 1,
  "command": "openShutter",
  "parameters": {}
}
{
  "commandId": 2,
  "command": "moveAz",
  "parameters": {
    "azimuth": 1.3962634015954636,
    "azRate": 0.001
  }
}

Replies should be formatted like this (the values are arbitrary, but representative):

{
 "commandId": 32,
  "response": 0,
  "timeout": 20
}
{
 "commandId": 47,
  "response": 2,
  "timeout": -1
}

Status commands, similarly, look like this (the commandId values are arbitrary):

{
 "commandId": 8,
  "command": "statusAMCS",
  "parameters": {}
}
{
 "commandId": 14,
  "command": "statusLCS",
  "parameters": {}
}

Configuration Protocol

When configuration parameters are sent, the complete set of configuration parameters for one lower level component will be sent at the same time from the upper level to the lower level. This way the other sub-systems can continue operations while the sub-system(s) that receive configuration parameters can reconfigure themselves. This means that all parameters and their values of the sub-system will be sent together, even the ones for which the value has not changed. This way it can be ensured that always all changes are sent and that no parameter gets forgotten. The upper level component will check and verify that all parameter values fall within the minimum and maximum allowed values for each individual parameter. However, since actual hardware can break it would be necessary for the lower level components to check the configuration parameters as well before applying them.

For the format of the protocol, the system gets specified separately and the configuration parameters to set are specified as an array of [target, setting] pairs. Due to limitations in the LabVIEW JSON support, both the value for the settings keyword and the values for the parameters always need to be arrays, even if only a single value is specified. So this means that the protocol will be of the form

{
  "commandId": 27,
  "command": "config",
  "parameters": {
    "system": "SYSTEM_ID",
    "settings": [
      {
        "target": "ParamX",
        "setting": ["Value1"]
      },
      {
        "target": "ParamY",
        "setting": ["Value1", "Value2", "Value3"]
      }
    ]
  }
}

The reply to the command should be OK with a timeout. The timeout signifies the amount of time needed for the lower level component to verify and apply the configuration parameters. During the timeout no other commands should be accepted by the sub-system except the status command.

If one or more of the parameters could not be configured correctly then this should be reflected in the reply to the status command. If one or more of the proposed values of the parameters fall outside of the range of the minimum and maximum values then none of the parameters should be applied. It therefore is essential to check all values first and to only apply all of them once it has been verified that the values are acceptable.

If during the timeout another command except the status command is received then the reply to that command should be ERROR with an error code signifying that the system is configuring itself (the value of that error code is TBD).

A list of all configurable parameters and their maximum and minimum values can be found here: Lower Level Configuration Parameters.

JSON Schemas

In order to validate the JSON messages, eight JSON schemas have been constructed. When the schemas are used for validation, the keys in the JSON data can be used to select which schema to use. The selection can be done for instance as follows:

  • If the “command” key is present, use the command schema.

  • If the “timeout” key is present, use the response schema.

  • In all other cases, test for the presence of the key containing the sub-system name (“APCS”, “ApSCS”, etc) and use the corresponding status schema.

This is the command schema. It looks rather complex since it covers all available commands (including the “config” command), however otherwise 24 separate schemas would need to be created. For a full list of the commands and their parameters, see Lower Level Commands.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["command"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "command": {
      "enum": [
        "moveAz",
        "moveEl",
        "stopAz",
        "stopEl",
        "stop",
        "crawlAz",
        "crawlEl",
        "setLouvers",
        "closeLouvers",
        "stopLouvers",
        "openShutter",
        "closeShutter",
        "stopShutter",
        "config",
        "restore",
        "park",
        "goStationary",
        "goStationaryAz",
        "goStationaryEl",
        "goStationaryLouvers",
        "goStationaryShutter",
        "setNormalAz",
        "setNormalEl",
        "setNormalLouvers",
        "setNormalShutter",
        "setNormalMonitoring",
        "setNormalThermal",
        "setDegradedAz",
        "setDegradedEl",
        "setDegradedLouvers",
        "setDegradedShutter",
        "setDegradedMonitoring",
        "setDegradedThermal",
        "setTemperature",
        "fans",
        "inflate",
        "statusAMCS",
        "statusApSCS",
        "statusCSCS",
        "statusLCS",
        "statusLWSCS",
        "statusMonCS",
        "statusRAD",
        "statusThCS",
        "exitFault",
        "resetDrivesAz",
        "setZeroAz",
        "resetDrivesShutter",
        "searchZeroShutter"
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "command": {
            "const": "moveAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "position": {
                "type": "number"
              },
              "velocity": {
                "type": "number"
              }
            },
            "required": [
              "position",
              "velocity"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "moveEl"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "position": {
                "type": "number"
              }
            },
            "required": [
              "position"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "stopAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "stopEl"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "stop"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "crawlAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "velocity": {
                "type": "number"
              }
            },
            "required": [
              "velocity"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "crawlEl"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "velocity": {
                "type": "number"
              }
            },
            "required": [
              "velocity"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setLouvers"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "position": {
                "type": "array",
                "minItems": 34,
                "maxItems": 34,
                "items": [
                  {
                    "type": "number"
                  }
                ]
              }
            },
            "required": [
              "position"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "closeLouvers"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "stopLouvers"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "openShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "closeShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "stopShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "config"
          }
        }
      },
      "then": {
        "properties": {
          "settings": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "items": {
              "type": "object",
              "properties": {
                "setting": {
                  "type": "number"
                },
                "target": {
                  "enum": [
                    "jmax",
                    "vmax",
                    "amax"
                  ]
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "system": {
            "enum": [
              "AMCS",
              "LWSCS"
            ]
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "restore"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "park"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "goStationary"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "goStationaryAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "goStationaryEl"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "goStationaryLouvers"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "goStationaryShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setNormalAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setNormalEl"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setNormalLouvers"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setNormalShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setDegradedAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setDegradedEl"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setDegradedLouvers"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setDegradedShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setTemperature"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "temperature": {
                "type": "number"
              }
            },
            "required": [
              "temperature"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "fans"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "speed": {
                "type": "number"
              }
            },
            "required": [
              "speed"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "inflate"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "action": {
                "type": "boolean"
              }
            },
            "required": [
              "action"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusAMCS"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusApSCS"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusCSCS"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusLCS"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusLWSCS"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusMonCS"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusRAD"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "statusThCS"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "exitFault"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "resetDrivesAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "reset": {
                "type": "array",
                "minItems": 5,
                "maxItems": 5,
                "items": [
                  {
                    "type": "integer"
                  }
                ]
              }
            },
            "required": [
              "reset"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "setZeroAz"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "resetDrivesShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "properties": {
              "reset": {
                "type": "array",
                "minItems": 4,
                "maxItems": 4,
                "items": [
                  {
                    "type": "integer"
                  }
                ]
              }
            },
            "required": [
              "reset"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "command": {
            "const": "searchZeroShutter"
          }
        }
      },
      "then": {
        "properties": {
          "parameters": {
            "type": "object",
            "additionalProperties": false
          }
        }
      }
    }
  ]
}    """
)

This is the response schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["timeout"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "timeout": {
      "type": "number"
    }
  },
  "required": [
    "commandId",
    "response",
    "timeout"
  ],
  "additionalProperties": false
}
    """
)

This is the AMCS status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["AMCS"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "AMCS": {
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "properties": {
            "messages": {
              "type": "array",
              "minItems": 1,
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              ],
              "required": [
                "code",
                "description"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "string"
            },
            "fans": {
              "type": "boolean"
            },
            "inflate": {
              "type": "boolean"
            },
            "operationalMode": {
              "type": "string"
            }
          },
          "required": [
            "messages",
            "status",
            "fans",
            "inflate",
            "operationalMode"
          ],
          "additionalProperties": false
        },
        "positionActual": {
          "type": "number"
        },
        "positionCommanded": {
          "type": "number"
        },
        "velocityActual": {
          "type": "number"
        },
        "velocityCommanded": {
          "type": "number"
        },
        "driveTorqueActual": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTorqueCommanded": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveCurrentActual": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTemperature": {
          "type": "array",
          "minItems": 13,
          "maxItems": 13,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "encoderHeadRaw": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "encoderHeadCalibrated": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "barcodeHeadRaw": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "barcodeHeadCalibrated": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "barcodeHeadWeighted": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "appliedConfiguration": {
          "type": "object",
          "properties": {
            "jmax": {
              "type":"number"
            },
            "amax": {
              "type":"number"
            },
            "vmax": {
              "type":"number"
            }
          }
        },
        "timestampUTC": {
          "type": "number"
        }
      },
      "required": [
        "status",
        "positionActual",
        "positionCommanded",
        "velocityActual",
        "velocityCommanded",
        "driveTorqueActual",
        "driveTorqueCommanded",
        "driveCurrentActual",
        "driveTemperature",
        "encoderHeadRaw",
        "encoderHeadCalibrated",
        "barcodeHeadRaw",
        "barcodeHeadCalibrated",
        "barcodeHeadWeighted",
        "appliedConfiguration",
        "timestampUTC"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "commandId",
    "response",
    "AMCS"
  ],
  "additionalProperties": false
}
    """
)

This is the ApSCS status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["ApSCS"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "ApSCS": {
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "properties": {
            "messages": {
              "type": "array",
              "minItems": 1,
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              ],
              "required": [
                "code",
                "description"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "array",
              "minItems": 2,
              "maxItems": 2,
              "items": [
                {
                  "type": "string"
                }
              ]
            },
            "operationalMode": {
              "type": "string"
            }
          },
          "required": [
            "messages",
            "status",
            "operationalMode"
          ],
          "additionalProperties": false
        },
        "positionActual": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "positionCommanded": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTorqueActual": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTorqueCommanded": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveCurrentActual": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTemperature": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "resolverHeadRaw": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "resolverHeadCalibrated": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "powerDraw": {
          "type": "number"
        },
        "timestampUTC": {
          "type": "number"
        }
      },
      "required": [
        "status",
        "positionActual",
        "positionCommanded",
        "driveTorqueActual",
        "driveTorqueCommanded",
        "driveCurrentActual",
        "driveTemperature",
        "resolverHeadRaw",
        "resolverHeadCalibrated",
        "powerDraw",
        "timestampUTC"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "commandId",
    "response",
    "ApSCS"
  ],
  "additionalProperties": false
}
    """
)

This is the CSCS status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["CSCS"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "CSCS": {
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "properties": {
            "messages": {
              "type": "array",
              "minItems": 1,
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              ],
              "required": [
                "code",
                "description"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "string",
            },
            "operationalMode": {
              "type": "string"
            }
          },
          "required": [
            "messages",
            "status",
            "operationalMode"
          ],
          "additionalProperties": false
        },
        "positionActual": {
          "type": "number"
        },
        "positionCommanded": {
          "type": "number"
        },
        "driveTorqueActual": {
          "type": "number"
        },
        "driveTorqueCommanded": {
          "type": "number"
        },
        "driveCurrentActual": {
          "type": "number"
        },
        "driveTemperature": {
          "type": "number"
        },
        "encoderHeadRaw": {
          "type": "number"
        },
        "encoderHeadCalibrated": {
          "type": "number"
        },
        "powerDraw": {
          "type": "number"
        },
        "timestampUTC": {
          "type": "number"
        }
      },
      "required": [
        "status",
        "positionActual",
        "positionCommanded",
        "driveTorqueActual",
        "driveTorqueCommanded",
        "driveCurrentActual",
        "driveTemperature",
        "encoderHeadRaw",
        "encoderHeadCalibrated",
        "powerDraw",
        "timestampUTC"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "commandId",
    "response",
    "CSCS"
  ],
  "additionalProperties": false
}
    """
)

This is the LCS status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["LCS"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "LCS": {
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "properties": {
            "messages": {
              "type": "array",
              "minItems": 1,
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              ],
              "required": [
                "code",
                "description"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "array",
              "minItems": 34,
              "maxItems": 34,
              "items": [
                {
                  "type": "string"
                }
              ]
            },
            "operationalMode": {
              "type": "string"
            }
          },
          "required": [
            "messages",
            "status",
            "operationalMode"
          ],
          "additionalProperties": false
        },
        "positionActual": {
          "type": "array",
          "minItems": 34,
          "maxItems": 34,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "positionCommanded": {
          "type": "array",
          "minItems": 34,
          "maxItems": 34,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTorqueActual": {
          "type": "array",
          "minItems": 68,
          "maxItems": 68,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTorqueCommanded": {
          "type": "array",
          "minItems": 68,
          "maxItems": 68,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveCurrentActual": {
          "type": "array",
          "minItems": 68,
          "maxItems": 68,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTemperature": {
          "type": "array",
          "minItems": 68,
          "maxItems": 68,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "encoderHeadRaw": {
          "type": "array",
          "minItems": 68,
          "maxItems": 68,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "encoderHeadCalibrated": {
          "type": "array",
          "minItems": 68,
          "maxItems": 68,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "powerDraw": {
          "type": "number"
        },
        "timestampUTC": {
          "type": "number"
        }
      },
      "required": [
        "status",
        "positionActual",
        "positionCommanded",
        "driveTorqueActual",
        "driveTorqueCommanded",
        "driveCurrentActual",
        "driveTemperature",
        "encoderHeadRaw",
        "encoderHeadCalibrated",
        "powerDraw",
        "timestampUTC"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "commandId",
    "response",
    "LCS"
  ],
  "additionalProperties": false
}
    """
)

This is the LWSCS status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["LWSCS"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "LWSCS": {
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "properties": {
            "messages": {
              "type": "array",
              "minItems": 1,
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              ],
              "required": [
                "code",
                "description"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "string"
            },
            "operationalMode": {
              "type": "string"
            }
          },
          "required": [
            "messages",
            "status",
            "operationalMode"
          ],
          "additionalProperties": false
        },
        "positionActual": {
          "type": "number"
        },
        "positionCommanded": {
          "type": "number"
        },
        "velocityActual": {
          "type": "number"
        },
        "velocityCommanded": {
          "type": "number"
        },
        "driveTorqueActual": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTorqueCommanded": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveCurrentActual": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "driveTemperature": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "encoderHeadRaw": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "encoderHeadCalibrated": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "resolverRaw": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "resolverCalibrated": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "powerDraw": {
          "type": "number"
        },
        "appliedConfiguration": {
          "type": "object",
          "properties": {
            "jmax": {
              "type":"number"
            },
            "amax": {
              "type":"number"
            },
            "vmax": {
              "type":"number"
            }
          }
        },
        "timestampUTC": {
          "type": "number"
        }
      },
      "required": [
        "status",
        "positionActual",
        "positionCommanded",
        "velocityActual",
        "velocityCommanded",
        "driveTorqueActual",
        "driveTorqueCommanded",
        "driveCurrentActual",
        "driveTemperature",
        "encoderHeadRaw",
        "encoderHeadCalibrated",
        "resolverRaw",
        "resolverCalibrated",
        "powerDraw",
        "appliedConfiguration",
        "timestampUTC"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "commandId",
    "response",
    "LWSCS"
  ],
  "additionalProperties": false
}
    """
)

This is the MonCS status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["MonCS"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "MonCS": {
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "properties": {
            "messages": {
              "type": "array",
              "minItems": 1,
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              ],
              "required": [
                "code",
                "description"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "string"
            },
            "operationalMode": {
              "type": "string"
            }
          },
          "required": [
            "messages",
            "status",
            "operationalMode"
          ],
          "additionalProperties": false
        },
        "data": {
          "type": "array",
          "minItems": 16,
          "maxItems": 16,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "timestampUTC": {
          "type": "number"
        }
      },
      "required": [
        "status",
        "data",
        "timestampUTC"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "commandId",
    "response",
    "MonCS"
  ],
  "additionalProperties": false
}
    """
)

This is the RAD status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["RAD"] = json.loads(
    """
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "commandId": {
            "type": "number"
        },
        "response": {
            "type": "number"
        },
        "RAD": {
            "type": "object",
            "properties": {
                "timestampUTC": {
                    "type": "number"
                },
                "status": {
                    "type": "object",
                    "properties": {
                        "status": {
                            "type": "array",
                            "minItems": 2,
                            "maxItems": 2,
                            "items": [
                                {
                                    "type": "string"
                                }
                            ]
                        },
                        "messages": {
                            "type": "array",
                            "minItems": 1,
                            "items": [
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "number"
                                        },
                                        "description": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "code",
                                        "description"
                                    ],
                                    "additionalProperties": false
                                }
                            ]
                        }
                    },
                    "required": [
                        "status",
                        "messages"
                    ],
                    "additionalProperties": false
                },
                "positionActual": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "positionCommanded": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "driveTorqueActual": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "driveTorqueCommanded": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "driveCurrentActual": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "driveTemperature": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "resolverHeadRaw": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "resolverHeadCalibrated": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "powerDraw": {
                    "type": "number"
                },
                "openLimitSwitchEngaged": {
                    "type": "array",
                    "minItems": 4,
                    "maxItems": 4,
                    "items": [
                        {
                            "type": "boolean"
                        }
                    ]
                },
                "closeLimitSwitchEngaged": {
                    "type": "array",
                    "minItems": 4,
                    "maxItems": 4,
                    "items": [
                        {
                            "type": "boolean"
                        }
                    ]
                },
                "lockingPins": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "number"
                        }
                    ]
                },
                "brakesEngaged": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": [
                        {
                            "type": "boolean"
                        }
                    ]
                },
                "photoelectricSensorClear": {
                    "type": "boolean"
                },
                "lightCurtainClear": {
                    "type": "boolean"
                }
            },
            "required": [
                "timestampUTC",
                "status",
                "positionActual",
                "positionCommanded",
                "driveTorqueActual",
                "driveTorqueCommanded",
                "driveCurrentActual",
                "driveTemperature",
                "resolverHeadRaw",
                "resolverHeadCalibrated",
                "powerDraw",
                "openLimitSwitchEngaged",
                "closeLimitSwitchEngaged",
                "lockingPins",
                "brakesEngaged",
                "photoelectricSensorClear",
                "lightCurtainClear"
            ],
            "additionalProperties": false
        }
    },
    "required": [
        "commandId",
        "response",
        "RAD"
    ],
    "additionalProperties": false
}
    """
)

This is the ThCS status schema.

# This file is part of ts_mtdome.
#
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json

from .registry import registry

registry["ThCS"] = json.loads(
    """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "commandId": {
      "type": "number",
      "description": "The command ID as generated by the CSC."
    },
    "response": {
      "type": "number"
    },
    "ThCS": {
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "properties": {
            "messages": {
              "type": "array",
              "minItems": 1,
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                }
              ],
              "required": [
                "code",
                "description"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "string"
            },
            "operationalMode": {
              "type": "string"
            }
          },
          "required": [
            "messages",
            "status",
            "operationalMode"
          ],
          "additionalProperties": false
        },
        "temperature": {
          "type": "array",
          "minItems": 13,
          "maxItems": 13,
          "items": [
            {
              "type": "number"
            }
          ]
        },
        "timestampUTC": {
          "type": "number"
        }
      },
      "required": [
        "status",
        "temperature",
        "timestampUTC"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "commandId",
    "response",
    "ThCS"
  ],
  "additionalProperties": false
}
    """
)