% % process xtx telemetry and downloaded program most recent % "Devices" text_conn <_> countup { pop %%% "devtelm" log)( % % monitor cloud messaging for this device % !Telem % % clear collection flags for this device % *machtels % % get the last program delivered % *machteln % % get the last telemetry delivered % *machtelt 0 !counter % % scan for programs and telemetry % parse through messages sifted for actionable % 0 !Mach.Xlate _Telem &"\" &_Subscription &"\" ofconn empty "Md*.*" !wilder prevfile { } { dup term2 "." left$ !Mach.Xlate } ifelse pop empty _Tsrv.Machines _Msys.HasMachine and _Telem _Device eq$ and { % % specific machine is being processed, sift through only processed messages % "Md*.xtx" } { % % no specific machine is being processed, sift through new and processed messages % "Md*.*" } ifelse !wilder { nextfile ? dup term2 "." left$ _Mach.PostTime ge ? *machmsgq { % % this message has proper format % is this first received block past the most recent cnc program % dup term2 "." left$ _Mach.Tlate gt %%% "Tlate" log)( { % % could be new cnc program fragment % pulling or end of pull, received text is part of cnc program % does the status reflect a pulling or pulled mode % execing dup term2 "." left$ _Mach.Plate gt { _Msg.Status dup _Devc.Pulling and nonzero exch _Devc.Drained and nonzero and "eligible " &_Msg.Status log)( { % % is pulling or pulled % does this message have received text % "Rcved" <_Msg.Lookup> "rcved" log)( { % % message has received text in pulling or pulled mode % _Mach.Pbuild { % % not first block, still collecting blocks % } { % % first block collection % empty !Mach.Phold true !Mach.Pbuild true !Mach.Proged } ifelse % % first or continuing, tally the reception into the program text % _Msg.Rcved hex2asc ^:Mach.Phold 0 !counter } if % % whether a reception block or not, check end of blocks % _Msg.Status _Devc.Pulled and nonzero { % % end of reception blocks, have we been collecting cnc program % _Mach.Pbuild { % % have been collecting cnc program % check that a percent sign is the last character % _Mach.Phold dup logs _Telem &"\" second trim dup 1 right "%" eq$ exch 1 left "%" eq$ and { % % valid fully received cnc program % &"pgm" } { % % not proper end of cnc program % &"imp" } ifelse &"_" third term2 "." left$ & &".pgm" ofconn write empty !Mach.Phold false !Mach.Pbuild } if } if } { % % this message is later than the last rcved cnc program % } ifelse } { % % not pulling or pulled mode % is this is a received telemetry text fragment % "Rcved" <_Msg.Lookup> { % % it is telemetry % dup term2 "." left$ _Mach.Tlate gt { % % newer than latest telemetry, collect the telemetry data % _Msg.Rcved hex2asc ^:Mach.Thold true !Mach.Tbuild } { % % earlier than the most recent telemetry block % } ifelse } if } ifelse } { % % block is earlier than possible new program % } ifelse } { % % no lookup, invalid message % } ifelse % % there was a cnc program or current telemetry in process % _Mach.Proged _Mach.Tbuild or { % % program processing or processed or has collected telemetry % } { % % this file can be shelved now % filing _Telem &"\xtx" ofconn folder &3 overwrite } ifelse % % keep track of last message received for telemetry marker % dup term2 "." left$ !Mach.Rlate +counter 500 gt ? } loop filing) _Mach.Tbuild { % % received valid telemetry block % _Mach.Thold _Telem &"\telm_" &_Mach.Rlate &".tlm" ofconn write } if _Mach.Rlate any? { !Mach.Tlate } if % % record the time of latest transaction for this device % _Mach.Tlate _Mach.Plate max _Mach.Xlate max _Telm ^"Device." ! } for