SmartRun

From scripting
Jump to: navigation, search
       static int SmartRun(int Motor_Num, int Num_Steps, int Interval_in_ms, 
       int Forward0_Backward1, int outputBinary)
           {
 	      //Nick Pisca 0001d 2015
               // outputBinary:
           // integer in the range 0 to 7 corresponding to the bit pattern for on/off of the 
           // additional switching outputs associated with motor 1. e.g. a value of 5 (which 
           // is 00000101 in binary) would result in outputs 1 and 3 being on.
           try
           {
               bool RM = false;
               if (Motor_Num == 1)
               {
                   RM = RunMotor1(Num_Steps, Interval_in_ms, Forward0_Backward1, outputBinary);
               }
               else
               {
                   RM = RunMotor2(Num_Steps, Interval_in_ms, Forward0_Backward1, outputBinary);
               }
               Console.Write("Proc: Motor" + Motor_Num + ", steps:" + Num_Steps + ", int:" + 
                Interval_in_ms + ". (time:" + SmartTime(Num_Steps * Interval_in_ms) + ")\n");
               Thread.Sleep(Num_Steps * Interval_in_ms);
           }
           catch 
           {
               if (Motor_Num == 1)
               {
                   StopMotor1(outputBinary);
               }
               else
               {
                   StopMotor2(outputBinary);
               }
           }
           return 0;
       }



Unrelated MEL scripting help located here: YSYT.