#region  --------------- Copyright Dresser Wayne Pignone -------------
/*
 * $Log: /Wrk/Support/ForecourtControl/Wrk/ForecourtControl/IForecourtControl.cs $
 *
 * 5     07-10-18 17:12 roger.månsson
 * Added IForecourtControl.OnFuelPriceChange event.
 *
 * 4     07-03-08 13:08 roger.månsson
 * Added PricePoles
 *
 * 3     07-01-12 15:25 roger.månsson
 * Made IDisposable
 *
 * 2     07-01-05 15:10 roger.månsson
 * Added TankGroups property
 */
#endregion
using System;
namespace Wayne.ForecourtControl
{
    /// <summary>
    /// The ForecourtControl object is the main root object to the Forecourtcontrol object hiearchy. It owns a list of pumps, and provides
    /// functionality to control the site.
    /// </summary>
    public interface IForecourtControl : Wayne.Lib.IConnectable,
                                         Wayne.Lib.IIdentifiableEntity,
                                         IDisposable
    {
        #region Properties

        /// <summary>
        /// ClientId in the communicationClientName in the communication to the Forecourt Controller.
        /// </summary>
        int ClientId { get;}

        /// <summary>
        /// ClientName in the communication to the Forecourt Controller.
        /// </summary>
        string ClientName { get;}

        /// <summary>
        /// Tells whether the site is open or closed.
        /// </summary>
        bool SiteOpened { get;}

        /// <summary>
        /// This property tells the operation mode of the site according to the pre-configured pump operation. Typically the configuration has been pre-defined with
        /// day, Night and rush hour operation modes, but this interface does not restrict which site mode that is used as day, night and rush-hour.
        /// </summary>
        int SiteMode { get;}

        /// <summary>
        /// The collection of pump objects.
        /// </summary>
        System.Collections.ObjectModel.ReadOnlyCollection<Wayne.ForecourtControl.IPump> Pumps {get;}

        /// <summary>
        /// The collection of Fuel prices.
        /// </summary>
        System.Collections.ObjectModel.ReadOnlyCollection<Wayne.ForecourtControl.IFuelPrice> FuelPrices { get;}

        /// <summary>
        /// The collection of Tank groups.
        /// </summary>
        System.Collections.ObjectModel.ReadOnlyCollection<Wayne.ForecourtControl.ITankGroup> TankGroups { get;}

        /// <summary>
        /// The collection of Price poles.
        /// </summary>
        System.Collections.ObjectModel.ReadOnlyCollection<Wayne.ForecourtControl.IPricePole> PricePoles { get;}

        #endregion

        #region Methods

        /// <summary>
        /// Opens or closes the station.
        /// </summary>
        /// <param name="opened">True if the station should be opened, and false if it should be closed.</param>
        /// <param name="requestCompleted">Delegate that will be called on completion.</param>
        /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
        void SetSiteOpenedAsync(bool opened, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);

        /// <summary>
        /// Sets the site mode. The pumps can be set in different modes for different site modes. This
        /// enables the option to have different day/night/rush modes of the station.
        /// </summary>
        /// <param name="siteMode">The new site mode.</param>
        /// <param name="requestCompleted">Delegate that will becalled on completion.</param>
        /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
        void SetSiteModeAsync(int siteMode, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted,object userToken);

        /// <summary>
        /// Reserves the fuel prices so they can be changed by this client.
        /// </summary>
        /// <param name="requestCompleted">Callback delegate that will becalled on completion</param>
        /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
        void ReserveFuelPricesAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);

        /// <summary>
        /// Releases the fuel price reservation. If the fuel prices were no reserved, the function will still return success=true.
        /// Changes made to the fuel prices will be undone.
        /// </summary>
        /// <param name="requestCompleted">Callback delegate that will becalled on completion</param>
        /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
        void UnreserveFuelPricesAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);

        /// <summary>
        /// Activates the fuel prices, and triggers a new Fuel period when the prices has been activated.
        /// Note that it can take several minutes before all price signs and pumps have been updated.
        /// The FuelPrice reservation is released, so UnreserveFuelPricesAsync must not be called afterwards.
        /// </summary>
        /// <param name="requestCompleted">Callback delegate that will becalled on completion</param>
        /// <param name="userToken">A user supplied object that will be returned in the requestCompleted callback</param>
        void ActivateFuelPricesAsync(EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);

        /// <summary>
        /// Reserves the pump cluster for the specified terminal number. The terminal device id is 1-based.
        /// </summary>
        /// <param name="terminalDeviceId"></param>
        /// <param name="requestCompleted"></param>
        /// <param name="userToken"></param>
        void ReservePumpClusterAsync(int terminalDeviceId, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);


        /// <summary>
        /// Unreserves the pump cluster for the specified terminal number. The terminal device id is 1-based.
        /// </summary>
        /// <param name="terminalDeviceId"></param>
        /// <param name="requestCompleted"></param>
        /// <param name="userToken"></param>
        void UnreservePumpClusterAsync(int terminalDeviceId, EventHandler<Wayne.Lib.AsyncCompletedEventArgs> requestCompleted, object userToken);

        #endregion

        #region Events
        /// <summary>
        /// Event Fired when the site mode, i.e. the Site mode or the Site open/close mode has changed.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "OnSite")]
        event EventHandler<SiteModeChangeEventArgs> OnSiteModeChange;

        /*
        /// <summary>
        /// Configuration changed.
        /// </summary>
        event EventHandler OnConfigurationChange;
        */

        /// <summary>
        /// Event that is raised when an alarm is fired from forecourt controller.
        /// </summary>
        event EventHandler<AlarmEventArgs> OnAlarm;

        /// <summary>
        /// Event fired when the fuel prices has been changed on the station and a new fuel price shift has been
        /// created.
        /// </summary>
        event EventHandler<FuelPriceChangeEventArgs> OnFuelPriceChange;

        #endregion
    }

}