#FSharp
ocaml | by: Cynede
posted: Dec, 8th 2011 | jump to bottom
module FBOI (* Top level library *) open System open System.Threading open System.Collections.ObjectModel open Work //------------------------------------------------------------------------------------------------------------// module Lambda = //------------------------------------------------------------------------------------------------------------// let mutable internal workbase : list<Dev> = [] //------------------------------------------------------------------------------------------------------------// let internal (<%=) W Z clear async N v = let X thriller = (W : Dev).ListPos .Clear() if clear then W.Out .Clear() thriller() if async then else W.Run N v //------------------------------------------------------------------------------------------------------------// let internal get W = if workbase.Length <> 0 then else -1 let internal (=%>) W thriller = (* Dev -> unit *) let id = get W if id <> -1 then workbase.[id] |> thriller let internal (=%=) W thriller = (* Dev -> 'a *) let id = get W if id <> -1 then Some ( workbase.[id] |> thriller ) else None //------------------------------------------------------------------------------------------------------------// let Reset() = workbase <- [] //------------------------------------------------------------------------------------------------------------// let Start id ip port user password = let work = new Dev(ip, port, user, password) work <%= [| Byteworks.Authorize(user,password) |] (*TODO: Run it empty*) <| true (*clear*) <| false (*async*) <| id (*workid*) <| -3 (*v*) work.ID <- id workbase <- work :: workbase true //------------------------------------------------------------------------------------------------------------// let GetArchive W dev v dt1 dt2 numIT numArh = (* Get Archive Data *) W =%> fun w -> w.Out.Clear() w.Start() while (not w.Stop) do w.Dev <- dev w <%= [|( Byteworks.GetArchive dev dt1 dt2 numIT numArh Nisemono.next )|] <| true (*clear*) <| false (*async*) <| W (*workid*) <| v (*v*) let GetCurrent W dev numIT = (* Get Instant Data *) W =%> fun w -> w.Out.Clear() w.Dev <- dev w <%= [|( Byteworks.GetCurrent dev numIT)|] <| true (*clear*) <| false (*async*) <| W (*workid*) <| -1 (*v*) //------------------------------------------------------------------------------------------------------------// let TimeSync W dt = (* BOI Time Synchronization *) W =%> fun w -> w.Out.Clear() w <%= [| Byteworks.SyncTime(dt) |] <| false (*clear*) <| true (*async*) <| W (*workid*) <| -2 (*v*) let DoSync W = TimeSync W DateTime.Now //------------------------------------------------------------------------------------------------------------// let Read W = match W =%= fun w -> w.Out with | Some(t) -> t | None -> new Collection<string>() let Check W = match W =%= fun w -> w.Error with | Some(t) -> t | None -> true let ReadDevices W = match W =%= fun w -> w.Devices with | Some(t) -> t | None -> new Collection<BModel.Device>() let GetBytes W = match W =%= fun w -> w.Recived with | Some(t) -> t | None -> [||] let CanRead W dev v = match W =%= fun w -> w.GetCanRead dev v with | Some(t) -> t | None -> false let GetABytes W dev v = match W =%= fun w -> w.GetArchive dev v with | Some(t) -> t | None -> [||] let GetIBytes W dev = match W =%= fun w -> w.GetInstant dev with | Some(t) -> t | None -> [||] //------------------------------------------------------------------------------------------------------------//
143 views




