Example #1
0
        static void Reload()
        {
            ProductDataBase.Load("Products.xml");
            if (System.IO.File.Exists("project.xml"))
            {
                XElement project = XElement.Load("project.xml");
                SynergySequence.SequenceManager sequencemanager = new ComputerSequenceManager();

                DesktopCodeBlocks.DesktopCodeBlock.AddAllPrototypes(sequencemanager);

                sequencemanager.AddDataType(new SequenceManager.DataType("int", System.Drawing.Color.Blue));
                sequencemanager.AddDataType(new SequenceManager.DataType("bool", System.Drawing.Color.Green));

                DesktopClient.sequence = new DesktopSequence();
                DesktopClient.sequence.Manager = sequencemanager;
                DesktopClient.sequence.Load(project.Element("Sequence"));
                DesktopClient.MainStation = null;
                if (project.Element("MainStation") != null)
                {
                    DesktopClient.MainStation = new MainStation.MainStation();
                    DesktopClient.MainStation.Load(project.Element("MainStation"));
                    MainStation.MainStation.Connect();
                    byte[] data = MainStation.MainStationCompiler.Compile(DesktopClient.MainStation);

                    if (MainStation.MainStation.EEPROMWriteVerify(data))
                        tray.ShowBalloonTip(1000, "", "MainStation updated", ToolTipIcon.None);
                    else
                        tray.ShowBalloonTip(1000, "", "Failed to update mainstation", ToolTipIcon.None);
                }

                foreach (WebInterface.WebInterface i in WebInterface.WebInterface.WebInterfaces)
                {
                    i.Stop();
                }

                WebInterface.WebInterface.WebInterfaces.Clear();
                foreach (XElement element in project.Elements("WebInterface"))
                {
                    WebInterface.WebInterface wi = new WebInterface.WebInterface(element);
                    wi.Start();
                    WebInterface.WebInterface.WebInterfaces.Add(wi);
                }
            }
        }