@startuml

class User{
    String Username
    String UserGroupID_FK
    String Email
    String Name
    String TimeWindow
    String Password
    String SubscriptionType
    ArrayList String[] Roles
    ArrayList Decimal[] Location
    Bool authenticateUser()
    Bool changePassword()
    Bool recoverPassword()
    Bool editUser()
    Bool editConfig()
    Bool changeSubscriptionType()
}

class fuel{
 String fuelType
 String UserID_Fk
 Double fuelPrice
}
User "1" *-- "many" fuel : has

class UserGroup{
    String Name
    String Admin
    Bool registerAdmin()
    Bool registerUser()
    Bool deleteUser()
}

class ConfigGroup{
    String Name
    String UserID_FK
    String AdminID_FK
    String SourceConfigID_FK
    Int margin
    Bool registerAdmin()
    Bool registerConfig()
    Bool deleteConfig()
    Bool acceptPayment()
}

UserGroup "many" *-- "many" User : has
User "1" *-- "many" Configuration : has
User "many" *-- "many" ConfigGroup : has
ConfigGroup "1" *-- "many" Configuration : has
class Configuration{
    String ConfigurationName
    String UserID_FK
    String ConfigGroupID_FK
    String GroupName
    String DefaultDurationWindow
    ArrayList Decimal[] Location
    Dict DeviceList

}

Configuration "1" o-- "many" SignalAssignment : has
Configuration "1" o-- "many" PowerConsumerGroup : has
PowerConsumerGroup "1" o-- "many" PowerConsumerLine : has


class Probe {
    String ProbeName
    String DeviceType
    Int NumberOfChannels
    Int SignalThreshold
    Int ErrorThreshold
    Int ScalingFactorCurrent
    Int ScalingFactorVoltage
    String WifiNetworkName
    String WifiPassword
    ArrayList SignalAssignment[] Channels
    Bool updateFirmware()
    Bool setFallBackVoltage ()
    Bool setScalingVoltage ()
    Bool setScalingCurrent ()
    Bool setErrorThresholds ()
    Bool setWiFiParams ()
    Bool setSignalAssignment()
}

Configuration "1" o-- "many" PowerSource : has
Probe "1" o-- "many" Switch : has
Configuration "1" *-- "many" PowerData_ELASTIC : has
Probe "1" *-- "many" SignalAssignment : has
class SignalAssignment{
    String ConfigID_FK
    String SourceID_FK
    String Source_channel
    String SourceType
    String SourceName
}
class PowerConsumerGroup{
    String Name
    String ConfigID_FK
    Bool start()
    Bool stop()
}
class PowerConsumerLine{
    String Name
    String GroupID_FK
    String Type
    String NumberOfPhases
    Bool State
    Bool start()
    Bool stop()
}
PowerConsumerLine "1" o-- "many" PowerConsumer : has
class PowerConsumer{
    String Name
    String LineID_FK
    String Type
    String NumberOfPhases
    Bool State
    Bool start()
    Bool stop()
}
class PowerSource{
    String ConfigID_FK
    String SourceName
    String SourceType
    String NumberOfPhases
    Date DateOfCommissioning
    Date DateOfLastService
    Time ServiceInterval
    Int Efficiency
    Int DefaultChannels
    Int MaxChannels
    Int State
    Bool start()
    Bool stop()
}

PowerSource "1" o-- "many" SignalAssignment : has
PowerSource <|-- Generator
PowerSource <|-- Grid
PowerSource <|-- Inverter
fuel "1" *-- "many" Generator : has
class Generator{
    String FuelType
    Double FuelUnitPrice
    Int FuelStore
    String ApparentPower
    Dict GeneratorMap
    Int Rating
    DateTime FuelRefillTime
}

class Grid{
    Dict UtilityMap
}

class Inverter{
    Int MaxDepthOfDischarge
    Int TargetDepthOfDischarge
    Int BatteryCapacity
    Int BatteryCount
    Int BatteryVoltage
    Int BatteryBankVoltage
    Int BulkChargingCurrent
    Int BatteryCost
    Int BatteryEndOfLife
    Int DefaultChannels
    DateTime BatteryInstallation
    String BatteryChemistry
    Int Rating
    Array[Dic] BatteryLife
}
class Switch{
    String SwitchID
    String ProbeID_FK
    String SwitchType
    String State
    Dict Inputs
    Int Output
    TimeDelta Latency
    Int Count
    Bool switch_to_input_1()
    Bool switch_to_input_2()
    Bool switch_to_neutral()
}
Switch "1" o-- "2" PowerSource : has
Switch "1" o-- "1" PowerConsumerLine : has


Class PowerData_ELASTIC{
    Double batterycapacity
    String ProbeID_FK
    String ConfigID_FK
    String Time
    String SourceType
    String SourceName
    Double Voltage1
    Double Voltage2
    Double Voltage3
    Double Current1
    Double Current2
    Double Current3
    Double PowerFactor1
    Double PowerFactor2
    Double PowerFactor3
    Double Energy_since_last
    Double Power_real_total
    Double Power_apparent_total
    Double Power_reactive_total
    Double Fuel_hour_rate
    Double Fuel_since_last
    Double Cost_since_last
}

 User "1" *-- "1" NotificationConfig : has
class NotificationConfig{

    ArrayList String[] UserEmails
    ArrayList String[] UserNumbers
    ArrayList NotificationParams[] SourceThreshold
    ArrayList NotificationParams[] SourceTransition
    NotificationParams OperatingWindow
    NotificationParams xAboveDOD
    NotificationParams xBelowDOD
    NotificationParams VoltageThreshold
    NotificationParams PowerFactorThreshold
    NotificationParams BatteryThreshold
    NotificationParams UtilityThreshold
    NotificationParams FuelThreshold
    NotificationParams LastGasp





}

class NotificationParams{
    Int HighValue
    Int LowValue
    Boolean email
    Boolean sms
    Boolean flag
    }



@enduml

/*


*/