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];
            }
        }
        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();
        }
Beispiel #3
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!");
            }
        }
Beispiel #4
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();
         }
     }
 }
        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;
        }
Beispiel #6
0
 public DoubleGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #7
0
 public BoolGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #8
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;
        }
Beispiel #9
0
 public LongGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #10
0
 public IntGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #11
0
 public DoubleGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #12
0
 public IntGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #13
0
 public StringGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #14
0
 public LongGetter(DataSafe ds)
 {
     this.ds = ds;
 }
Beispiel #15
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
            {

            }
        }
Beispiel #16
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]);
     }
 }
Beispiel #17
0
 public StringGetter(DataSafe ds)
 {
     this.ds = ds;
 }
 public LoadingWindow( DataSafe ds)
 {
     InitializeComponent();
     MWDS = ds;
 }
Beispiel #19
0
 public BoolGetter(DataSafe ds)
 {
     this.ds = ds;
 }