예제 #1
0
        private void LoadBcus()
        {
            string jsonPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "maskversion.json");
            string xmlPath  = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "maskversion.xml");

            if (System.IO.File.Exists(jsonPath))
            {
                BCUs = Newtonsoft.Json.JsonConvert.DeserializeObject <ObservableCollection <Models.MaskVersion> >(System.IO.File.ReadAllText(jsonPath));
            }
            else
            {
                BCUs = new ObservableCollection <Models.MaskVersion>();
                XDocument xdoc = XDocument.Load(xmlPath);
                foreach (XElement xmask in xdoc.Root.Elements())
                {
                    Models.MaskVersion mask = new Models.MaskVersion();
                    mask.Id = xmask.Attribute("Id").Value;

                    string eleStr = xmask.ToString();
                    if (eleStr.Contains("<Procedure ProcedureType=\"Load\""))
                    {
                        XElement prodLoad = xmask.Descendants(XName.Get("Procedure")).First(p => p.Attribute("ProcedureType")?.Value == "Load");
                        if (prodLoad.ToString().Contains("<LdCtrlMerge"))
                        {
                            mask.Procedure = Models.ProcedureTypes.Merge;
                        }
                        else
                        {
                            mask.Procedure = Models.ProcedureTypes.Default;
                        }
                    }
                    else
                    {
                        mask.Procedure = Models.ProcedureTypes.Application;
                    }


                    if (mask.Procedure != Models.ProcedureTypes.Application)
                    {
                        if (eleStr.Contains("<LdCtrlAbsSegment"))
                        {
                            mask.Memory = Models.MemoryTypes.Absolute;
                        }
                        else if (eleStr.Contains("<LdCtrlWriteRelMem"))
                        {
                            mask.Memory = Models.MemoryTypes.Relative;
                        }
                        else if (eleStr.Contains("<LdCtrlWriteMem"))
                        {
                            mask.Memory = Models.MemoryTypes.Relative;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    BCUs.Add(mask);
                }

                System.IO.File.WriteAllText(jsonPath, Newtonsoft.Json.JsonConvert.SerializeObject(BCUs));
            }
        }
예제 #2
0
        private void ClickOpen(object sender, RoutedEventArgs e)
        {
            OpenFileDialog diag = new OpenFileDialog();

            diag.Title  = "Projekt öffnen";
            diag.Filter = "Kaenx Hersteller Projekt (*.ae-manu)|*.ae-manu";
            if (diag.ShowDialog() == true)
            {
                string general = System.IO.File.ReadAllText(diag.FileName);
                General = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.ModelGeneral>(general, new Newtonsoft.Json.JsonSerializerSettings()
                {
                    TypeNameHandling = Newtonsoft.Json.TypeNameHandling.Auto
                });
                filePath = diag.FileName;

                foreach (Models.Application app in General.Applications)
                {
                    foreach (Models.AppVersion ver in app.Versions)
                    {
                        foreach (Models.Parameter para in ver.Parameters)
                        {
                            if (!string.IsNullOrEmpty(para._memory))
                            {
                                Models.Memory mem = ver.Memories.Single(m => m.Name == para._memory);
                                para.MemoryObject = mem;
                            }
                            if (!string.IsNullOrEmpty(para._parameterType))
                            {
                                Models.ParameterType pt = ver.ParameterTypes.Single(p => p.Name == para._parameterType);
                                para.ParameterTypeObject = pt;
                            }
                        }

                        foreach (Models.ParameterRef pref in ver.ParameterRefs)
                        {
                            if (!string.IsNullOrEmpty(pref._parameter))
                            {
                                Models.Parameter para = ver.Parameters.Single(p => p.Name == pref._parameter);
                                pref.ParameterObject = para;
                            }
                        }

                        foreach (Models.ComObjectRef cref in ver.ComObjectRefs)
                        {
                            if (!string.IsNullOrEmpty(cref._comObject))
                            {
                                Models.ComObject com = ver.ComObjects.Single(c => c.Name == cref._comObject);
                                cref.ComObjectObject = com;
                            }
                        }

                        LoadSubDyn(ver.Dynamics[0], ver.ParameterRefs.ToList(), ver.ComObjectRefs.ToList());
                    }


                    string mid = app._maskId;
                    if (string.IsNullOrEmpty(mid))
                    {
                        continue;
                    }

                    Models.MaskVersion mask = BCUs.Single(bcu => bcu.Id == mid);
                    app.Mask = mask;
                }


                foreach (Models.Hardware hard in General.Hardware)
                {
                    if (string.IsNullOrEmpty(hard._appsString))
                    {
                        continue;
                    }

                    foreach (string name in hard._appsString.Split(','))
                    {
                        try{
                            hard.Apps.Add(General.Applications.Single(app => app.Name == name));
                        } catch {}
                    }
                }

                SetSubCatalogItems(General.Catalog[0]);

                SetButtons(true);
            }
        }