예제 #1
0
        public override void handleGETRequest(HttpProcessor p)
        {
            //XmlDocument doc = new XmlDocument();
            //XmlElement bookElement = doc.CreateElement("book", "http://www.contoso.com/books"); ///< book xmlns = "http://www.contoso.com/books" />
            //doc.AppendChild(bookElement);

            /* XmlTextWriter writer = new XmlTextWriter(p.outputStream);
             * writer.Formatting = Formatting.Indented;
             * doc.WriteTo(writer);
             * writer.Flush();
             * Console.WriteLine();*/

            Console.WriteLine("****** start SMCSettings ******");
            //Console.WriteLine(connector.SMCSettings);

            //De.Boenigk.SMC5D.Basics.Log log = new Log(true);

            XmlSerializer xsSubmit = new XmlSerializer(typeof(SMCSettings));
            XmlTextWriter writer   = new XmlTextWriter(p.outputStream);

            writer.Formatting = Formatting.Indented;

            using (StringWriter sww = new StringWriter())
                using (XmlWriter w = XmlWriter.Create(sww))
                {
                    xsSubmit.Serialize(w, ConnectorUtility.GetConnectorSettings());
                    var         xml = sww.ToString(); // Your XML
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(xml);
                    doc.WriteTo(writer);
                    writer.Flush();
                    Console.WriteLine();
                }

            Console.WriteLine("connector.IsSpindleOn: " + ConnectorUtility.GetConnector().IsSpindleOn());
            //Console.WriteLine("connector.IsUSB: " + ConnectorUtility.GetConnector().IsUSB);
            Console.WriteLine("Volt 1: " + ConnectorUtility.GetConnector().AD1Volt);
            Console.WriteLine("Volt 2: " + ConnectorUtility.GetConnector().AD2Volt);
            Console.WriteLine("GlobPos SpindleSpeed: " + ConnectorUtility.GetConnector().GlobPosition.SpindleSpeed);
            Console.WriteLine("GlobPos X: " + ConnectorUtility.GetConnector().GlobPosition.X);
            Console.WriteLine("GlobPos Y: " + ConnectorUtility.GetConnector().GlobPosition.Y);
            Console.WriteLine("GlobPos Z: " + ConnectorUtility.GetConnector().GlobPosition.Z);

            Console.WriteLine("****** end SMCSettings ******");


            /*
             * Console.WriteLine("request: {0}", p.http_url);
             * p.writeSuccess();
             * p.outputStream.WriteLine("<html><body><h1>test server</h1>");
             * p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
             * p.outputStream.WriteLine("url : {0}", p.http_url);
             *
             * p.outputStream.WriteLine("<form method=post action=/form>");
             * p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
             * p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
             * p.outputStream.WriteLine("</form>");
             */
        }
예제 #2
0
        public MyHttpServer(String ip_addr, int port) : base(ip_addr, port)
        {
            if (!File.Exists("../../vendor/config.xml"))
            {
                Console.WriteLine("Fatal error: Configuration not found!");
                //TODO return 0;
            }
            else
            {
                Console.WriteLine("Found config.xml");
            }

            connector = ConnectorUtility.GetConnector();
            //TODO connector.ConnectorStatus += connector_ConnectorStatus;
        }