AzeoTech

Administrators
  • Posts

    6,432
  • Joined

Posts posted by AzeoTech

  1. So are you not getting an error from the first try?  Are you using the object form of the emailer or the generic email. version?  The object form blocks by default, but the generic email. is async and runs in the background so is difficult to error handle.

  2. To DAQFactory, an accelerometer is just a data value, a number, so really I think your question is how to properly connect the LabJack to an accelerometer and then how to tell the LabJack how to read it?  If so, then I would start by looking on the LabJack website as this is more about their hardware (for example here: https://labjack.com/pages/support?doc=%2Fapp-notes%2Fsensor-types-app-note%2Faccelerometers-app-note%2F), but then feel free to post more questions here.  I will make sure LabJack support sees this post as well.

  3. Does it generate multiples if you just do a single send call from DAQFactory without any retries?  I'd first check to see if the problem is essentially echoing, where the remote site gives up and tries again and generates an error but the message actually got through enough for the server to process.  This retry could be happening at a lower level than your script / DAQFactory which is why I ask if it generates multiples from a single call.  

    The default timeout for outgoing email at a lower level is 60 seconds.  At present we don't expose this so you can't edit it, but we could make this available if it comes to it.

  4. Yes, you can do:

    channel.restart()

    but it is often more reliable to simply create a while loop to sample the channels when you want.  If you put all your input channels in a single channel group, you can do:

    channel.readGroup("myGroup")

    where myGroup is the name of your group, and all the channels will be read once.  Set the timing to 0 on those channels of course...

     

  5. 1) use read(1).  Then after you can use readUntil() to read the rest, or you could read(1), then read(4).  Read() will read the specified number of characters (within the timeout period) and remove them from the buffer.

    2) the XOR operator in DAQFactory is #.  There is no #=, so you would have to do: tb_CheckSumme = tb_CheckSumme # EmpfangsBuffer[tb_Cnt]

     

  6. In DAQFactory ' and " are interchangeable, though they still have to be used in pairs.  So, you could do:

    system.shellExecute("reg",'delete "HKEY_CURRENT_USER\Control Panel\Desktop" /v scrnsave.exe /f')

    or something like that.  Notice how the first string, "reg" uses double quotes, but the second one I used single quotes to define the string.  The double quotes inside this string are processed as double quote characters in the string.

    As mentioned, you have to use them in pairs:

    "abc" and 'abc' result in the same string.  "abc' is invalid. 

    "abc'def'abc"

    results in a string:

    abc'def'abc

    while

    'abc"def"abc'

    results in the string:

    abc"def"abc

    If you need to use both ' and " inside your string, then you can concatenate up multiple strings.  For example to create the string:

    abc'def"abc

    you would do:

    "abc'de" + 'f"abc'

    or something similar (you can put the + in several places.  I chose between e and f to make it clearer).  

    If you have a lot of it, its sometimes clearer to create variables:

    private string sq = "'" // double quote, single quote, double quote
    private string dq = '"'  // its really hard to see, but that is a single quote, double quote then single quote
    private string out = "abc" + sq + "def" + dq + "abc"

    I rarely do this, but then you rarely need to use both so often.  I am more apt to use this method with carriage return / line feed pairs:

    private string CRLF = chr(13) + chr(10)
    private out = "get data" + CRLF

     

     

  7. 1) No, though that would be pretty easy to implement so I'll add it to the wish list. 

    2) you could provided the data isn't coming in too fast.  I'm not sure what too fast would be, but it might only be a problem at 115k baud or higher.  Anyhow the script goes something like this:  

    private handle = file.open("c:\data\myFile.dat",0,1,0,0)
    private string datain
    while(1)
       try
          datain = device.myDevice.read(480)
          file.write(handle, datain)
       catch()
          delay(0.05)
       endcatch
    endwhile

    A few points:


    1) obviously change the file name to what you want. Also, change myDevice to your device.

    2) the 480 in the read is a bit arbitrary.  If the data is continuously streaming you want a number that equal to about half the number of characters that would arrive in the timeout period.  So, if you were, say, at 9600 baud 8,n,1 you are talking 10 bits per character, or 960 characters per second.  If the timeout is 1000ms, then 480 is probably appropriate.  If your data is faster, then you'd need a larger number.  I believe the internal buffer is 10000 characters, so you should probably not go above 8000 or so

    3) the data is going to be logged in binary.  Converting it to an ASCII representation would be too slow for anything but the slowest baud rates.  Use a binary editor to view the data.  Visual Studio for example

    4) The above will work for ASCII as well and will write everything that comes in.

    5) I did not test this....  Make sure and save before you start the sequence.
          

     

     

  8. FromJson is limited to existing classes and requires the specification of the class name for each object.  This is something we are hoping to improve upon, probably in the next release, if not shortly after.  For now, you will have to split the array and process each element.  It's pretty easy to split the array since you can just search for { and }.  Once you have it down to a string like:

    {"time": 1689202773000,"frequency": 0,"temperature": 24.113449096679688,"density": 1.0002}

    You just need to define a class name in there.  So, first you need to declare a class.  It can be empty:

    class CData
    endclass

    Then inject the class name specifier in your string:

    {"_ClassName" : "CData", "time": 1689202773000,"frequency": 0,"temperature": 24.113449096679688,"density": 1.0002}

    Now you can use fromJson() and it will work.  Repeat for each object.

  9. Just use a flag to determine whether it should do the action, or popup.  I don't really like popups.  For example in your case, what happens if the nobody selects anything and the popup just sits there?  Should it act like a snooze and wait for a response, or activate the alarm?

  10. Actually, the output string is 6 bytes.  It is just that 0x38 is the ASCII code for the number 8.  That is why it reads \x008 at the end.  \x00 is the 5th byte, while 8 (ASCII) is the 6th byte.  You should, in general, always have "Display all chars as ASCII codes" checked when working with binary protocols.  Note also that 8 ASCII and 0x38 are the exact same thing and result in a single byte (0x38) being sent out the port.

  11. You are on the right track by using beginseq() when you want to do anything with a delay().  As for snooze, the logic is pretty simple.  In your fire_seq do something like:

    global actionTime = systime() + 2*60  // default is 2 minutes after now
    while(systime() < actionTime)
       delay(1)
    endwhile
    // do the desired action

    Then in the action script of your button, simply put:

    actionTime += 58*60 

    to add 58 minutes to the action time. As long as it is pressed within the 2 minutes, it will extend it.  You can add additional logic too, for example, not doing it if the alarm resets.

    Note: You could of course replace 2*60 with 120, but it is little CPU expense and much clearer the way I did it.

  12. No.  DAQFactory was never designed to be a data analysis tool.  It just has some basic functions.  Of course you could extend it using the extern() function to bring in a DLL, but truthfully, you can't really interpolate at the ends well with any tool without making a bunch of assumptions.  If you know its a 4th order polynomial, then that is a piece of data that would help make the interpolation more accurate, but DAQFactory's interpolate tool doesn't take that into account.

  13. 1st: sorry, if you look in the forum post, at least on my screen the x shows up a little higher than a normal x.  I think it is just the forum software thinking it is a multiplication symbol, but I want to make sure you use an actual x, the letter, when you use it for hex.  Considering my post also has the raised x, I think you are just fine.

    2nd: you can't really do it differently in event driven environments like Windows (and thus DAQFactory).  There is an event when the mouse button goes down, and another when it goes up.  There is nothing in between, so you have to implement it, and it needs to run in the background.  We could, I suppose, add a background thread, but that would just replicate something that you can already do easily in DAQFactory, with less flexibility.

  14. 1st question: yes.  But make sure it is an actual x.  It might be the forum software, but it rendered 0x80 with a different character for the x.  It should be the letter x.

    2nd question: do you want it to repeatedly send that string?  To do something that starts on mouse button down, and stops on mouse button up, use two Actions.  The first, with "Mouse Down" checked, should start a sequence using beginseq().  The second, without Mouse Down checked, should stop the sequence.  The sequence should have a loop and do whatever you want to do while the mouse it held down.

  15. The U3 is part of the LabJackUD driver.  I am sorry it is confusing, but LabJack has three different series of devices and they chose the names for their drivers.  The U12 goes with LabJack_U12.  The U series devices (U3, U6, UE9) all fall under the LabJackUD.  The new T series devices all fall under the LabJackM device.

     

  16. DAQFactory doesn't write directly to Excel, it writes to CSV files which you can open in Notepad and view.  Open it in Notepad and look and see if the numbers are rounded there. 

    If they are rounded, then the issue is the sig figs you have specified in the logging set.  Sig figs is NOT the same as what DAQFactory calls precision.  Precision is the number of digits after the decimal point.  Sig figs is significant figures, a scientific standard.  So 145242.6 to 4 significant figures is 145200.  

    If they are not rounded in the file, then the issue is the formatting that Excel is doing.

  17. You won't get an "unable to initialize" error on a port if it is the only port and you reconfigure it.  Either you have another port you don't know about (CLV?) or Windows is having troubles closing the port before reopening, something you sometimes see in virtual comm port drivers (which includes USB to serial converters), and is thus one of the many reasons I recommend against using these.  These drivers are not created by Microsoft, but instead by the vendor, and in the case of cheaper USB to serial converters, the software is equally cheap.  I recommend using a quality converter from a reputable company, say, SeaLevel or just using an ethernet to serial converter (also available from SeaLevel) where they offer a Raw port allowing use without a driver.  Otherwise you will largely have to deal with it since it is a Windows level issue.

    But to answer your question, you can, of course, juse open the configure page again and hit save and it will reinit the port.  The only way to close a port is to give it a different port number (if available) or set it to 0, which closes it without opening a new one.  This applies to TCP too: set the Port of a TCP connection to 0 and it will close the existing socket without opening a new one.  This is a great way to create ports that may or may not be used by a particular instance of your application.

  18. Yes, because so many people are always logged in on admin accounts (I certainly am right now), the folks at Microsoft decided to make it so some actions are not allowed, by default, for the admin, and require you to explicitly say "run as administrator" or acknowledge the action.  If you don't, then even if you are logged in as an admin, the user level application, in this case DAQFactory, does not get full administrator access unless you explicitly allowed it by doing "run as administrator"

     

  19. A couple things:

    1) I recommend against using var. notation.  This is left over from very old ( > 15 years) releases of DAQFactory.  Instead use variable declaration.  So:

    global count_1 = 0
    global count_2 = 0
    global habilitacion = 0
    while(1)
       if (habilitacion >= 1)
          count_2 = count_2 + count_1
       endif
    endwhile
    

    2) you have an infinite while() loop without any delay.  This script will use a lot of CPU power, most of which will be wasted.  I suggest adding at least a delay(0.01) before the endwhile.

    As for the rest, the script looks fine.  It will loop forever and whenever habilitacion >=0, it will increment count_2 by count_1.

     

  20. First part: http.get() just uses the OpenURL() function of the MFC CInternetSession class.  It is a pretty dead simple wrap of this function.  https://learn.microsoft.com/en-us/cpp/mfc/reference/cinternetsession-class?view=msvc-170.  DAQFactory will automatically add http:// in front.  It will also add :5000 to the end.  For the path, if you don't start with / it will add it for you.  Note you should see an error message in the command alert if it fails.  Are you not getting one?

    As to the second question, first, are you just trying to run a command line?  If so, why don't you just use system.shellExecute()?  There is no reason to right a DLL.  System.ShellExecute() does not block, which, actually is the only reason I can think that you would want to create a DLL to wrap it.  There are cases when you want to run a shell program, and then likely you piped the result to a file that you can then read into DAQFactory.  If you don't block you have to use other tricks to make sure it is complete.

    Anyhow, to your original question, you can make pretty much anything non-blocking in DAQFactory by simply putting it in its own sequence or thread.

  21. This is a lot like a GPS unit.  Anyhow, basically you just do reads without any writes and let the loop automatically pause on the reads (so no Delay() except maybe inside a catch()).  The trick is alignment, but usually those units have a CRLF at the end and some sort of string at the beginning that tells you what the line of data contains.  Let's assume it does end with a CRLF and that it starts with "$GPRMC" (a GPS standard data packet).  It'd go something like this:

    private string datain
    device.myDevice.purge()
    while(1)
       try
          datain = device.myDevice.ReadUntil(10) // note LF.  If just a CR then change to 13
          if (left(datain,6) == "$GPRMC")
             // process the datain string
          endif
       catch()
          ? strLastError // if you want
          delay(0.01) // just in case.  Can remove or make smaller once tested
       endcatch
    endwhile

    That is pretty much it.  You just need to add parsing script.  If the string doesn't start with $GPRMC it is tossed and the next line is read.  You don't need a delay() because the readUntil() will delay until it receives the full line.