//
//  RegisteredEca.swift
//  Sailassist
//
//  Created by 三浦薫巳 on 2023/10/27.
//

import Foundation
import CoreLocation

enum EcaState {
    case register       //登録
    case running        //ECAタスク実行開始
    case noticePass     //ECA通知円到達
    case startPass      //ECA開始円到達
    case finishPass     //ECAタスク終了円到達
    case end            //ECAタスク完了（燃料切替実施済み)
    case incomplete     //ECAタスク未完了 (燃料切替未実施で終了)
    case cancel         //ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル)
}

let serverRegister = 0x00000000      //登録
let serverRunning = 0x10000000       //ECAタスク実行開始
let serverNoticePass = 0x10000001    //ECA通知円到達
let serverStartPass = 0x10000002     //ECA開始円到達
let serverFinishPass = 0x10000004    //ECAタスク終了円到達
let serverEnd = 0x00000100           //ECAタスク完了（燃料切替実施済み)
let serverIncomplete = 0x00000200    //ECAタスク未完了 (燃料切替未実施で終了)
let serverCancel =  0x00000400       //ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル)

struct RegisteredEca {
    var areaId: Int = 0
    var isEnable: Bool = false      //ECA有効
    var isRunning: Bool = false     //ECA実行中
    var name: String = ""           //ECA名称
    var swNotice: Float = 6         //ECA通知[NM]
    var swStart: Float = 5          //ECA開始[NM]
    var swFinish: Float = 4         //ECA終了[NM]
    var status: EcaState = EcaState.register    //ECA状態
    var datetime: String = ""       //時刻（UTC ISO8601準拠）
    var color: String = ""          //ライン色（ARGB）
    var width: Int = 1              //ライン幅
    var centerPosition: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)
    var zoomLevel: CGFloat = 11.0
    var points: [CLLocationCoordinate2D] = []

    init?(id: Int, ecaName: String ) {
        self.areaId = id
        self.name = ecaName
    }
}
