Beispiel #1
0
        /// <summary> Homes the given device. </summary>
        /// <param name="device"> The device. </param>
        public static bool Home_1(IGenericAdvancedMotor device)
        {
            Console.WriteLine("Homing device");
            // create wait handler
            ManualResetEvent waitEvent = new ManualResetEvent(false);

            waitEvent.Reset();
            // clear errors
            device.ClearDeviceExceptions();
            // call home function, passing in event handler
            // could alternatively use method with in-built wait handler by passing a timeout instead of callback
            device.Home(p => waitEvent.Set());
            if (!waitEvent.WaitOne(60000))
            {
                // timed out
                return(false);
            }
            // check for exceptions thrown by background thread during process
            device.ThrowLastDeviceException();
            // check status
            bool homed = device.Status.IsHomed;

            Console.WriteLine("Device Homed");
            return(true);
        }
Beispiel #2
0
        /// <summary> Homes the given device. </summary>
        /// <param name="device"> The device. </param>
        public static bool Home_3(IGenericAdvancedMotor device)
        {
            Console.WriteLine("Homing device");

            // call home function, passing in event handler
            device.Home(60000);

            // check status
            bool homed = device.Status.IsHomed;

            Console.WriteLine("Device Homed");
            return(true);
        }
        public static void Home_Method2(IGenericAdvancedMotor device)
        {
            Console.WriteLine("Homing device");
            _taskComplete = false;
            _taskID       = device.Home(CommandCompleteFunction);
            while (!_taskComplete)
            {
                Thread.Sleep(500);
                StatusBase status = device.Status;
                Console.WriteLine("Device Homing {0}", status.Position);

                // will need some timeout functionality;
            }
            Console.WriteLine("Device Homed");
        }
 public static void Home_Method1(IGenericAdvancedMotor device)
 {
     try
     {
         Console.WriteLine("Homing device");
         device.Home(60000);
     }
     catch (Exception)
     {
         Console.WriteLine("Failed to home device");
         Console.ReadKey();
         return;
     }
     Console.WriteLine("Device Homed");
 }
Beispiel #5
0
        /// <summary> Homes the given device. </summary>
        /// <param name="device"> The device. </param>
        public static bool Home_2(IGenericAdvancedMotor device)
        {
            Console.WriteLine("Homing device");

            // call home function, passing in message complete handler provided by device
            Action <UInt64> workDone = device.InitializeWaitHandler();

            // call home function, passing in event handler
            device.Home(workDone);
            device.Wait(60000);

            // check status
            bool homed = device.Status.IsHomed;

            Console.WriteLine("Device Homed");
            return(true);
        }