コード例 #1
0
        public IActionResult SerialGateway()
        {
            ViewBag.ports = SerialConnectionPort.GetAvailablePorts();

            return(View(new SerialGatewayViewModel
            {
                PortName = SystemController.gatewayConfig.SerialGateway.SerialPortName,
                Boudrate = SystemController.gatewayConfig.SerialGateway.Boudrate
            }));
        }
コード例 #2
0
        public IActionResult Gateway(string id)
        {
            //prevent start wizard if already passed
            if (!bool.Parse(configuration["FirstRun"]))
            {
                return(View("Error", ALREADY_PASSED_MESSAGE));
            }

            //redirect to first step if user came this url directly
            if (SystemController.dataBaseConfig == null)
            {
                return(RedirectToAction("Index"));
            }

            if (id == "None")
            {
                dynamic json = ReadConfig();
                json.Gateway.SerialGateway.Enable   = false;
                json.Gateway.EthernetGateway.Enable = false;
                WriteConfig(json);
                configuration.Reload();

                SystemController.DisconnectGateway();
                SystemController.ReadConfig();
                SystemController.ConnectToGateway();

                return(RedirectToAction("UserProfile"));
            }
            if (id == "Serial")
            {
                ViewBag.ports = SerialConnectionPort.GetAvailablePorts();

                return(View("GatewaySerial", new SerialGatewayViewModel
                {
                    PortName = configuration["Gateway:SerialGateway:SerialPortName"],
                    Boudrate = Int32.Parse(configuration["Gateway:SerialGateway:Boudrate"])
                }));
            }
            if (id == "Ethernet")
            {
                return(View("GatewayEthernet", new EthernetGatewayViewModel
                {
                    Ip = configuration["Gateway:EthernetGateway:GatewayIP"],
                    Port = Int32.Parse(configuration["Gateway:EthernetGateway:GatewayPort"])
                }));
            }

            return(View());
        }