Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

execute slowsequence entering values in public


kokihualpa May 1, 2020 11:28 PM

I want to execute a routine in slowsequence (in the program of CR1000) but when I put some values in public and so the routine start. Is it possible?


JDavis May 4, 2020 04:17 PM

 I think the below example code will answer your program. The Trigger variable is only ever set to True by a user manually changing it with connected software.

Public PTemp, Batt_volt
Public Trigger As Boolean

'Main Program
BeginProg
  Scan (1,Sec,0,0)
    PanelTemp (PTemp,60)
    Battery (Batt_volt)


    CallTable Test
  NextScan

  SlowSequence
  Scan (1,Sec,3,0)
    If Trigger Then
      Trigger = False 'Include this line if you want sequence to only run once
      
      'Add other code here.
      
    EndIf
  NextScan

EndProg

 


kokihualpa May 5, 2020 08:06 PM

Thank you very much it is work.

An aditional question:

when I want the sequence starts and with some values like for example: hour=16 , day=05 , year=20 .

like so

If Trigger AND hour AND day AND year Then
      Trigger = False 'Include this line if you want sequence to only run once
      
      'Add other code here AND THIS CODE CONTAINS THE VARS HOUR, DAY AND YEAR.
      
    EndIf


JDavis May 5, 2020 08:38 PM

Yes, you can combine conditions. I prefer to always add parentheses to make sure the order of operations is what I expect.

  If (Trigger = True) AND (hour = 16) AND (day=5) Then


Nigel Jun 3, 2020 02:45 AM

Personally I find more than one AND conditional argument problematic and you quite often get unexpected results.

I have found it far more reliable to nest 'if' arguments for each question, despite more code, it is easier to read through a program

See this example, I have string for 5 treatments for each month of the year. Each minute scan I pass the strings collection through this test. If they fail the first stage it passes to the next for next.

I ask for the current julian day, this has to be correct to then current hour, if this is correct then compare the minute then a conditional trigger. 

If this is all correct then i can break up the string to redefine program parameters.

When I tested this with 'AND'  'AND'  'AND'  it didn't always work. Same with 'OR' conditions. You seem to have to add parentheses to make ((a = b) AND ( c = d)) AND (( e = f) AND (g = h)), which isnt the same argument.  

 

For y=1 To 5
               For x=1 To 12
                    QD = Mid(KeyTreatment(x,y),2,3)'JulianDay
                    QH = Mid(KeyTreatment(x,y),5,2)'Hour
                    QM = Mid(KeyTreatment(x,y),7,2)'Minute
                    QT = Mid(KeyTreatment(x,y),25,2)'Treatment number, Treatment lock
                    'Load treatment into keycurrent on triggers,Julian,Hour,Minute
                    If QD  = JulianDay Then
                         If QH = Hour Then
                              If QM = Minute Then
                                   If QT = Treatmentlock(y) Then
                                        KeyCurrent(y) = Left(KeyTreatment(x,y),26)'loads whole keytreatment key number into keycurrent
                                        'Load keycurrent setup into treatment
                                        EventApp(y)=Mid(KeyCurrent(y),9,3)
                                        Climate_mm(y) = Mid(KeyCurrent(y),12,2)
                                        Rain0_IrrigC1_Irrig2(y) = Mid(KeyCurrent(y),14,3)
                                        IrrigDays(y) = Mid(KeyCurrent(y),17,2)
                                        Intensity(y) = Mid(KeyCurrent(y),19,3)
                                        HighLowLimit(y) = Mid(KeyCurrent(y),22,3)
                                   EndIf
                              EndIf
                         EndIf
                    EndIf
               Next x
          Next y

 

 

Log in or register to post/reply in the forum.