Ejemplo n.º 1
0
 /// <summary>
 /// Method that is used to move the blinds up/down
 /// </summary>
 /// <param name="knxObject"></param>
 /// <returns></returns>
 public async Task Move(KnxObject knxObject)
 {
     try
     {
         var response = await(Config.ServiceBase + "move").PostJsonAsync(new { data = knxObject });
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Calls service to move the blinds up
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <param name="knxObj"></param>
 private void MoveBlindsUp(object sender, EventArgs e, KnxObject knxObj)
 {
     try
     {
         knxObj.Value = "1";
         _            = DependencyService.Get <IConnector>().Move(knxObj);
         _            = DependencyService.Get <IConnector>().UpdateKnxObject(knxObj);
     }
     catch
     {
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Method for updating KNX object data
 /// </summary>
 /// <param name="knxObject"></param>
 /// <returns></returns>
 public async Task <bool> UpdateKnxObject(KnxObject knxObject)
 {
     try
     {
         var response = await(Config.ServiceBase + "update-knx-object").PostJsonAsync(new { data = knxObject });
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a new KNX object to the database
 /// </summary>
 /// <param name="knxObject"></param>
 /// <returns></returns>
 public async Task <bool> AddKnxObject(KnxObject knxObject)
 {
     try
     {
         knxObject._id = Guid.NewGuid();
         var response = await(Config.ServiceBase + "add-knx-object").PostJsonAsync(new { data = knxObject });
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Switches the light on/off
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <param name="knxObj"></param>
 private void ToggleChange(object sender, ToggledEventArgs e, KnxObject knxObj)
 {
     try
     {
         Switch toggle = sender as Switch;
         knxObj.Value = toggle.IsToggled ? "1" : "0";
         _            = DependencyService.Get <IConnector>().Switch(knxObj);
         _            = DependencyService.Get <IConnector>().UpdateKnxObject(knxObj);
     }
     catch
     {
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Changes the value of the dimmable KNX object when the slider is released
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <param name="knxObj"></param>
 private void Slider_ValueChanged(object sender, EventArgs e, KnxObject knxObj)
 {
     try
     {
         Slider slid = sender as Slider;
         knxObj.Value = ((int)slid.Value).ToString();
         _            = DependencyService.Get <IConnector>().Dim(knxObj);
         _            = DependencyService.Get <IConnector>().UpdateKnxObject(knxObj);
     }
     catch
     {
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Calls service to rorate the blinds up
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <param name="knxObj"></param>
 private void RotateDown(object sender, EventArgs e, KnxObject knxObj)
 {
     try
     {
         if (int.Parse(knxObj.Value) > 0)
         {
             knxObj.Value = (int.Parse(knxObj.Value) - 1).ToString();
             _            = DependencyService.Get <IConnector>().Rotate(knxObj);
             _            = DependencyService.Get <IConnector>().UpdateKnxObject(knxObj);
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructor for managing knx objects - gets object if update, else null and list of rooms/types to be selected
        /// </summary>
        /// <param name="knxObject"></param>
        /// <param name="rooms"></param>
        /// <param name="types"></param>
        public NewKnxObjectPage(KnxObject knxObject, List <Room> rooms, List <Type> types)
        {
            InitializeComponent();

            KnxObject = knxObject ?? new KnxObject();
            IsUpdate  = knxObject != null ? true : false;

            Title = IsUpdate ? "Uredi KNX objekt" : "Novi KNX objekt";

            Rooms = rooms;
            Types = types;

            var dataPointTypes = new DPT();

            DataPointTypes = dataPointTypes.DPTs;

            if (IsUpdate)
            {
                knxObject.Type = Types.FirstOrDefault(x => x._id == knxObject.Type._id);
                knxObject.Room = Rooms.FirstOrDefault(x => x._id == knxObject.Room._id);
            }

            BindingContext = this;
        }