public ActionResult LampBedienen()
        {
            DomoticzAPI API    = new DomoticzAPI();
            int         device = API.GetRoomDevices(LoginController.Kamer_ID + 1, "lamp");

            API.ToggleSwitch(device);

            return(RedirectToAction("DashboardPatient", "Patient"));
        }
        public ActionResult TemperatuurBedienen()
        {
            DomoticzAPI API    = new DomoticzAPI();
            int         device = API.GetRoomDevices(LoginController.Kamer_ID + 1, "temperatuur");

            API.KiesTemperatuur(device);


            return(RedirectToAction("DashboardPatient", "Patient"));
        }
        public ActionResult MediaPlayerBedienen()
        {
            /*
             * SqlConnection conn = new SqlConnection();
             * SqlCommand cmd = new SqlCommand();
             */
            DomoticzAPI API    = new DomoticzAPI();
            int         device = API.GetRoomDevices(LoginController.Kamer_ID + 1, "media player");

            API.ToggleSwitch(device);

            return(RedirectToAction("DashboardPatient", "Patient"));
        }
Exemplo n.º 4
0
        private void startButton_Click(object sender, EventArgs e)
        {
            Program.form.SetGameInProgress(true);
            difficultyBoxLabel.Text = difficultyBox.SelectedItem.ToString();
            int scene = 1;

            if (timeBox.SelectedIndex == 0)
            {
                minutes = 5;
            }
            else if (timeBox.SelectedIndex == 1)
            {
                minutes = 10;
            }
            else if (timeBox.SelectedIndex == 2)
            {
                minutes = 15;
            }
            if (difficultyBox.SelectedIndex == 0)
            {
                currentHidingLocation = "Bedroom1";
                scene     = 1;
                maxClicks = 4;
                score     = 100;
            }
            else if (difficultyBox.SelectedIndex == 1)
            {
                currentHidingLocation = "Bathroom";
                scene     = 2;
                maxClicks = 3;
                score     = 200;
            }
            else if (difficultyBox.SelectedIndex == 2)
            {
                currentHidingLocation = "Storage";
                scene     = 3;
                maxClicks = 2;
                score     = 300;
            }
            clicksLabel.Text   = (maxClicks - clicks).ToString();
            gamePanel.Visible  = true;
            setupPanel.Visible = false;
            start = DateTime.Now;
            gameTimer.Start();
            api          = new DomoticzAPI(start);
            getLogThread = new Thread(api.GetLogs);
            getLogThread.Start();
            api.ToggleScene(scene);
        }
Exemplo n.º 5
0
            static void GetFloors()
            {
                (List <Floorplan>, string)floorResults = DomoticzAPI.GetFloors();

                if (floorResults.Item1 != null)
                {
                    Console.WriteLine("IDx : Naam");
                    foreach (Floorplan dev in floorResults.Item1)
                    {
                        Console.WriteLine("{0} : {1}", dev.Idx, dev.Name);
                    }
                    Console.WriteLine();
                }
                else
                {
                    CustomLogWrites.LogWriter("Geen floors gevonden!");
                }
            }
Exemplo n.º 6
0
            static void GetRoomsByFloor()
            {
                Console.WriteLine("Geef naam van floor");
                (List <Floorplan>, string)roomResults = DomoticzAPI.GetRoomsbyFloor(Console.ReadLine());

                if (roomResults.Item1 != null)
                {
                    Console.WriteLine("IDx : Naam");
                    foreach (Floorplan room in roomResults.Item1)
                    {
                        Console.WriteLine("{0} : {1}", room.Idx, room.Name);
                    }
                    Console.WriteLine();
                }
                else
                {
                    CustomLogWrites.LogWriter("Geen rooms gevonden!");
                }
            }
Exemplo n.º 7
0
            /*
             * CUSTOM FUNCTIONS
             * These functions are for running the server
             */

            // DOMOTICZ FUNCTIONS
            static void GetDevicesByRoom()
            {
                Console.WriteLine("Geef IDx van kamer");
                (List <Device>, string)deviceResults = DomoticzAPI.GetDevicesByRoom(Console.ReadLine());

                if (deviceResults.Item1 != null)
                {
                    Console.WriteLine("IDx : Naam");
                    foreach (Device dev in deviceResults.Item1)
                    {
                        Console.WriteLine("{0} : {1}", dev.Devidx, dev.Name);
                    }
                }
                else
                {
                    CustomLogWrites.LogWriter("Geen devices gevonden!");
                }

                Console.WriteLine();
            }
Exemplo n.º 8
0
        private async Task GetEntries(Sensor sensor)
        {
            chartEntries = new List <ChartValue>();
            chartEntries = await DomoticzAPI.GetTempHumMonth(sensor.Id);

            //var valuesDTOList = JsonConvert.DeserializeObject<TempHumMonthValuesDTO>(json);
            //valuesList = Mapper.Map<List<ChartValue>>(valuesDTOList.Items);

            List <Entry> entries = new List <Entry>();

            foreach (ChartValue entrie in chartEntries)
            {
                var chartEntrie = new Entry(entrie.Value)
                {
                    Color = SKColor.Parse("#3366ff"),
                    //Label = (entrie.Label).Substring(8, 2),
                    Label      = entrie.Label,
                    ValueLabel = entrie.ValueLabel
                };

                entries.Add(chartEntrie);
            }



            LastRidesChart = new LineChart()
            {
                Entries = entries,
                //ValueLabelOrientation = Orientation.Vertical
                MinValue  = entries.Min(e => e.Value),
                Margin    = 20,
                PointMode = PointMode.Circle,
                PointSize = 20,
                //LabelOrientation = Orientation.Horizontal
            };
        }
Exemplo n.º 9
0
 private async Task GetSensors()
 {
     ListDataSensors = await DomoticzAPI.GetAllDevices();
 }
Exemplo n.º 10
0
 static void SensorSwitch(bool switchState)
 {
     Console.WriteLine("Geef IDx van device");
     CustomLogWrites.LogWriter(DomoticzAPI.TriggerMotionDetector(Console.ReadLine(), switchState));
 }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Assembly        assembly        = Assembly.GetExecutingAssembly();
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            Console.WriteLine("Verstoppertje server");
            Console.WriteLine("Version: " + fileVersionInfo.FileVersion);


            /*
             * STARTUP
             */

            // SETTINGS FILE
            Dictionary <String, String> settings = DataAccessLayer.getSettings();


            // SOCKETSERVER IP AND PORT
            string ipaddress  = settings["SERVER_IP"];
            int    portnumber = Int32.Parse(settings["SERVER_PORT"]);

            // DOMOTICZSERVER IP AND TESTCONNECTION
            DomoticzAPI domoticz = new DomoticzAPI(settings["DOMOTICZ_IP"]);

            (string responseCategory, string responseMessage) = domoticz.TestConnection();
            if (responseCategory == "success")
            {
                CustomLogWrites.LogWriter(responseMessage);
            }
            else if (responseCategory == "log")
            {
                CustomLogWrites.ErrorWriter(responseMessage);
                CustomLogWrites.DomoticzLogWriter(DomoticzAPI.GetLogInfo());
            }
            else if (responseCategory == "error")
            {
                CustomLogWrites.ErrorWriter(responseMessage);
                Console.WriteLine("Druk op enter om te stoppen...");
                Console.ReadLine();
                Environment.Exit(0);
            }

            // STARTING SOCKETSERVER
            CustomLogWrites.LogWriter("Socket server aanmaken");
            SocketServer.SocketServer.PrepareSocket(ipaddress, portnumber);
            CustomLogWrites.LogWriter("Socket server aangemaakt op ipaddress: " + ipaddress + " en poort " + portnumber.ToString());
            //SocketServer.SocketServer.StartListening();

            // Console for executing commands

            // List with all the executable functions (FUNCTIONNAME, DESCRIPTION, FUNCTION TO EXECUTE)
            List <(string, string, Action)> commands = new List <(string, string, Action)>()
            {
                ("quit", "Stopt de server", () => Environment.Exit(0)),
                ("domoticzlog", "Haalt log van Domoticz Server op", () => CustomLogWrites.DomoticzLogWriter(DomoticzAPI.GetLogInfo())),
                ("getfloors", "Geeft vloerplannen van de afdelingen van Domoticz terug", () => GetFloors()),
                ("getrooms", "Geeft vloerplannen van de kamer van Domoticz terug", () => GetRoomsByFloor()),
                ("get_devices_by_room", "Geeft devices van de kamer in Domoticz terug", () => GetDevicesByRoom()),
                ("triggerSensor", "Triggert een sensor", () => SensorSwitch(true)),
                ("sensorOn", "Zet sensor aan", () => SensorSwitch(true)),
                ("sensorOff", "Zet sensor uit", () => SensorSwitch(false)),
                ("startSocket", "Zet socket server aan", () => SocketServer.SocketServer.StartListening()),
                ("getClients", "Geeft alle verbonden clients terug", () => SocketServer.SocketServer.GetConnectedClients()),
                ("sendTestMessage", "Stuurt bericht naar client", () => SendTestMessage()),
                ("createDatabase", "Maak een nieuwe database", () => DataAccessLayer.DatabaseInitializer()),
                ("getUser", "Haal gebruiker op", () => GetAUser()),
                ("newUser", "Maak een nieuwe gebruiker aan", () => MakeNewUser()),
                ("changeUser", "Pas een bestaande gebruiker aan", () => ChangeAUser()),
                ("deleteUser", "Verwijder een bestaande gebruiker", () => DeleteAUser())
            };


            bool done = false;

            while (!done)
            {
                Console.Write("Geef een commando. Typ 'help' voor hulp.\n: ");
                string commandResponse = Console.ReadLine();

                if (commandResponse == "help")
                {
                    Console.WriteLine("COMMANDO'S\n-----------------------");
                    foreach ((string functionName, string description, Action function) in commands)
                    {
                        Console.WriteLine("{0} : {1}", functionName, description);
                    }
                    Console.WriteLine();
                }
                else
                {
                    foreach ((string functionName, string description, Action function) in commands)
                    {
                        if (commandResponse == functionName)
                        {
                            function.Invoke();
                        }
                    }
                }
            }