DQMH Consortium Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Generic Cloneable Logger Module

Hi,

 

I am relatively new to DQMH, but I have really enjoyed using it, especially after struggling with the Actor Framework.  What I am trying to do now, but finding myself hitting a wall, is to create a generic logger 'cloneable' module.  For each device module, I want to create its own logger.  The idea is that each time a device module is launched, an instance of the cloneable logger module is launched.  The device generates data which is stored in a queue and that queue is shared with the logger, which has its own helper loop to dequeue each element and save it to disk.  The problem I am experiencing is with having the queue reference as an input to the logger.  Since each device may generate different data (e.g. 2D array, waveform, etc.), then I need to create a generic queue reference.  I tried doing this using the variant data type and the 'to more specific class.vi' with the target class being a queue reference corresponding to the specific data type generated by my device.  But, this does not work and generates an error.  I also tried making a simple VI just to test whether I can convert between a queue ref of one data type to another and that fails.  My feeling is that I will have to implement OOP to get this to work, but I'm not sure how.  Any advise?

0 Kudos
Message 1 of 3
(1,105 Views)

Hi, 

 

Glad to know that you are liking DQMH and you are making progress on your programs.

 

My suggestion would be to make your logger module more generic. What we have done in the past is create a logger module that receives an array with the header items via a request called "Set Header" and when we want to log data, we send the data already formatted as a string array for "Log Data". You could also change that to send the data as a binary array. You could also log the data as a JSON or XML text.

 

If you want to get more specific, you could make the argument of Log Data an object and then have your different modules send a child of that object. You would then have a dynamic dispatch method that knows how to convert your specific data to the type of log file you are using.

 

Hopefully, this gives you some direction. 

 

Let us know how your project goes on.

 

Best regards,

Fab

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 2 of 3
(1,047 Views)

Note: one uses "Variant to Data" to convert variants, not "to more specific class" (which is just used with classes).

0 Kudos
Message 3 of 3
(1,040 Views)