using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMDServer.Common;
using System.Diagnostics;

namespace EMDHardwareClientSimulation.Core.Devices
{
    class Switch : Device
    {
        #region Class variables
        // ----------------------------------------

        // ----------------------------------------
        #endregion

        #region Public methods
        // ----------------------------------------
        /// <summary>
        /// Creates a new instance of the Switch class
        /// </summary>
        public Switch()
        {
            Debug.WriteLine("SWITCH - Instantiated!");
        }

        /// <summary>
        /// Creates a new instance of the Switch class
        /// </summary>
        /// <param name="gateway">iEMDConnection interface to the Device</param>
        public Switch(iEMDConnection gateway):base(gateway)
        {
            Debug.WriteLine("SWITCH - Instantiated with params EMDINTERFACE!");
        }

        /// <summary>
        /// Creates a new instance of the Switch class
        /// </summary>
        /// <param name="id">int id of the Switch</param>
        /// <param name="gateway">iEMDConnection interface to the Switch</param>
        public Switch(int id, iEMDConnection gateway)
            : base(id, Constants.EMD_DEVICE_TYPE.SWITCH , gateway)
        {
            Debug.WriteLine("SWITCH - Instantiated with params ID=" + id + ", TYPE=" + Constants.EMD_DEVICE_TYPE.SWITCH + ", EMDINTERFACE!");
        }

        /// <summary>
        /// Toggles value of Device
        /// </summary>
        public void Toggle()
        {
            if (deviceValue > 0)
            {
                deviceValue = 0;
            }
            else
            {
                deviceValue = 255;
            }

            sendValue();

            Debug.WriteLine("SWITCH - Switch toggled: " + deviceId);
        }
        // ----------------------------------------
        #endregion

        #region Private methods
        // ----------------------------------------

        // ----------------------------------------
        #endregion

    }
}
