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

Help creating a loop....

Expand Messages
  • Steve
    Hello all, I am trying to write a program to control a video switcher. Making the switcher and LB talk VIA RS232 is no problem, I have the whole HEX/Decmial
    Message 1 of 3 , Apr 27, 2006
    • 0 Attachment
      Hello all,

      I am trying to write a program to control a video switcher. Making
      the switcher and LB talk VIA RS232 is no problem, I have the whole
      HEX/Decmial thing down pat. I have four buttons on my form that I can
      use to manually switch things. I then tried to get fancy and created
      a "button FIVE" to start an "automation" so my video switcher changes
      between diffrent sources on its own. This is where I am "skunked",
      creating a sub for a repeating loop. My program has a clock, so I am
      trying to use time checks to trigger my video switcher. I know I keep
      creating an endless loop, and I am not sure how to get this going.

      For example:

      [button5Click]
      confirm "Automate WX Radar & Router 24 source?"; answer$
      if answer$ <> "yes" then wait
      if answer$ <> "no" then print #tile1.textbox50, "AUTOMATION ON"
      if answer$ <> "no" then goto [auto]
      wait
      '--- Fire RS232 commands at video switch
      '--- Router 1 crosspoint is MasterControl
      '--- Router 2 crosspoint is NASA-TV
      '--- Router 3 crosspoint is WX Radar
      '--- Router 4 Crosspoint is BTS Router 24
      '--- Every 30 sec Switch to Router 24 source
      [auto]
      '--- NOTE it takes three seconds for switched video to show on
      air due to MPEG encode delay
      if currentseconds=57 then print #tile1.textbox50, "Router 24 to 36-2
      Air"
      if currentseconds=57 then print #com1port, chr$(2) + "0" + "1" + "3"
      + "3";
      if currentseconds=27 then print #tile1.textbox50, "WX Radar to 36-2
      Air"
      if currentseconds=27 then print #com1port, chr$(2) + "0" + "1" + "2"
      + "2";
      goto [auto]
    • pendl2megabit
      Message 2 of 3 , May 2, 2006
      • 0 Attachment
        >
        > Hello all,
        >
        > I am trying to write a program to control a video switcher. Making
        > the switcher and LB talk VIA RS232 is no problem, I have the whole
        > HEX/Decmial thing down pat. I have four buttons on my form that I can
        > use to manually switch things. I then tried to get fancy and created
        > a "button FIVE" to start an "automation" so my video switcher changes
        > between diffrent sources on its own. This is where I am "skunked",
        > creating a sub for a repeating loop. My program has a clock, so I am
        > trying to use time checks to trigger my video switcher. I know I keep
        > creating an endless loop, and I am not sure how to get this going.
        >

        How about using the TIMER command ???

        [start.auto]
        timer 30000, [auto]
        wait

        [stop.auto]
        timer 0
        wait

        The two branches above are the event handlers for your buttons 5 and 6.

        The timer will execute the [auto] branch every 30 seconds in this case.
        If you have variable length videos, you can use a variable instead of the
        fixed value:

        delay = video.length

        ...

        timer delay, [auto]

        ---
        Stefan Pendl



        ___________________________________________________________
        Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
      • Steve
        Thanks for the help. I did a bit a help file, web site and book reading and came up with the answer. It was simple. I have clock in the program, I did the
        Message 3 of 3 , May 2, 2006
        • 0 Attachment
          Thanks for the help. I did a bit a help file, web site and book
          reading and came up with the answer. It was simple. I have clock in
          the program, I did the following.

          IF currentseconds = TS then gosub [auto]

          The program works, and is VERY stable. It is a work in progress and I
          am learing to program from it.

          Thanks for the help!

          Steve

          ' Evertz X0400 Remote By Steve Pietras Ver 1.12

          '--- hope someday to have a enterable timer value
          '-----Begin code for #tile1 interface --------
          nomainwin
          Com = 16384
          open "com1:9600,n,8,1,ds0,cs0,rs" for random as #com1port
          WindowWidth = 330
          WindowHeight = 240
          UpperLeftX=int((DisplayWidth-WindowWidth)/2)
          UpperLeftY=int((DisplayHeight-WindowHeight)/2)

          'VARIBLES USED ARE TH, TM, TS, AUTO

          '--- GUI INTERFACE STUFF
          button #tile1.button1,"MC",[button1Click], UL, 25, 110, 70, 25
          button #tile1.button2,"Two",[button2Click], UL, 95, 110, 70,
          25
          button #tile1.button3,"WX Radar",[button3Click], UL, 165, 110,
          70, 25
          button #tile1.button4,"Router",[button4Click], UL, 235, 110,
          70, 25
          button #tile1.button5, "Automation On",[button5Click], UL, 195,
          40, 110, 25
          button #tile1.button6, "Automation Off", [button6Click], UL, 195,
          70, 110, 25
          'button #tile1.button7, "Timer", [button7Click], UL, 25, 70, 70,
          25
          '---- textbox property format: x, y, width, height
          textbox #tile1.textbox1, 50, 7, 25, 25 'hour clock
          textbox #tile1.textbox2, 80, 7, 25, 25 'minute clock
          textbox #tile1.textbox3, 110, 7, 25, 25 'second clock
          statictext #tile1.statictext30, ":", 75, 9, 4, 20 'clock
          hour colen
          statictext #tile1.statictext25, ":", 105, 9, 4, 20 'clock
          minute colen
          statictext #tile1.statictext35, "Current Time", 150, 7, 100,
          20
          'statictext #tile1.statictext28, ":", 75, 40, 4, 20 ' Hour
          timer colen
          'statictext #tile1.statictext29, ":", 105, 40, 4, 20 ' minute
          timer colen
          statictext #tile1.statictext32, "Last Command Status", 32, 140,
          300, 30 'Status title

          'TextboxColor$ = "red" 'define color of record time text box
          'textbox #tile1.textbox38, 50, 37, 25, 25 'Hour box timer
          'textbox #tile1.textbox39, 80, 37, 25, 25 'minute box timer
          'textbox #tile1.textbox40, 110, 37, 25, 25 'second box timer
          TextboxColor$ = "darkgray" 'define back color status display off
          textbox #tile1.textbox50, 12, 170, 300, 42 'Switch- press readout
          textbox #tile1.textbox51, 138, 45, 54, 40 'automation on/off
          status

          '----- End GUI objects code -------

          '----- define font sizes for textboxes and controls
          open "WUPW-SD 36-2 Automation Control V 1.12" for window_nf as
          #tile1
          print #tile1, "font arial 10" 'defines the default font size of
          text on form
          print #tile1.statictext30, "!font arial 12 bold"
          print #tile1.statictext25, "!font arial 12 bold"
          'print #tile1.statictext28, "!font arial 12 bold" 'hour timer
          colen font size
          'print #tile1.statictext29, "!font arial 12 bold" 'minute timer
          colen font size
          'print #tile1.statictext32, "!font arial 18 italic bold" 'Status
          lable
          print #tile1.statictext35, "!font arial 12 italic" 'time lable
          print #tile1.textbox50, "!font arial 18 bold italic"
          print #tile1.textbox51, "!font arial 16 bold"
          'start current time program
          [clock]
          'current hours
          currenthours = int((time$("seconds")/60)/60)

          [Hours]
          print #tile1.textbox1, currenthours
          if currenthours <10 then print #tile1.textbox1,"0";currenthours
          goto [minutes]

          [minutes]
          minutes = int(time$("seconds")/60)
          currentminutes = minutes - (int(minutes / 60) * 60)
          if currentminutes <10 then print
          #tile1.textbox2, "0";currentminutes
          if currentminutes >9 then print #tile1.textbox2, "";
          currentminutes

          [seconds]
          'current seconds
          currentseconds = time$("seconds") - (int(time$("seconds") / 60) *
          60)
          if currentseconds <10 then print
          #tile1.textbox3, "0";currentseconds
          if currentseconds >9 then print #tile1.textbox3, "";
          currentseconds

          timer 1000, [clock]
          '[autologic]
          if auto=1 then gosub [auto]
          if auto=1 then print #tile1.textbox51, "ON"
          if auto=0 then gosub [manual]
          'if auto=0 then print #tile1.textbox51, "OFF"
          [manual]
          '--- timer logic
          '[TH]
          'if currenthours > TH then auto=0
          'if currenthours < TH then auto=0
          'if currenthours = TH then goto [TM]
          '[TM]
          'if currentminutes > TM then auto=0
          'if currentminutes < TM then auto=0
          'if currentminutes = TM then gosub [TS]

          '[TS]
          'if currentseconds > TS then auto=0
          'if currentseconds < TS then auto=0
          'if currentseconds = TS then auto=1
          'if currentseconds = TS then gosub [autologic]
          'if currentseconds = TS then print #tile1.textbox50, "TS JUST RAN"

          '----- X Tile close, shutdown program -----
          Print #tile1, "trapclose [quit]"
          wait

          '--- Fire RS232 commands at SD EVERTZ switch
          '--- Router 1 crosspoint is MasterControl
          '--- Router 2 crosspoint is NASA-TV
          '--- Router 3 crosspoint is WX Radar
          '--- Router 4 Crosspoint is BTS Router 24
          '--- Top Of Hour Switch to Router 24 source
          [auto]
          '--- NOTE it takes three seconds for switched video to show on
          air due to MPEG encode delay
          if currentseconds=57 then print #tile1.textbox50, "Router 24 to
          36-2 Air"
          if currentseconds=57 then print #com1port, chr$(2) + "0" + "1"
          + "3" + "3";
          if currentseconds=27 then print #tile1.textbox50, "WX Radar to 36-
          2 Air"
          if currentseconds=27 then print #com1port, chr$(2) + "0" + "1"
          + "2" + "2";

          return

          ' ----- Switcher Commands -------
          [button1Click]
          'ask if the user wants to Switch
          confirm "Switch to Master Control?"; answer$
          if answer$ <> "yes" then wait
          if answer$ <> "no" then Print #com1port, chr$(2)
          + "0"+"1"+"0"+"0"; 'switch enabled
          if answer$ <> "no" then print #tile1.textbox50, "Master Control to
          Air"
          wait

          [button2Click]
          'ask if the user wants to Switch
          confirm "Switch to Input TWO?"; answer$
          if answer$ <> "yes" then wait
          if answer$ <> "no" then Print #com1port, chr$(2)
          + "0"+"1"+"1"+"1"; 'switch enabled
          if answer$ <> "no" then print #tile1.textbox50, "Input TWO"
          wait
          [button3Click]
          'ask if the user wants to Switch
          confirm "Switch to WX Radar?"; answer$
          if answer$ <> "yes" then wait
          if answer$ <> "no" then Print #com1port, chr$(2)
          + "0"+"1"+"2"+"2"; 'switch enabled
          if answer$ <> "no" then print #tile1.textbox50, "WX Radar To Air"
          wait
          [button4Click]
          'ask if the user wants to Switch
          confirm "Switch to BTS Router 24 ?"; answer$
          if answer$ <> "yes" then wait
          if answer$ <> "no" then Print #com1port, chr$(2)
          + "0"+"1"+"3"+"3"; 'switch enabled
          if answer$ <> "no" then print #tile1.textbox50, "BTS Router 24 to
          Air"
          wait
          [button5Click]'automation on
          confirm "Automate WX Radar & Router 24 source?"; answer$
          if answer$ <> "yes" then wait
          if answer$ <> "yes" then auto=0
          'if answer$ <> "no" then print #tile1.textbox51, "ON"
          if answer$ <> "no" then auto=1
          if answer$ <> "no" then gosub [auto]
          wait
          [button6Click]'automation off
          confirm "Shutdown Automation?"; answer$
          if answer$ <> "yes" then wait
          if answer$ <> "yes" then auto=1
          if answer$ <> "no" then print #tile1.textbox51, "OFF"
          if answer$ <> "no" then auto=0
          if answer$ <> "no" then gosub [manual]
          wait
          '[button7Click]
          'prompt "Enter Start Hours";TH
          'print #tile1.textbox38,"";TH;
          'if TH <10 then print #tile1.textbox38,"0";TH
          'Prompt "Enter Start Minutes";TM
          'print #tile1.textbox39,"";TM;
          'if TM <10 then print #tile1.textbox39, "0";TM
          'if TM >9 then print #tile1.textbox39, "";TM
          'Prompt "Enter Start Seconds";TS
          'print #tile1.textbox40,"";TS;
          'if TS <10 then print #tile1.textbox40, "0";TS
          'if TS >9 then print #tile1.textbox40, "";TS
          'wait

          [quit]
          beep
          'ask if the user wants to quit
          confirm "Shutdown Evertz Control?"; answer$
          if answer$ <> "yes" then wait 'abort quitting
          close #com1port
          close #tile1
          end












































          --- In libertybasic@yahoogroups.com, "pendl2megabit"
          <pendl2megabit@...> wrote:
          >
          > >
          > > Hello all,
          > >
          > > I am trying to write a program to control a video switcher. Making
          > > the switcher and LB talk VIA RS232 is no problem, I have the whole
          > > HEX/Decmial thing down pat. I have four buttons on my form that I
          can
          > > use to manually switch things. I then tried to get fancy and
          created
          > > a "button FIVE" to start an "automation" so my video switcher
          changes
          > > between diffrent sources on its own. This is where I am "skunked",
          > > creating a sub for a repeating loop. My program has a clock, so I
          am
          > > trying to use time checks to trigger my video switcher. I know I
          keep
          > > creating an endless loop, and I am not sure how to get this going.
          > >
          >
          > How about using the TIMER command ???
          >
          > [start.auto]
          > timer 30000, [auto]
          > wait
          >
          > [stop.auto]
          > timer 0
          > wait
          >
          > The two branches above are the event handlers for your buttons 5
          and 6.
          >
          > The timer will execute the [auto] branch every 30 seconds in this
          case.
          > If you have variable length videos, you can use a variable instead
          of the
          > fixed value:
          >
          > delay = video.length
          >
          > ...
          >
          > timer delay, [auto]
          >
          > ---
          > Stefan Pendl
          >
          >
          >
          > ___________________________________________________________
          > Telefonate ohne weitere Kosten vom PC zum PC:
          http://messenger.yahoo.de
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.