示例#1
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();
        }
    private void Awake()
    {
        instance = this;


        DontDestroyOnLoad(this.gameObject);
    }
        protected void LoadValues()
        {
            DataSafe ds = new DataSafe(Paths.SettingsPath, "MainWindow");

            CamMoveXmm = ds.Doubles["CamMoveXmm", 0];
            CamMoveYmm = ds.Doubles["CamMoveYmm", 0];

            ds.Doubles["CamMoveXmm"] = CamMoveXmm;
            ds.Doubles["CamMoveYmm"] = CamMoveYmm;
        }
示例#4
0
        private void MIHardwareChangeBtn_Click(object sender, RoutedEventArgs e)
        {
            DataSafe         ds  = new DataSafe(Paths.SettingsPath, "MainWindow");
            HardwareSelector hws = new HardwareSelector(ds);

            if (hws.ShowDialog() == true)
            {
                MessageBox.Show("LaserControl will exit now. \nPlease open it again to apply the hardware change!", "Hardware changed exit", MessageBoxButton.OK, MessageBoxImage.Information);
                Environment.Exit(0);
            }
        }
示例#5
0
        public void Save()
        {
            DataSafe ds = new DataSafe(Data.Paths.SettingsScriptFunctionsPath, this.FunctionName);

            ds.Ints["ReturnType"] = Function.TypeToIndex(this.ReturnType);
            ds.Strings["Code"]    = this.Code;
            ds.Ints["Parameter"]  = ParameterCount;
            for (int i = 0; i < ParameterCount; ++i)
            {
                ds.Strings["ParamName-" + i] = ParameterNames[i];
                ds.Ints["ParamType-" + i]    = Function.TypeToIndex(ParameterTypes[i]);
            }
        }
示例#6
0
        public void StartupInit()
        {
            DataSafe ds = new DataSafe(Paths.SettingsPath, "MainWindow");

            if (!ds.containsKey("SelectedHardware") || ds.Ints["SelectedHardware"] < 0)
            {
                HardwareSelector hws = new HardwareSelector(ds);
                if (hws.ShowDialog() != true)
                {
                    Environment.Exit(0);
                }
            }
            LoadingWindow lw = new LoadingWindow(ds);

            lw.Load();

            this.WindowState = ds.Bools["Maximized", false] ? System.Windows.WindowState.Maximized : System.Windows.WindowState.Normal;
            this.HWC         = lw.HWC;
            CameraClickAndMove.SetHWC(this.HWC);

            //Init 1 CloseableTabItem
            Data.TabItems_Add(new CloseableTabItem("new"));

            // Init UI Elemente
            AxesControl.SetHardwareControllerAndInitGUI(HWC);
            IOControl.SetHardwareControllerAndInitGUI(HWC);

            //Verbinde EventHandler
            ScriptHandler.OnState1Changed += this.OnScriptHandlerStateChange_1;
            ScriptHandler.OnState2Changed += this.OnScriptHandlerStateChange_2;

            //Data.CodeTextFieldItems = new List<string>();
            //Load last X Commands
            List <string> s = new List <string>();
            int           x = ds.Ints["CodeTextFieldItemsCount", 0];

            for (int i = 0; i < x; ++i)
            {
                s.Add(ds.Strings["CTFI-" + i, ""]);
            }
            Data.CodeTextFieldItems = s;

#if TEST
            Tests.TestClass.RunTest(this, HWC);
#endif
        }
示例#7
0
        public static void Save()
        {
            DataSafe ds = new Data.DataSafe(Data.Paths.SettingsPath, "Functions");

            ds.Ints["Categories"] = AllCategories.Count - 1;
            for (int i = 1; i < AllCategories.Count; ++i)
            {
                FunctionCategory category = AllCategories[i];
                ds.Strings["Category-" + (i - 1)] = category.Title.ToUpper();
                DataSafe catSafe = new DataSafe(Data.Paths.SettingsScriptFunctionsPath, "Category-" + category.Title);
                catSafe.Ints["Functions"] = category.Functions.Count;
                for (int f = 0; f < category.Functions.Count; ++f)
                {
                    catSafe.Strings["Function-" + f] = category.Functions[f].ToUpper();
                    GetFunction(category.Functions[f]).Save();
                }
            }
        }
示例#8
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            DataSafe ds = new DataSafe(Paths.SettingsPath, "MainWindow.xml");

            ds.Bools["Maximized"] = this.WindowState == System.Windows.WindowState.Maximized;


            List <string> s = Data.CodeTextFieldItems;

            if (s == null)
            {
                s = new List <string>();
            }
            ds.Ints["CodeTextFieldItemsCount"] = s.Count;
            for (int i = 0; i < s.Count; ++i)
            {
                ds.Strings["CTFI-" + i] = s[i];
            }
        }
示例#9
0
        public static Function Load(string name)
        {
            name = name.ToUpper();
            DataSafe ds = new DataSafe(Data.Paths.SettingsScriptFunctionsPath, name);

            //Function f = new Function(name, ds.Strings["Code", ""]);
            Type t  = typeof(bool);
            int  rt = ds.Ints["ReturnType", 0];

            t = Function.IndexToType(rt);
            Function f      = new Function(name, ds.Strings["Code", ""], t);
            int      pCount = ds.Ints["Parameter", 0];

            for (int i = 0; i < pCount; ++i)
            {
                string pname = ds.Strings["ParamName-" + i, ""];
                f.AddParameter(pname, Function.IndexToType(ds.Ints["ParamType-" + i, 0]));
            }

            return(f);
        }
示例#10
0
        private void SetSpeedBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FreeRunSpeed frs = new FreeRunSpeed(Axis.SConvertIntToStr(Speed), Axis.SConvertIntToStr(Distance), UseDistance);
                if (frs.ShowDialog() == true)
                {
                    Speed       = Axis.SConvertDoubleString(frs.SpeedStr);
                    Distance    = Axis.SConvertDoubleString(frs.DistStr);
                    UseDistance = frs.UseDistVal;
                    //Save Values
                    DataSafe ds = new DataSafe(Paths.SettingsPath, "MainWindow");
                    ds.Ints[MyAxis.ControlIdent + "-FR-Speed"]    = Speed;
                    ds.Ints[MyAxis.ControlIdent + "-FR-Distance"] = Distance;
                    ds.Bools[MyAxis.ControlIdent + "-FR-UseDis"]  = UseDistance;

                    DisplayFreeRunValues();
                }
            }
            catch
            {
            }
        }
示例#11
0
        public static void Load()
        {
            if (!Loaded)
            {
                AllCategories.Clear();
                AllFunctions.Clear();

                FunctionCategory AllCat = new FunctionCategory("All Functions");
                //AllCategories.Add(AllCat);

                //1) Lade alle Kategorien!
                DataSafe ds       = new Data.DataSafe(Data.Paths.SettingsPath, "Functions");
                int      catCount = ds.Ints["Categories", 0];
                for (int i = 0; i < catCount; ++i)
                {
                    string name = ds.Strings["Category-" + i, ""];

                    /*if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
                     * {
                     *  throw new Exception("Error in Function Categories -> Functions.xml");
                     * }*/

                    FunctionCategory category = new FunctionCategory(name);


                    DataSafe catSafe  = new DataSafe(Data.Paths.SettingsScriptFunctionsPath, "Category-" + name);
                    int      funCount = catSafe.Ints["Functions", 0];
                    for (int f = 0; f < funCount; ++f)
                    {
                        string funName = catSafe.Strings["Function-" + f, ""];
                        AllCat.Functions.Add(funName);
                        category.Functions.Add(funName);

                        //Lade eine Funktion
                        AllFunctions.Add(Function.Load(funName));
                    }

                    category.Sort();
                    AllCategories.Add(category);
                }

                //AllFunctions.Sort();
                AllCat.Sort();

                AllCategories.Sort();
                AllCategories.Insert(0, AllCat);



                /*
                 * string code = "$RETURN = 1;if( $i > 1 ){ $RETURN = FAK($i - 1) * $i; }";
                 * Function fak = new Function("FAK", code, typeof(int));
                 * fak.AddParameterInt("I");
                 * AllFunctions.Add(fak);
                 */
                Loaded = true;
            }
            else
            {
                Console.WriteLine("All Functions have been loaded before!");
            }
        }
示例#12
0
 public LoadingWindow(DataSafe ds)
 {
     InitializeComponent();
     MWDS = ds;
 }