Power.Dev Optimization Services

<back to all web services

TODOptimizerRequest

The following routes are available for this service:
POST/optimizer/tod
import Foundation
import ServiceStack

public class TODOptimizerRequest : TodOptimizerRequestBase
{
    required public init(){ super.init() }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
    }
}

public class TodOptimizerRequestBase : Codable
{
    public var projectId:String
    public var chargeDischargeLimit:Double
    public var batteryCapacity:Double
    public var chargeEfficiency:Double
    public var dischargeEfficiency:Double
    public var paraciticLossesOperation:Double
    public var paraciticLossesResting:Double
    public var hvacLosses:Double
    public var acCablingLosses:Double
    public var transformatorLosses:Double
    public var thermalLosses:Double
    public var unavailabilityLoss:Double
    public var otherLosses:Double
    public var enableCapacity:Bool
    public var energySchedule:[AnnualRateItem] = []
    public var capacitySchedule:[AnnualRateItem] = []
    public var yoyFactors:[YoyFactorOptimizarItem] = []
    public var data:[TodOptimizerRequestItem] = []
    public var apiActionId:String

    required public init(){}
}

public class AnnualRateItem : Codable
{
    public var year:Int
    public var value:Double

    required public init(){}
}

public class YoyFactorOptimizarItem : Codable
{
    public var year:Int
    public var factor:Double

    required public init(){}
}

public class TodOptimizerRequestItem : Codable
{
    public var year:Int
    public var month:Int
    public var hour:Int
    public var weekDay:Int
    public var energyPrice:Double
    public var capacityPrice:Double

    required public init(){}
}

public class TodOptimizerResponse : Codable
{
    public var status:ApiResponseStatus
    public var message:String
    public var apiActionId:String
    public var testItems:[TodOptimizerResponseItem] = []

    required public init(){}
}

public enum ApiResponseStatus : Int, Codable
{
    case Undefined = 0
    case Success = 1
    case Pending = 10
    case Failed = 100
}

public class TodOptimizerResponseItem : TodOptimizerRequestItem
{
    public var chargeState:Double
    public var charging:Double
    public var loss:Double
    public var chargeRate:Double

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case chargeState
        case charging
        case loss
        case chargeRate
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        chargeState = try container.decodeIfPresent(Double.self, forKey: .chargeState)
        charging = try container.decodeIfPresent(Double.self, forKey: .charging)
        loss = try container.decodeIfPresent(Double.self, forKey: .loss)
        chargeRate = try container.decodeIfPresent(Double.self, forKey: .chargeRate)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if chargeState != nil { try container.encode(chargeState, forKey: .chargeState) }
        if charging != nil { try container.encode(charging, forKey: .charging) }
        if loss != nil { try container.encode(loss, forKey: .loss) }
        if chargeRate != nil { try container.encode(chargeRate, forKey: .chargeRate) }
    }
}


Swift TODOptimizerRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /optimizer/tod HTTP/1.1 
Host: dev-optimization.power.dev 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"projectId":"00000000000000000000000000000000","chargeDischargeLimit":0,"batteryCapacity":0,"chargeEfficiency":0,"dischargeEfficiency":0,"paraciticLossesOperation":0,"paraciticLossesResting":0,"hvacLosses":0,"acCablingLosses":0,"transformatorLosses":0,"thermalLosses":0,"unavailabilityLoss":0,"otherLosses":0,"enableCapacity":false,"apiActionId":"00000000000000000000000000000000"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"status":"Undefined","message":"String","apiActionId":"00000000000000000000000000000000","testItems":[{"chargeState":0,"charging":0,"loss":0,"chargeRate":0,"year":0,"month":0,"hour":0,"weekDay":0,"energyPrice":0,"capacityPrice":0}]}