using EVCB_OCPP.Packet20.DataTypes.EnumTypes;
using EVCB_OCPP.Packet20.Utilites;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EVCB_OCPP.Packet20.DataTypes
{
    public class EventDataType
    {
        /// <summary>
        /// Identifies the event. This field can be referred
        ///to as a cause by other events
        /// </summary>
        [Required]
        public int EventId { set; get; }

        /// <summary>
        /// Timestamp of the moment the report was
        /// generated.
        /// </summary>
        [Required]
        [JsonConverter(typeof(UTCDateTimeConverter))]
        public DateTime Timestamp { set; get; }


        /// <summary>
        /// Type of monitor that triggered this event, e.g.
        /// exceeding a threshold value.
        /// </summary>
        [Required]
        [JsonConverter(typeof(StringEnumConverter))]
        public EventTriggerEnumType Trigger { set; get; }

        /// <summary>
        /// Refers to the Id of an event that is considered to
        /// be the cause for this event.
        /// </summary>
        public int? Cause { set; get; }

        /// <summary>
        /// Actual value (attributeType Actual) of the
        /// variable.
        ///The Configuration Variable ReportingValueSize can be
        ///used to limit GetVariableResult.attributeValue,
        ///max size of these values will always remain equal.
        /// </summary>
        [Required]
        [StringLength(2500, MinimumLength = 0)]
        public string ActualValue { set; get; }

        /// <summary>
        ///Technical (error) code as reported by
        ///  component.
        /// </summary>    
        [StringLength(50, MinimumLength = 0)]
        public string TechCode { set; get; }

        /// <summary>
        ///Technical detail information as reported by
        ///component.
        /// </summary>    
        [StringLength(500, MinimumLength = 0)]
        public string TechInfo { set; get; }

        /// <summary>
        ///Cleared is set to true to report the clearing of a
        /// monitored situation, i.e.a 'return to normal'.
        /// </summary>          
        public bool? Cleared { set; get; }

        /// <summary>
        ///If an event notification is linked to a specific
        /// transaction, this field can be used to specify its
        /// transactionId.
        /// </summary>    
        [StringLength(36, MinimumLength = 0)]
        public string TransactionId { set; get; }

        /// <summary>
        /// Identifies the VariableMonitoring which
        /// triggered the event.
        /// </summary>
        public int? VvariableMonitoringId { set; get; }

        /// <summary>
        /// Specifies the event notification type of the  message.
        /// </summary>
        [JsonConverter(typeof(StringEnumConverter))]
        public EventNotificationEnumType? EventNotificationType { set; get; }

        /// <summary>
        /// Component for which event is notified.
        /// </summary>
        [Required]
        public ComponentType Component { set; get; }

        /// <summary>
        /// Variable for which event is notified.
        /// </summary>
        [Required]
        public VariableType Variable { set; get; }



    }
}
