Jump to content

drjdpowell

Members
  • Posts

    1,964
  • Joined

  • Last visited

  • Days Won

    171

Posts posted by drjdpowell

  1. I believe JKI JSON converts to Variants containing the basic JSON-matching types: String, Boolean, Number (DBL, I'm guessing).  Then it also provides, if I remember, a special VI to convert that Variant into your cluster of actual specific data types.

    One of the reasons I don't like that is that it ties things to a monolithic LabVIEW type, the Cluster, that is not as flexible as JSON Object/Arrays.  You show the same "LabVIEW tunnel vision" in your design of an array of "Group", "Name", "Value" clusters.  That's a common way to handle the limits of LabVIEW.   

    In JSON, the natural structure is this:

    {
    "Basic": 
       {
         "config file":"c:\\test\\config.ini",
         "Operator:"Muller"
       },
    "Extended": 
       {
         "Room Temp":21.4,
         "Test No":0,
         "ping":null
       }
    }

    That isn't really doable with your LabVIEW Arrays and Clusters, even if I give you some extra Variant support.  But you have tools to do stuff like this in JSONtext.  

  2. I would encourage you to try the "subJSON" described in the conversation LogMAN linked to.  Basically, replace your "Value" variant with a string labelled "<JSON>Value", and convert your values to JSON (at all the places where you now have "Set Data Name__ogtk.vi").  Then, wherever you are converting your variants to strict type, instead convert the subJSON to that type.

    The problem with using Variants and JSONtext is that the JSON doesn't contain the specific type information needed to recover the data in the Variant.

     

  3. 2 hours ago, SahnAlbert said:

    I want to get a Array with all Clusters where folder contains "Admin"

    I don't have the filtering syntax of JSONpath yet implemented in JSONtext.  In fact, you surprised me by seeming to indicate that $..[?(@.folder=="User/Admin/UserA")] actually works, when it doesn't.  At some point I may have teh time to implement that, but in the meantime consider filtering code in LabVIEW like this

     

    2021-11-30 08_45_02-Untitled 2 Block Diagram on Untitled Project 1_My Computer _.png

  4. 9 hours ago, rharmon@sandia.gov said:

    Dr. Powell says he never uses Date/Time to Seconds Function... What do you use? What makes your method stronger?

    I used to use  Scan From String function, with %T codes:

    143804446_2021-11-1108_53_53-Untitled109BlockDiagramonKeitSpectrometer.lvproj_MyComputer_.png.8bff9b0e442f960ad0888a077fbf47d0.png

    But I wouldn't say this was any stronger than your method.

    Now I use a reusable library for RFC3339 (subset of ISO-8601).  This uses Scan From String mostly, but is robust against a variety of edge cases.  Also handles things like the Local Time plus Offset format, which is nice in that it stores both Local Time and UTC time:

    735772709_2021-11-1109_01_25-Untitled109BlockDiagramonKeitSpectrometer.lvproj_MyComputer_.png.8f84ba11bc30561a7c5591ba75b37673.png

  5. 8 hours ago, rharmon@sandia.gov said:

    I'm finding it difficult to wrap my hard head around Dr. Powell's comment "I would go with DST=-1.  There will be one hour per year (Fall Back) where LabVIEW won't be able to know what the UTC time actually is (as there are two possibilities), but otherwise it would work.  Note, though, that i never use that function that you are using." How are there two possibilities about actual UTC Time? I can't have one hour a year when time isn't correct, my luck would have that one hour out of 8,760 hours be the actual time I truly need.

    There I was thinking about a simple fix to your immediate problem, rather than the much bigger change of switching to UTC.  Using DST=-1 is to use true Local Time, which is what your Users will find most intuitive.  But one time a year your times will jump back one hour, which is a rather problematic behaviour.  You could use Local Time never corrected for Summer Time; easier for you but confusing to Users.

    Aside: I suffer the programmer disadvantage of living in the Western European Timezone, which is the same as UTC for half the year, making it hard to notice errors in my UTC-Local conversion.  I often have my computer set to a far away Timezone when I'm debugging time-related things.

  6. JKSH has explained as well as I could the expected use.  "Missing from Object" is determined when operating on the Object.  

    I had a look, and it should be reasonably easy to give a different error for a string with only whitespace, but I'll need to understand use case for it better.  I, personally, never find the need to write custom error-handling code.

    By the way, if one's use case is "set from this JSON as much as possible, or use supplied default for items where this is not possible", then one can just not use the error wires at all.

  7. On 8/13/2020 at 11:28 AM, drjdpowell said:

    Note: I am considering uping Messenger Library's base LabVIEW version from 2013 to 2017.  This is to allow use adding actor templates that use JSONtext to do configuration, and to add VIMs to the palettes.  None of my clients use LabVIEW earlier than 2017.   Let me know if you use Messenger Library with LabVIEW earlier than 2017sp1 (sp1 fixed VIM bugs).

    I am actual about to commit to making the next release in LaVIEW 2019, rather than 2017, as VIMs were very new in 2017 and both buggy and of limited capability.  

     

    • Like 2
  8. 15 hours ago, Michael Aivaliotis said:

    is it possible to improve the error handling for empty strings? Perhaps have a special error code I can filter on if an empty string is detected?

     

    image.png

    Use case?   Why do you need different custom error than the 402841: "Invalid JSON formatting" that you have now?

  9. The problem I have with the Network Streams QoS arguement is that TCP already does this, using ACKs and retries to ensure an ordered stream.  And if I really needed to be sure a message is handled, I need to verify it all the way through the application to the final result, not just through the Network Stream message delivery.  For example, if I need to send something to be saved to disk, I need QoS all the way to disk, and would have to implement a custom buffer on the send side, layered on top of Network Streams.

  10. I've done this kind of thing, with a 32-bit-only dll needed from a 64-bit one.  Actually, it was two 64-bit Test Stations that both needed the same info from the 32-bit equipment, so having both be Clients of the 32-bit Server worked well.  I used the TCP capability of Messenger Library, which is very little effort.  

    One question: why Network Streams?  If you are wrapping things in your own API then why not a standard TCP connection?  What are Network Streams giving you?

  11. Does anyone actually use Variants in clusters in this way?  To me, this is not even a tertiary use case of JSONtext, so it would be helpful to hear from people with real-world uses.  I am tempted to suggest throwing a "Variants not supported" error, but even that would add overhead which I am loath to do.

  12. 15 minutes ago, Aristos Queue said:

    Recording an array when passed a NAMED cluster is definitely a bug, regardless of the behavior of the variants.

    Again, Variants are tricky, and have two names and serve two purposes.  Viewed as a container of named data, your Variants are just placeholders, not actual data themselves (which is why I suggested in the last post to put a named Variant as Data inside the placeholder).

  13. 1 hour ago, Aristos Queue said:

    Our use  case is nullable strings and nullable integers. We want to be able to differentiate between "this is the set value of the parameter (including possibly empty string)" and "this parameter has never been set, so defer to the default". So a cluster of variant correctly should record "null" for an empty variant and not-null for a non-empty variant.

    Consider just not including those parameters.  Rather than {"A":123,"B":null,"C":789} just have {"A":123,"C":789}; then "B" will be default.

    Alternately you could put named-Variant values inside your variants (which teh Variant-to-Data node will pass through:

    1090371450_2021-08-0517_26_42-Untitled2BlockDiagramonJSONtext.lvproj_MyComputer_.png.63907e2224240eac829f7dadb8bfa9d8.png

    Variants are quite tricky, as they can serve both as a temporary container for a value, and a value itself.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.