diff --git a/ivette/api/kernel/ast/index.ts b/ivette/api/kernel/ast/index.ts index 18f6889d903da219b0c49eb42fe2f3b4d9cca64c..731f28b341cbf27056488d7573fcf2e317c5d9ea 100644 --- a/ivette/api/kernel/ast/index.ts +++ b/ivette/api/kernel/ast/index.ts @@ -71,6 +71,8 @@ export const markerKindTags: Server.GetRequest<null,tag[]> = { /** Markers data */ export const markerData: State.Array<'#markerData',markerDataData> = { + name: 'kernel.ast.markerData', + key: 'key', signal: signalMarkerData, fetch: fetchMarkerData, reload: reloadMarkerData, @@ -162,6 +164,8 @@ export const printFunction: Server.GetRequest<Json.Key<'#fct'>,text> = { /** AST Functions */ export const functions: State.Array<'#functions',functionsData> = { + name: 'kernel.ast.functions', + key: 'key', signal: signalFunctions, fetch: fetchFunctions, reload: reloadFunctions, diff --git a/ivette/api/kernel/properties/index.ts b/ivette/api/kernel/properties/index.ts index a17f096b2157bb18cac4d1905c7d4cf586eea4ad..7dc2b45c16ce08026653b3249bc0409d61651fcb 100644 --- a/ivette/api/kernel/properties/index.ts +++ b/ivette/api/kernel/properties/index.ts @@ -215,6 +215,8 @@ export const alarmsTags: Server.GetRequest<null,tag[]> = { /** Status of Registered Properties */ export const status: State.Array<'#status',statusData> = { + name: 'kernel.properties.status', + key: 'key', signal: signalStatus, fetch: fetchStatus, reload: reloadStatus, diff --git a/ivette/api/server_tsc.ml b/ivette/api/server_tsc.ml index 4914eee0de328f327de077b7581f911e3e2e910d..6516ae96f8a753db4e11e3a0f3386cfe825c9b0b 100644 --- a/ivette/api/server_tsc.ml +++ b/ivette/api/server_tsc.ml @@ -309,6 +309,7 @@ let makeDeclaration fmt names d = Format.fprintf fmt "@[<hov 2>export const %s: State.Value<@,%a@,> = {@]@\n" self.name jtype js ; + Format.fprintf fmt " name: '%s',@\n" (Pkg.name_of_ident self) ; Format.fprintf fmt " signal: %a,@\n" (jcall names) (Pkg.Derived.signal self) ; Format.fprintf fmt " getter: %a,@\n" @@ -319,6 +320,7 @@ let makeDeclaration fmt names d = Format.fprintf fmt "@[<hov 2>export const %s: State.State<@,%a@,> = {@]@\n" self.name jtype js ; + Format.fprintf fmt " name: '%s',@\n" (Pkg.name_of_ident self) ; Format.fprintf fmt " signal: %a,@\n" (jcall names) (Pkg.Derived.signal self) ; Format.fprintf fmt " getter: %a,@\n" @@ -327,11 +329,13 @@ let makeDeclaration fmt names d = (jcall names) (Pkg.Derived.setter self) ; Format.fprintf fmt "};@\n" - | D_array kd -> + | D_array { arr_key ; arr_kind } -> let data = Pkg.Derived.data self in Format.fprintf fmt "@[<hov 2>export const %s: State.Array<@,'#%s',@,%a@,> = {@]@\n" - self.name kd (jcall names) data ; + self.name arr_kind (jcall names) data ; + Format.fprintf fmt " name: '%s',@\n" (Pkg.name_of_ident self) ; + Format.fprintf fmt " key: '%s',@\n" arr_key ; Format.fprintf fmt " signal: %a,@\n" (jcall names) (Pkg.Derived.signal self) ; Format.fprintf fmt " fetch: %a,@\n" diff --git a/src/plugins/server/package.ml b/src/plugins/server/package.ml index b0361dcbd90b7a958d3afc9292a6190d610e556e..cde3cfeb3d3e2130381aefcd0bdf4d15bcbfffe1 100644 --- a/src/plugins/server/package.ml +++ b/src/plugins/server/package.ml @@ -205,6 +205,11 @@ type requestInfo = { rq_output: paramInfo ; } +type arrayInfo = { + arr_key: string; + arr_kind: string; +} + type declKindInfo = | D_signal | D_type of jtype @@ -213,7 +218,7 @@ type declKindInfo = | D_request of requestInfo | D_value of jtype | D_state of jtype - | D_array of string (* key kind *) + | D_array of arrayInfo (* key kind *) | D_safe of ident * jtype (* safe decoder *) | D_loose of ident * jtype (* loose decoder *) | D_order of ident * jtype (* natural ordering *) diff --git a/src/plugins/server/package.mli b/src/plugins/server/package.mli index 0e639a0ee9e584fb6738a1fdc0e1ee8f1da13d85..f60c02145bc13fff7dd9a0a841a9bac2659d215e 100644 --- a/src/plugins/server/package.mli +++ b/src/plugins/server/package.mli @@ -69,6 +69,11 @@ type requestInfo = { rq_output: paramInfo ; } +type arrayInfo = { + arr_key: string; + arr_kind: string; +} + type declKindInfo = | D_signal | D_type of jtype @@ -77,7 +82,7 @@ type declKindInfo = | D_request of requestInfo | D_value of jtype | D_state of jtype - | D_array of string + | D_array of arrayInfo | D_safe of ident * jtype (* safe decoder *) | D_loose of ident * jtype (* loose decoder *) | D_order of ident * jtype (* natural ordering *) diff --git a/src/plugins/server/states.ml b/src/plugins/server/states.ml index 9c49096ef34b5da4e5577b1f9910e1e38d5613b6..c45af471fbefed4c9fc496bfa6d34c7a9ee17f51 100644 --- a/src/plugins/server/states.ml +++ b/src/plugins/server/states.ml @@ -126,6 +126,7 @@ type 'a content = { type 'a array = { signal : Request.signal ; + fkey : string ; key : 'a -> string ; iter : ('a -> unit) -> unit ; getter : (string * ('a -> json)) list ; @@ -205,21 +206,22 @@ type buffer = { mutable updated : json list ; } -let add_entry buffer cols key v = +let add_entry buffer cols fkey key v = let fjs = List.fold_left (fun fjs (fd,to_json) -> try (fd , to_json v) :: fjs with Not_found -> fjs ) [] cols in - buffer.updated <- `Assoc( ("key", `String key):: fjs) :: buffer.updated ; + let row = (fkey, `String key) :: fjs in + buffer.updated <- `Assoc row :: buffer.updated ; buffer.capacity <- pred buffer.capacity let remove_entry buffer key = buffer.removed <- key :: buffer.removed ; buffer.capacity <- pred buffer.capacity -let update_entry buffer cols key = function +let update_entry buffer cols fkey key = function | Remove -> remove_entry buffer key - | Add v -> add_entry buffer cols key v + | Add v -> add_entry buffer cols fkey key v let fetch array n = let m = content array in @@ -239,7 +241,7 @@ let fetch array n = begin fun v -> let key = array.key v in if buffer.capacity > 0 then - add_entry buffer array.getter key v + add_entry buffer array.getter array.fkey key v else ( m.updates <- Kmap.add key (Add v) m.updates ; buffer.pending <- succ buffer.pending ) ; @@ -249,7 +251,7 @@ let fetch array n = m.updates <- Kmap.filter begin fun key upd -> if buffer.capacity > 0 then - ( update_entry buffer array.getter key upd ; false ) + ( update_entry buffer array.getter array.fkey key upd ; false ) else ( buffer.pending <- succ buffer.pending ; true ) end m.updates ; @@ -260,7 +262,9 @@ let fetch array n = (* --- Signature Registry --- *) (* -------------------------------------------------------------------------- *) -let register_array ~package ~name ~descr ~key ?(keyKind=name) +let register_array ~package ~name ~descr ~key + ?(keyName="key") + ?(keyKind=name) ~(iter : 'a callback) ?(add_update_hook : 'a callback option) ?(add_remove_hook : 'a callback option) @@ -275,7 +279,7 @@ let register_array ~package ~name ~descr ~key ?(keyKind=name) fd_descr = plain "Entry identifier." ; } :: List.map fst columns in let id = Package.declare_id ~package:package ~name:name ~descr - (D_array keyKind) in + (D_array { arr_key = keyName ; arr_kind = keyKind }) in let signal = Request.signal ~package ~name:(Package.Derived.signal id).name ~descr:(plain "Signal for array" @ href) in @@ -286,7 +290,7 @@ let register_array ~package ~name ~descr ~key ?(keyKind=name) let getter = List.map Package.(fun (fd,to_js) -> fd.fd_name , to_js) !model in let array = { - key ; iter ; getter ; signal ; + fkey = keyName ; key ; iter ; getter ; signal ; current = None ; projects = Hashtbl.create 0 } in let signature = Request.signature ~input:(module Jint) () in diff --git a/src/plugins/server/states.mli b/src/plugins/server/states.mli index fe842f6134609be1828317482881f9164bab2b1a..3e2c681cb406e8b08cf75a0e218871525f3a9967 100644 --- a/src/plugins/server/states.mli +++ b/src/plugins/server/states.mli @@ -124,6 +124,7 @@ val register_array : name:string -> descr:Markdown.text -> key:('a -> string) -> + ?keyName:string -> ?keyKind:string -> iter:('a callback) -> ?add_update_hook:('a callback) ->