IF NOT EXISTS ( SELECT * FROM sys . databases WHERE name = ' teleport ' )
CREATE DATABASE teleport ;
IF NOT EXISTS ( SELECT * FROM sysobjects WHERE name= ' teleport_battery_power ' and xtype = ' U ' )
CREATE TABLE " teleport_battery_power "
" id " int not null identity ( 1 , 1 ),
" teleport_hash_id " varchar ( 32 ) NOT NULL ,
" asset_identifier " varchar ( 128 ) NOT NULL ,
" battery_status " varchar ( 32 ) DEFAULT NULL , -- can be "on", "off", "other" or null (see warning and errors in case of 'other')
" energy_charged " decimal ( 23 , 3 ) DEFAULT NULL , -- in Wh, nonnegative
" energy_discharged " decimal ( 23 , 3 ) DEFAULT NULL , -- in Wh, nonnegative
" frequency " decimal ( 7 , 2 ) DEFAULT NULL , -- in Hz, nonnegative
" active_power " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, positive means discharging, negative charging
" reactive_power " decimal ( 23 , 3 ) DEFAULT NULL , -- in var, positive is injecting reactive power to the grid and negative is absorbing reactive power
" state_of_charge " decimal ( 7 , 4 ) DEFAULT NULL , -- in %, nonnegative
" state_of_health " decimal ( 7 , 4 ) DEFAULT NULL , -- in %, nonnegative
" available_energy " decimal ( 23 , 3 ) DEFAULT NULL , -- in Wh, nonnegative
" rated_energy " decimal ( 23 , 3 ) DEFAULT NULL , -- in Wh, nonnegative
" available_active_power_charge " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, nonnegative
" available_active_power_discharge " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, nonnegative
" available_reactive_power_inject " decimal ( 23 , 3 ) DEFAULT NULL , -- in var, nonnegative
" available_reactive_power_absorb " decimal ( 23 , 3 ) DEFAULT NULL , -- in var, nonnegative
" active_power_setpoint_dispatch_power " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, positive means discharging, negative charging
" active_power_setpoint_deliver_fcr " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, positive means discharging, negative charging
" active_power_setpoint_charge_to_state " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, positive means discharging, negative charging
" active_power_setpoint_aggregate " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, positive means discharging, negative charging
" three_phase_connection_type_high_voltage " varchar ( 32 ) DEFAULT NULL , -- can be "wye" or "delta"
" ac_voltage_medium_voltage_phase_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_medium_voltage_phase_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_medium_voltage_phase_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_medium_voltage_line_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_medium_voltage_line_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_medium_voltage_line_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_current_medium_voltage_phase_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_medium_voltage_phase_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_medium_voltage_phase_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_medium_voltage_line_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_medium_voltage_line_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_medium_voltage_line_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" auxiliary_power_active " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, can be null. Negative means consuming, positive generating, will be negative or 0
" auxiliary_power_reactive " decimal ( 23 , 3 ) DEFAULT NULL , -- in Var, can be null. Negative means consuming, positive generating, will be negative or 0
" configuration_dispatch_power_active_power " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, positive means discharging, negative charging. When dispatchPower is null but the battery system does not support stand-by mode, the Teleport will send a schedule with 0 W to the asset, while the reported dispatchPower is null.
" configuration_deliver_fcr_max_rate " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, nonnegative
" configuration_charge_to_state_percentage " decimal ( 7 , 4 ) DEFAULT NULL , -- in %, nonnegative
" warnings " nvarchar ( 4000 ) DEFAULT NULL , -- if not null, will contain a JSON aray of string elements. see error codes section
" errors " nvarchar ( 4000 ) DEFAULT NULL , -- if not null, will contain a JSON array of string elements. see error codes section
" schedule_complete_until " datetime DEFAULT NULL , -- first gap in the schedule for this asset_identifier
" scheduled " bit NOT NULL , -- false for measurements that are not part of the regular reporting interval, eg. directly after command execution and at Teleport initialisation
" measured_at " datetime NOT NULL , -- when read-out started
" created_at " datetime NOT NULL , -- when written to the table
INDEX " teleport " ( " teleport_hash_id " , " created_at " ),
INDEX " teleport_asset " UNIQUE ( " teleport_hash_id " , " asset_identifier " , " measured_at " ) WITH ( IGNORE_DUP_KEY = ON )
IF NOT EXISTS ( SELECT NULL FROM SYS . EXTENDED_PROPERTIES WHERE [major_id] = OBJECT_ID ( ' teleport_battery_power ' ) AND [name] = N ' version ' AND [minor_id] = 0 )
EXEC sys . sp_addextendedproperty
@level1name = N ' teleport_battery_power '
ELSE EXEC sys . sp_updateextendedproperty
@level1name = N ' teleport_battery_power ' ;
IF NOT EXISTS ( SELECT * FROM sysobjects WHERE name= ' teleport_battery_power_bess ' and xtype = ' U ' )
CREATE TABLE " teleport_battery_power_bess "
" id " int not null identity ( 1 , 1 ),
" teleport_hash_id " varchar ( 32 ) NOT NULL ,
" asset_identifier " varchar ( 128 ) NOT NULL ,
" bess_identifier " varchar ( 128 ) NOT NULL ,
" cell_temperature_min " decimal ( 6 , 2 ) DEFAULT NULL , -- in ºC, min value of all cells
" cell_temperature_max " decimal ( 6 , 2 ) DEFAULT NULL , -- in ºC, max value of all cells
" room_temperature " decimal ( 6 , 2 ) DEFAULT NULL , -- in ºC, max value of all cells
" state_of_charge " decimal ( 7 , 4 ) DEFAULT NULL , -- in %, nonnegative
" available_energy " decimal ( 23 , 3 ) DEFAULT NULL , -- in Wh, nonnegative
" available_active_power_charge " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, nonnegative
" available_active_power_discharge " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, nonnegative
" three_phase_connection_type_low_voltage " varchar ( 32 ) DEFAULT NULL , -- can be "wye" or "delta"
" ac_voltage_low_voltage_phase_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_low_voltage_phase_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_low_voltage_phase_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_low_voltage_line_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_low_voltage_line_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_voltage_low_voltage_line_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" ac_current_low_voltage_phase_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_low_voltage_phase_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_low_voltage_phase_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_low_voltage_line_l1 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_low_voltage_line_l2 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" ac_current_low_voltage_line_l3 " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" warnings " nvarchar ( 4000 ) DEFAULT NULL , -- if not null, will contain a JSON aray of string elements. see error codes section
" errors " nvarchar ( 4000 ) DEFAULT NULL , -- if not null, will contain a JSON array of string elements. see error codes section
" scheduled " bit NOT NULL , -- false for measurements that are not part of the regular reporting interval, eg. directly after command execution and at Teleport initialisation
" measured_at " datetime NOT NULL , -- when read-out started
" created_at " datetime NOT NULL , -- when written to the table
INDEX " bess " ( " bess_identifier " , " created_at " ),
INDEX " teleport " ( " teleport_hash_id " , " asset_identifier " , " created_at " ),
INDEX " teleport_asset " UNIQUE ( " teleport_hash_id " , " asset_identifier " , " bess_identifier " , " measured_at " ) WITH ( IGNORE_DUP_KEY = ON )
IF NOT EXISTS ( SELECT * FROM sysobjects WHERE name= ' teleport_battery_power_bess_rack ' and xtype = ' U ' )
CREATE TABLE " teleport_battery_power_bess_rack "
" id " int not null identity ( 1 , 1 ),
" teleport_hash_id " varchar ( 32 ) NOT NULL ,
" asset_identifier " varchar ( 128 ) NOT NULL ,
" bess_identifier " varchar ( 128 ) NOT NULL ,
" rack_identifier " varchar ( 128 ) NOT NULL ,
" dc_voltage " decimal ( 23 , 3 ) DEFAULT NULL , -- in V, nonnegative
" dc_current " decimal ( 23 , 3 ) DEFAULT NULL , -- in A, delivering to the grid is a positive value
" scheduled " bit NOT NULL , -- false for measurements that are not part of the regular reporting interval, eg. directly after command execution and at Teleport initialisation
" measured_at " datetime NOT NULL , -- when read-out started
" created_at " datetime NOT NULL , -- when written to the table
INDEX " bess_rack " ( " rack_identifier " , " created_at " ),
INDEX " bess " ( " bess_identifier " , " created_at " ),
INDEX " teleport " ( " teleport_hash_id " , " asset_identifier " , " created_at " ),
INDEX " teleport_asset " UNIQUE ( " teleport_hash_id " , " asset_identifier " , " bess_identifier " , " rack_identifier " , " measured_at " ) WITH ( IGNORE_DUP_KEY = ON )
IF NOT EXISTS ( SELECT * FROM sysobjects WHERE name= ' teleport_battery_power_flash ' and xtype = ' U ' )
CREATE TABLE " teleport_battery_power_flash "
" id " int not null identity ( 1 , 1 ),
" teleport_hash_id " varchar ( 32 ) NOT NULL ,
" asset_identifier " varchar ( 128 ) NOT NULL ,
" frequency " decimal ( 7 , 2 ) DEFAULT NULL , -- in Hz, nonnegative
" active_power " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, positive means discharging, negative charging
" state_of_charge " decimal ( 7 , 4 ) DEFAULT NULL , -- in %, nonnegative
" available_energy " decimal ( 23 , 3 ) DEFAULT NULL , -- in Wh, nonnegative
" available_active_power_charge " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, nonnegative
" available_active_power_discharge " decimal ( 23 , 3 ) DEFAULT NULL , -- in W, nonnegative
" scheduled " bit NOT NULL , -- false for measurements that are not part of the regular reporting interval, eg. directly after command execution and at Teleport initialisation
" measured_at " datetime NOT NULL , -- when read-out started
" created_at " datetime NOT NULL , -- when written to the table
INDEX " teleport " ( " teleport_hash_id " , " created_at " ),
INDEX " teleport_asset " UNIQUE ( " teleport_hash_id " , " asset_identifier " , " measured_at " ) WITH ( IGNORE_DUP_KEY = ON )
IF NOT EXISTS ( SELECT NULL FROM SYS . EXTENDED_PROPERTIES WHERE [major_id] = OBJECT_ID ( ' teleport_battery_power_flash ' ) AND [name] = N ' version ' AND [minor_id] = 0 )
EXEC sys . sp_addextendedproperty
@level1name = N ' teleport_battery_power_flash '
ELSE EXEC sys . sp_updateextendedproperty
@level1name = N ' teleport_battery_power_flash ' ;