示例#1
0
        static void Main(string[] args)
        {
            UpTime = Stopwatch.StartNew();

            Logger.Clear();
            Logger.Log("Sharp Clock v0.7.7");

            ParseCommands(args);
            HandleUnixSignals();

            var GPIOevents = new GPIO();
            var Screen     = new PixelDraw();

            LoadingAnimation.Run(Screen);

            var Pixel = new PixelRenderer(PixelDraw.Screen);

            PixelModule.SetScreen(Screen);
            PixelModule.SetGPIO(GPIOevents);
            PixelModule.SetRenderer(Pixel);
            WebServer = new HttpServer("WebPage");
            WebServer.Start();

            Pixel.Start();

            PostHandler postHandler = new PostHandler(WebServer);
        }
示例#2
0
        public void CreateModule(PixelModule module)
        {
            XmlElement m = xml.CreateElement(string.Empty, "module", string.Empty);

            Logger.Log(ConsoleColor.Yellow, $"Module Name: {module.Name} Start: True");
            m.SetAttribute("class", module.Name);
            m.SetAttribute("start", "True");

            XmlElement p = xml.CreateElement(string.Empty, "params", string.Empty);

            foreach (var prop in module.GetType().GetProperties())
            {
                try
                {
                    Logger.Log(ConsoleColor.Yellow, $"Prop: {prop.Name} Value: {prop.GetValue(module).ToString()}");
                    if (prop.Name == "Name" || prop.Name == "IsRunning")
                    {
                        continue;
                    }
                    else if (prop.PropertyType == typeof(Color))
                    {
                        var c = (Color)prop.GetValue(module);
                        p.SetAttribute(prop.Name, $"#{c.R.ToString("X2")}{c.G.ToString("X2")}{c.B.ToString("X2")}");
                    }
                    else
                    {
                        p.SetAttribute(prop.Name, prop.GetValue(module).ToString());
                    }
                }
                catch (Exception)
                {
                    Logger.Log(ConsoleColor.Yellow, $"Prop: {prop.Name} Value: ", ConsoleColor.Red, "NULL");
                }
            }

            m.AppendChild(p);
            xml.DocumentElement["modules"].AppendChild(m);
            xml.Save(file);
        }