/// <summary>
        /// Queries the currnet configuration from MooseBox and creates a synchronized instance of FanAutomation.
        /// </summary>
        /// <returns>FanAutomation instance representing current state of MooseBox.</returns>
        internal static async Task<FanAutomation> QueryCurrentFanAutomation()
        {
            IMooseBoxRESTAPI mooseBoxRESTAPI = MooseBoxRESTAPIFactory.Instance.Create();

            List<FanAutomationConfig> registeredFans = await mooseBoxRESTAPI.ListFanAutomationConfig();

            FanAutomation fanAutomation = new FanAutomation(mooseBoxRESTAPI, registeredFans);

            return fanAutomation;
        }
Exemple #2
0
        /// <summary>
        /// Queries the currnet configuration from MooseBox and creates a synchronized instance of FanAutomation.
        /// </summary>
        /// <returns>FanAutomation instance representing current state of MooseBox.</returns>
        internal static async Task <FanAutomation> QueryCurrentFanAutomation()
        {
            IMooseBoxRESTAPI mooseBoxRESTAPI = MooseBoxRESTAPIFactory.Instance.Create();

            List <FanAutomationConfig> registeredFans = await mooseBoxRESTAPI.ListFanAutomationConfig();

            FanAutomation fanAutomation = new FanAutomation(mooseBoxRESTAPI, registeredFans);

            return(fanAutomation);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="fanAutomationRef">Reference to MooseBox Fan Automation object.</param>
        public FanManualOverrideForm(FanAutomation fanAutomationRef)
        {
            //Parameter Validations.
            if (fanAutomationRef == null)
                throw new ArgumentNullException("FanAutomation fanAutomationRef");

            //WinForms UI Initialization.
            InitializeComponent();

            //Set Members.
            m_fanAutomationRef = fanAutomationRef;
        }
        /// <summary>
        /// UI Handler for load event.
        /// </summary>
        /// <param name="sender">Instance of object raising event.</param>
        /// <param name="e">Generic event args.</param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            //Configure the actual MooseBox endpoint so we can connect via REST APIs; First Release is a static IP on our home network (local).
            MooseBoxRESTAPIFactory.Instance.Register("http://10.0.1.42:8080");

            //Start the Polling Timer.
            m_statusPollTimer.Start();

            //Build the Fan Automation write-through cache.
            m_fanAutomation = AsyncHelper.RunSync(() => { return FanAutomation.QueryCurrentFanAutomation(); });
        }