Ejemplo n.º 1
0
 /// <summary>
 /// Erstellt einen neuen Controller, die Basisklasse für alle Komponenten der LaserControl Software.
 /// </summary>
 /// <param name="name">Name des Controllers</param>
 /// <param name="controlIdent">ControlIdent des Controller, sollte eindeutig im gesammten Programmsystem sein.</param>
 public Controller(string name, string controlIdent)
 {
     this.ControlIdent = controlIdent.ToUpper();
     this.Name = name;
     EventThread1 = new TrackedThread(ControlIdent+" - EventThread 1", EventThread1Method);
     EventThread1.Start();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Erstellt einen neuen IOController und initialisiert diesen.
 /// </summary>
 /// <param name="name">Name des Controllers</param>
 /// <param name="controlident">Eindeutiges zeichen des Controllers</param>
 public IOController(string name, string controlident)
     : base(name, controlident)
 {
     AllIOPorts = new List<IOPort>();
     Load();
     EventThread2 = new TrackedThread(ControlIdent + " - EventThread 2 (IO)", EventThread2Method);
     EventThread2.Start();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Erstellt eine neue Achse
 /// </summary>
 /// <param name="name"></param>
 /// <param name="controlident"></param>
 public Axis(string name, string controlident)
     : base(name, controlident)
 {
     this.Load();
     IsMoving = false;
     EventThread2 = new TrackedThread(ControlIdent + " - EventThread 2 (Axis)", EventThread2Method);
     EventThread2.Start();
 }
Ejemplo n.º 4
0
        public AerotechCamera(string path)
            : base(path)
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            binding.MaxReceivedMessageSize = 2147483647;
            binding.MaxBufferSize = 2147483647;
            binding.MaxBufferPoolSize = 2147483647;
            EndpointAddress epa = new EndpointAddress(path);
            Client = new CameraServiceClient(binding, epa);

            UpdateThread = new TrackedThread("Camera " + Name + " Event Thread", UpdateThreadMethod);
            UpdateThread.Start();
        }
Ejemplo n.º 5
0
        static ScriptHandler()
        {
            EventThread = new TrackedThread("Script Handler State Event Thread", StateChangeEventThread);
            EventThread.Start();

            Node.OnPaused += OnPaused;

            Thread_1 = new TrackedThread("Script Thread 1", Thread_1_Handle, true);
            //Thread_1.ApartmentState = ApartmentState.STA;
            Thread_1.Start();

            Thread_2 = new TrackedThread("Script Thread 2", Thread_2_Handle, true);
            Thread_2.Start();
        }
Ejemplo n.º 6
0
        public static void RunTest(MainWindow mw, HardwareController hwc)
        {
            #if TEST
            MW = mw;
            HWC = hwc;
            while (true)
            {
                TestWindow tw = new TestWindow();
                if (tw.ShowDialog() != true)
                    continue;

                int testNr = tw.SelectedTest.SelectedIndex;
                switch (testNr)
                {

                    case 0:
                        TrackedThread testThread = new TrackedThread("Test ImgButton", Test1);
                        testThread.Start();
                        return;
                    case 1:
                        TrackedThread testThread2 = new TrackedThread("Test Enable Move Move Home Disable", Test2);
                        testThread2.Start();
                        return;
                    case 2:
                        TrackedThread testThread3 = new TrackedThread("Test TabControl Main Window", Test3);
                        testThread3.Thread.SetApartmentState(ApartmentState.STA);
                        testThread3.Start();
                        return;
                    case 3:
                        TrackedThread testThread4 = new TrackedThread("Test Script with FAK", Test4);
                        testThread4.Thread.SetApartmentState(ApartmentState.STA);
                        testThread4.Start();
                        return;
                    case 4:
                        TrackedThread testThread5 = new TrackedThread("Test Script with FAK", Test5);
                        testThread5.Thread.SetApartmentState(ApartmentState.STA);
                        testThread5.Start();
                        return;
                    default:
                        MessageBox.Show("Unknown Test ");
                        break;
                }
            }
            #endif
        }
        public CameraClickAndMove(HardwareController hwc)
        {
            InitializeComponent();
            this.Progress.Maximum = TimeStepsMS;

            LoadValues();

            Data = FindResource("datahandler") as CameraClickAndMoveDataHandler;

            HWC = hwc;

            //NewImage();
            ImgThread = new TrackedThread("CameraClickAndMove Window New Image Thread", NewImageContinousShot);
            ImgThread.Start();

            PreviousWindowState = System.Windows.WindowState.Normal;

            Console.WriteLine(this.GetType().AssemblyQualifiedName);
        }
Ejemplo n.º 8
0
 public void Load()
 {
     TrackedThread tt = new TrackedThread("LoadingWindow Loading Thread", LoadingThread);
     tt.Start();
     this.ShowDialog();
 }
Ejemplo n.º 9
0
        public void SetAxisAndInitGUI(HardwareController hwc, Axis axis)
        {
            HWC = hwc;
            MyAxis = axis;
            Data.AxisName = MyAxis.ControlIdent;

            EnableChange(axis, axis.IsEnable);
            HasFaultChange(axis, axis.HasFault);

            this.Data.AbsPosStr = Axis.SConvertIntToStr(MyAxis.Position, true);
            this.Data.RelPosStr = Axis.SConvertIntToStr(HWC.ConvertCoordinatesAlways(MyAxis.ControlIdent, -MyAxis.Position) * (-1), true);

            //Verbinde Notifyer
            MyAxis.IsEnableChanged += EnableChange;
            MyAxis.HasFaultChange += HasFaultChange;
            MyAxis.PositionChange += PositionChange;
            MyAxis.VelocityChange += VelocityChange;

            //Load Values
            DataSafe ds = new DataSafe(Paths.SettingsPath, "MainWindow");
            Speed = ds.Ints[axis.ControlIdent + "-FR-Speed", 0];
            Distance = ds.Ints[axis.ControlIdent + "-FR-Distance", 0];
            UseDistance = ds.Bools[axis.ControlIdent + "-FR-UseDis", false];
            DisplayFreeRunValues();

            FreeRunThread = new TrackedThread("Free Run Distance Thread: "+ MyAxis, this.FreeRunThreadMethod);
            FreeRunQueue = new Queue<Action>();
            FreeRunThread.Start();
        }
Ejemplo n.º 10
0
        protected void NewImage()
        {
            TrackedThread tt = new TrackedThread("New Image from Camera Thread", () =>
            {
                Camera c = HWC.Camera;
                if (c.IsConnected)
                {
                    Data.ImageVisible = System.Windows.Visibility.Collapsed;
                    Data.ProgbarVisible = System.Windows.Visibility.Visible;
                    TrackedThread localthread = new TrackedThread("New Image from Camera Thread (local)", () =>
                    {
                        //c.SetOverlay(false, true, true);
                        //c.SetProcessing(true);
                        Thread.Sleep(TimeStepsMS);

                        System.Drawing.Bitmap b = c.GetImage();

                        ContentImage.Dispatcher.Invoke(new Action(() =>
                        {
                            Data.Img = BitmapToImageSource(b);
                        }));

                        b.Dispose();

                        Data.ImageVisible = System.Windows.Visibility.Visible;
                        Data.ProgbarVisible = System.Windows.Visibility.Collapsed;

                    });
                    localthread.Start();

                    for (int i = 0; i < TimeStepsMS; ++i)
                    {
                        Data.ProgbarValue = i;
                        Thread.Sleep(1);
                    }
                }
            });
            tt.Start();
        }
Ejemplo n.º 11
0
 public static void Display(HardwareController hwc)
 {
     ScriptID = 0;
     if (HWC == null && hwc == null)
     {
         MessageBox.Show("Error while displaying Camera Window!");
         return;
     }
     if (SingletonWindow == null)
     {
         if (System.Threading.Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
         {
             TrackedThread tt = new TrackedThread("Inner Thread,CameraClickAndMove.Display ", () =>
             {
                 SingletonWindow = new CameraClickAndMove(hwc);
                 SingletonWindow.ShowDialog();
             });
             tt.ApartmentState = ApartmentState.STA;
             tt.Start(true);
             return;
         }
         SingletonWindow = new CameraClickAndMove(hwc);
         SingletonWindow.Show();
     }
     else
     {
         if (SingletonWindow.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
         {
             SingletonWindow.Dispatcher.Invoke(new Action(() =>
             {
                 CameraClickAndMove.Display(HWC);
             }));
             return;
         }
         SingletonWindow.WindowState = SingletonWindow.PreviousWindowState;
         SingletonWindow.ShowInTaskbar = true;
     }
     SingletonWindow.Data.ButtonsVisible = Visibility.Collapsed;
 }
Ejemplo n.º 12
0
 public static void StopThread2()
 {
     if (State_2 != ScriptThreadState.Waiting)
     {
         try
         {
             Thread_2.Thread.Abort();
             if (Thread_2_Obj != null)
             {
                 lock (Thread_2_Obj)
                 {
                     Thread_2_Obj = null;
                 }
             }
             GC.Collect();
             GC.WaitForPendingFinalizers();
             Thread_2 = new TrackedThread("Script Thread 2", Thread_2_Handle, true);
             Thread_2.Start();
             Node.SetPaused(2, false);
         }
         catch
         {
     #warning Implement error handling
         }
     }
 }
Ejemplo n.º 13
0
        public static void StopThread1()
        {
            if (State_1 != ScriptThreadState.Waiting)
            {
                try
                {
                    Thread_1.Thread.Abort();

                    if (Thread_1_LocalNode != null)
                    {
                        Thread_1_LocalNode.Clean();
                    }

                    if(Thread_1_Obj != null)
                    {
                        lock (Thread_1_Obj)
                        {
                            Thread_1_Obj.Clear();
                            Thread_1_Obj = null;
                        }
                    }
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    Thread_1 = new TrackedThread("Script Thread 1", Thread_1_Handle, true);
                    Thread_1.Start();

                    //Reset pausing state
                    Node.SetPaused(1,false);

                    //Reset Line if there was a Event method connected
                    if (Thread_1_LineChangeEvent != null)
                    {
                        Thread_1_LineChangeEvent(-1);
                    }
                }
                catch
                {
            #warning Implement error handling
                }
            }
        }
Ejemplo n.º 14
0
 //CALLC("LaserControl.ScriptV2.ScriptHandler", "StopThread", 1);
 public static void StopThread(int i)
 {
     if (i == 1)
     {
         TrackedThread tt = new TrackedThread("Kill Script Thread 1", () =>
         {
             StopThread1();
         });
         tt.Start();
     }
     if (i == 2)
     {
         TrackedThread tt = new TrackedThread("Kill Script Thread 2", () =>
         {
             StopThread2();
         });
         tt.Start();
     }
 }