108 lines
2.8 KiB
Forth
108 lines
2.8 KiB
Forth
module Hipster.Actors
|
|
|
|
open System
|
|
open Dapr.Actors
|
|
open System.Threading.Tasks
|
|
|
|
open Drifters.ApiTypes
|
|
open Hipster.Job
|
|
|
|
type DriftersAction =
|
|
| Submit
|
|
override x.ToString() =
|
|
match x with
|
|
| Submit -> "submit"
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module DriftersPolicy =
|
|
let toString (x: DriftersPolicy) = string x
|
|
let isAllowed (x: DriftersPolicy) = x.IsAllowed()
|
|
let fromString (s: string) =
|
|
let cap, v = s.Split ';' |> fun y -> y[0], y[1] = "True"
|
|
match cap with
|
|
| "run:transport" -> SubmitTransport v
|
|
| "run:sedimentation" -> SubmitSedimentation v
|
|
| _ -> SubmitTransport false
|
|
let toPolicy (m: SimType, a: DriftersAction, v: bool) =
|
|
match m, a with
|
|
| DepositionSim, Submit -> SubmitSedimentation v
|
|
| _, Submit -> SubmitTransport v
|
|
|
|
type DriftersJob = {
|
|
aid: Guid
|
|
name: string
|
|
model: SimType
|
|
input: DriftersInput
|
|
groups: string[] option
|
|
partition: string option
|
|
dependency: int option
|
|
}
|
|
|
|
type PostdriftJob = {
|
|
aid: Guid
|
|
name: string
|
|
model: SimType
|
|
input: PostdriftInput
|
|
groups: string[] option
|
|
partition: string option
|
|
dependency: int option
|
|
}
|
|
|
|
type PlumeJob = {
|
|
name: string
|
|
fvcom: Guid
|
|
pos: LatLong
|
|
// TODO: Functions, could be constants
|
|
// saltfunc: unit
|
|
// tempfunc: unit
|
|
/// Example 4 and 0
|
|
temp: float
|
|
salt: float
|
|
/// DOB Depth on Bottom
|
|
depth: float
|
|
/// Pipe Angle
|
|
theta: float
|
|
transport: float
|
|
/// Pipe radius
|
|
radius: float
|
|
start: DateTime
|
|
stop: DateTime
|
|
timeIdx: int
|
|
} with
|
|
static member empty = {
|
|
name = ""
|
|
fvcom = System.Guid.Empty
|
|
pos = {Lat = 0.0; Long = 0.0}
|
|
temp = 0.0
|
|
salt = 0.0
|
|
depth = 0.0
|
|
theta = 0.0
|
|
transport = 0.0
|
|
radius = 0.0
|
|
start = DateTime.MinValue
|
|
stop = DateTime.MaxValue
|
|
timeIdx = 0
|
|
}
|
|
|
|
type IJobActor =
|
|
inherit IActor
|
|
abstract Cancel: unit: unit -> Task<bool>
|
|
abstract Remove: job: int -> Task<bool>
|
|
abstract RemoveById: aid: Guid -> Task<bool>
|
|
abstract Clear: unit: unit -> Task
|
|
abstract HandleJobEvent: job: SlurmJobStatusMsg -> Task
|
|
abstract GetJobState: jobid: int -> Task<JobInfo option>
|
|
abstract GetActiveJobs: aid: Guid -> Task<JobInfo[]>
|
|
abstract GetFenceRadius: unit: unit -> Task<float>
|
|
abstract CheckFence: aid: Guid * pos: (float * float) list -> Task<bool>
|
|
|
|
type IDriftersActor =
|
|
inherit IJobActor
|
|
abstract SubmitDrifters: job: DriftersJob -> Task<Result<JobInfo, string>>
|
|
abstract SubmitPostdrift: job: PostdriftJob -> Task<Result<JobInfo, string>>
|
|
abstract GetPolicies: aid: Guid -> Task<DriftersPolicy[]>
|
|
|
|
type IPlumeActor =
|
|
inherit IActor
|
|
abstract Submit: job: PlumeJob -> Task<Result<JobInfo, string>>
|