Loading ...
Sorry, an error occurred while loading the content.

Re: How can I test the current speed in a script?

Expand Messages
  • francois.rogez
    2 follow-up questions (my script is actually not working): 1) I assumed that you apply the profile definitions defined in OTWINCFG as: if profile n / do once /
    Message 1 of 8 , Mar 15, 2013
    • 0 Attachment
      2 follow-up questions (my script is actually not working):

      1)
      I assumed that you apply the profile definitions defined in OTWINCFG as:
      if profile n / do once / ... / end block / end block
      Is this true?

      2)
      if my script also has a" if profile n / do once", which one (my script
      or you profile) will actually set a given parameter (like POWER, or
      INTERVAL). Should I wait 1 second after the profile switch before trying
      to overwrite the parameters defined in the profile?

      Thanks


      --- In tracker2@yahoogroups.com, "francois.rogez" <ffdef@...> wrote:
      >
      > Thank you Scott, this would be nice to have.
      >
      > As a workaround, I wrote a script to override the parameters set by
      the
      > profile, for the first n minutes after the transition, then revert to
      > the same parameters as the profile has.
      > This seems to work.
      >
      > --- In tracker2@yahoogroups.com, Scott Miller scott@ wrote:
      > >
      > > Speed isn't presently one of the things you can check from a script.
      > I
      > > can add that to my to-do list for the next release.
      > >
      > > Scott
      > >
      > > On 3/14/2013 10:52 AM, francois.rogez wrote:
      > > > I am looking for advice/examples on detecting condition based on a
      > speed
      > > > threshold in a script.
      > > >
      > > > My current setup uses a speed threshold to transition between the
      2
      > > > profiles, but I would like this transition to only happen if the
      > speed
      > > > is below the threshold for a given number of minutes. I think a
      > script
      > > > is needed.
      > > >
      > > > The wiki has some script examples, and the "Comparing Analog
      > Readings"
      > > > is close to what is needed; I just need to replace the 'Exec
      "analog
      > 1
      > > > in"' statement with something that will return the current speed.
      > > >
      > > > Any ideas?
      > > >
      > > > Thanks
      > > >
      > > > Francois
      > > >
      > > >
      > >
      >
    • Scott Miller
      ... Yes, this should run a block of code once when the profile test is true. ... The profile switching doesn t set parameters, it just determines which of two
      Message 2 of 8 , Mar 15, 2013
      • 0 Attachment
        > I assumed that you apply the profile definitions defined in OTWINCFG as:
        > if profile n / do once / ... / end block / end block
        > Is this true?

        Yes, this should run a block of code once when the profile test is true.

        > 2)
        > if my script also has a" if profile n / do once", which one (my script
        > or you profile) will actually set a given parameter (like POWER, or
        > INTERVAL). Should I wait 1 second after the profile switch before trying
        > to overwrite the parameters defined in the profile?

        The profile switching doesn't set parameters, it just determines which
        of two complete sets of parameters is used. Command line commands will,
        by default, act on the currently active profile. You can override that
        and force a specific profile to be updated.

        Scott
      • James Ewen
        ... As stated, speed is not a variable that can be accessed in a script currently, but it can be tested against via profile switching. ... Sounds like it...
        Message 3 of 8 , Mar 15, 2013
        • 0 Attachment
          On Thu, Mar 14, 2013 at 11:52 AM, francois.rogez <ffdef@...> wrote:

          > I am looking for advice/examples on detecting condition based on
          > a speed threshold in a script.

          As stated, speed is not a variable that can be accessed in a script
          currently, but it can be tested against via profile switching.

          > My current setup uses a speed threshold to transition between the 2 profiles, but I would like
          > this transition to only happen if the speed is below the threshold for a given number of minutes.
          > I think a script is needed.

          Sounds like it...

          > Any ideas?

          It all depends upon what you need this routine to do, and how much you
          are changing between the profiles.

          Let's pretend that you want to change the path used from WIDE2-2 while
          moving to WIDE2-1 when sitting still, but only after sitting still for
          5 minutes.

          So set both profiles up identically, with WIDE2-2 as the path. Set up
          the profile switching so that you switch to profile 2 when speed is
          below 5 mph. Switch to profile 1 when speed is above 10 mph.

          So, you're thinking... that's silly, why have two profiles the same
          and switch between them based on speed?

          We'll we can't test against speed in a script, but we can test against
          which profile we are in, and we can set which profile we are in based
          on speed, so really it's kind of a derivative work, but we can test
          against speed in a round-about way. With both profiles identical, you
          can't tell that there is a change, except that the tracker has
          internally switched profiles.

          So now what?

          Well, set up a script that tests against being in profile 2, and while
          in profile 2, start a timer. Increment the timer every second, and
          when the timer reaches 300 (5 minutes * 60 seconds), execute the
          command to change the path to WIDE2-1.

          You'll need to test if you switch back to profile 1, and if you do,
          clear the timer value to zero, and set the path in profile 2 back to
          WIDE2-2. You can set a variable to check to see if you've changed
          parameters while in profile 2 or not so you don't do unnecessary
          writes.

          There you go, profile switching based on speed...

          You can change as many parameters as required and desired.

          Be aware that every time you write a parameter change, you wear out
          the memory slightly. That would be why you would want to keep track of
          whether you need to reset parameters back when in profile 1 or not. No
          need wearing the thing out prematurely.

          So, what do you want to do, and how often do you want to do it?

          --
          James
          VE6SRV
        • francois.rogez
          ... Thanks James, I updated my script based on your explanation.My initial script was not working, because I had assumed that the profiles defined in OTWINCFG
          Message 4 of 8 , Apr 2 10:34 AM
          • 0 Attachment
            --- In tracker2@yahoogroups.com, James Ewen <ve6srv@...> wrote:
            > It all depends upon what you need this routine to do, and how much you
            > are changing between the profiles.
            >
            > Let's pretend that you want to change the path used from WIDE2-2 while
            > moving to WIDE2-1 when sitting still, but only after sitting still for
            > 5 minutes.

            ...

            > Well, set up a script that tests against being in profile 2, and while
            > in profile 2, start a timer. Increment the timer every second, and
            > when the timer reaches 300 (5 minutes * 60 seconds), execute the
            > command to change the path to WIDE2-1.
            >
            > You'll need to test if you switch back to profile 1, and if you do,
            > clear the timer value to zero, and set the path in profile 2 back to
            > WIDE2-2. You can set a variable to check to see if you've changed
            > parameters while in profile 2 or not so you don't do unnecessary
            > writes.

            ...

            > So, what do you want to do, and how often do you want to do it?
            >
            > --
            > James
            > VE6SRV

            Thanks James, I updated my script based on your explanation.
            My initial script was not working, because I had assumed that the profiles defined in OTWINCFG were static, and just used to set the active parameters.
            Instead, as you described, the profiles are directly modified avery time a script modifies a parameter, therefore I needed to re-set the parameters to their original value.
            The parameters I want to change are POWER, INTERVAL, and COMMENT.
            The attached script has been working well for the last 2 weeks

            If Profile 1
              Do Once
                Exec "POWER ON"
                Exec "INTERVAL 60"
                Exec "COMMENT S"
                Set Counter 1 = 0
                Exec "BEACON"
              End Block
              On Second
                Increment Counter 1
                If Counter 1 = 300
                  Exec "COMMENT P"
                  Exec "POWER 3"
                  Exec "INTERVAL 900"
                End Block
              End Block
            End Block
            If Profile 2
              Do Once
                Exec "COMMENT M"
                Exec "BEACON"
              End Block
            End Block


          • James Ewen
            ... Yeah, you really need to understand what is happening, and where it is happening. I could see getting tripped up on that aspect. Just think of scripting as
            Message 5 of 8 , Apr 2 6:58 PM
            • 0 Attachment
              On Tue, Apr 2, 2013 at 11:34 AM, francois.rogez <ffdef@...> wrote:

              > Thanks James, I updated my script based on your explanation.
              > My initial script was not working, because I had assumed that the profiles
              > defined in OTWINCFG were static, and just used to set the active parameters.
              > Instead, as you described, the profiles are directly modified avery time a
              > script modifies a parameter, therefore I needed to re-set the parameters to
              > their original value.

              Yeah, you really need to understand what is happening, and where it is
              happening. I could see getting tripped up on that aspect. Just think
              of scripting as you sending commands to the unit. I still have to sit
              and ponder on changing parameters in the other profile and such...
              scripting is pretty darned powerful. I like it when people dream up
              weird things to do, and ask how to do it. It's a challenge to see if
              you can figure out how to complete the task with the tools available.

              > The parameters I want to change are POWER, INTERVAL, and COMMENT.
              > The attached script has been working well for the last 2 weeks

              The script looks okay...

              > If Profile 1
              > Do Once
              > Exec "POWER ON"
              > Exec "INTERVAL 60"
              > Exec "COMMENT S"
              > Set Counter 1 = 0
              > Exec "BEACON"
              > End Block

              So when profile 1 tests are true, and the unit is in profile 1, you
              fire up whatever is hooked up to the power output, send an immediate
              position report followed by one every minute with a comment of S until
              5 minutes elapses.

              > On Second
              > Increment Counter 1
              > If Counter 1 = 300
              > Exec "COMMENT P"
              > Exec "POWER 3"
              > Exec "INTERVAL 900"
              > End Block
              > End Block
              > End Block

              So once 5 minutes elapses, the interval gets changed to 15 minutes,
              and the power to the external device gets turned off until 15 minutes
              has elapsed, where upon power gets turned on for 3 seconds before a
              transmission occurs (with a comment of P), then power gets shut off.
              The timer runs continuously, so the counter 1 = 300 becomes true about
              every 18.2 hours. (I beleive the max counter value is 65535, and it
              rolls over back to 0) Putting the contents of the IF statement within
              a DO ONCE block would make it only happen once. This is minor, but
              there are a maximum number of write cycles available. Rewriting once
              every 18 hours is going to take a long time to wear out the device,
              but the DO ONCE will make it only happen once per switch to profile 1.

              > If Profile 2
              > Do Once
              > Exec "COMMENT M"
              > Exec "BEACON"
              > End Block
              > End Block

              You shouldn't have to do this at all if the comment is set to M, and
              you select "Transmit when switching to this profile" on the profile
              switching page. All parameters in profile 2 are not affected by what
              you do while in profile 1.

              --
              James
              VE6SRV
            Your message has been successfully submitted and would be delivered to recipients shortly.