mardi 17 mars 2015

Best practices in block based or flow based system programming

I'm trying to implement a Labview-like system (in Java) where some blocks are capable of

- Sourcing

- Sinking

- Passing-through

the data.



Every block has a number of inputs (>= 0) and a number of outputs (>= 0) and is devoted to a function on inputting, outputting and transforming data. Data flow is represented as samples, taken from field measures coming from various devices (thermometers, wind-speed meters, irradiation sensors, power-meters and so on).



Every sample is related to an "epoch", that is an instant where all values are captured, starting from a trigger (source blocks should have a special trigger input), so a sample group coming from an epoch should be processed together with other samples from the same one.



A typical block-chain, for example, may be represented by a source (temp sensor), followed by an averager block (pass-through) and finally followed by a sink able to log data into a database (sink block).



I've implemented a push-like policy, where each block owns the "next-block" reference and calls a method on it passing the data to process. This policy works perfectly until it encounters a situation where a block (like a comparer block, with two float inputs and a boolean output), needs to output a comparation value based on the same sample epoch.



The problem is that I'm unable to find and apply a pattern that abstracts this problem. Maybe this is something similar to how Labview or Simulink blocks are working internally but I've still no success finding a "best-practice". Major problems with my "push-policy" is that, depending on chain sizes and depths, blocks with more than one input finish to work on samples belonging to different epochs (imagine a comparer block comparing two samples coming from two different measurement istants).



Thanks in advance for all advices, tips, best-practices and everything that will be able to solve my more-phylosophical-than-programming problem.


Aucun commentaire:

Enregistrer un commentaire