/**
 * <p class=proto-main>This API enables the SDP to configure the TBM for Parental Control data collection and notification.
 * The feature supports notifying the vehicle owner with alerts for geofencing, curfew, speed, valet, and similar events. 
 * </p>
 *
 * <div class=proto-hier>
 * 	 UconnectAny
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.PCUpdateConfigRequest">PCUpdateConfigRequest</a>
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.PCUpdateConfigResponse">PCUpdateConfigResponse</a>
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.PCConfiguredAlertPublish">PCConfiguredAlertPublish</a>
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.PCNotificationPublish">PCNotificationPublish</a>
 *     |
 * 	   |---- <a href="#com.fca.uconnect.global.AckMessage">AckMessage</a>
 *
 * </div>
 *
 *  <h3 class=change-log-hdr> Change Log</h3>
 *  <table id="change-log" class="change-log"><thead><tr>
 *	<td>Version</td><td>Date</td><td>Notes</td></tr></thead>
 *   <tbody>
<tr><td>1.12</td<td>2019-01-20></td><td>Removed Deprecated from the response items to accomodate REPLACE method : Fixed mispelling OUT_OF_BOUNDRY to OUT_OF_BOUNDARY and mispelled Indentifier fixed in ConfigResponseType</td></tr>
 * <tr><td>1.10</td<td>2018-09-20></td><td><Added TripId to Speed and Drive Alerts /td></tr>
 * <tr><td>1.9</td<td>2018-09-20></td><td><Added BreachType Both and made corrections /td></tr>
 * <tr><td>1.8</td<td>2018-08-30></td><td><Added BreachType /td></tr>
 *  <tr><td>1.7</td<td>2018-08-21></td><td>Added a ConfigActionEnum to various alerts, added timestamp to logged events and utcoffset</td></tr>
 *  <tr><td>1.6</td><td>2018-06-20</td><td>Added LogAlert to Conig</td></tr>
 <tr><td>1.5</td><td>2018-06-20</td><td>Update ConfigTypeVehicle, Added Logs Configuration and Uploads, added name to PC Config</td></tr>
 *  <tr><td>1.4</td><td>2017-11-2</td><td>Update to Proto3</td></tr>
 *  <tr><td>1.3</td><td>2017-09-27</td><td>Update configuration response.</td></tr>
 *  <tr><td>1.2</td><td>2017-09-15</td><td>Added ACKMessage RadiusUnitsEnum.</td></tr>
 *  <tr><td>1.1</td><td>2017-04-19</td><td>Added RadiusUnitsEnum.</td></tr>
 *	<tr><td>1.0</td><td>2017-03-19</td><td>Release of initial Proto.</td></tr>
 *	</tbody></table>
 *
 *  <h3 class=change-log-hdr>List of MQTT Topics</h3>
 *  <table class="change-log"><thead><tr>
 *	<td>Flow</td><td>Type</td><td>Topic Name</td></tr></thead>
 *    <tbody>
 *   <tr><td>Cloud send to Vehicle</td><td>Publish</td><td>fcasdp/${iot:ClientId}/PC</td></tr>
 *	 <tr><td>Cloud receive from Vehicle</td><td>Subscribe</td><td>fcasdp/PC/#</td></tr>
 *	 <tr><td>Vehicle send to Cloud </td><td>Publish</td><td>fcasdp/PC/${iot:ClientId}</td></tr>
 *	 <tr><td>Vehicle receive from Cloud </td><td>Subscribe</td><td>fcasdp/${iot:ClientId}/#</td></tr>
 *	</tbody></table>
 * <h3 class=change-log-hdr>Data Flow</h3>
 * <p class=proto-main>The following sequence diagram depicts the flow of messages between the TBM and the SDP for regions that use PCConfiguredAlertPublish:</p>
 *
 * <img class=img-border src=./images/pc.png>
 *
 * <table class=sequence-table><thead><tr>
 *	<td>Seq</td><td>Title</td><td>Role</td><td>Message</td><td>Topic</td><td>Description</td></tr></thead>
 *   <tbody>
 * <tr><td>1.</td><td>PC Provisioned Active Event</td><td>SDP</td><td></td><td></td><td><p>PC Provisioned active for Provisioning Push .</p></td></tr>
 * <tr><td></td><td>par</td><td></td><td></td><td></td><td><p>The interaction operator par defines potentially parallel execution of behaviors of the operands of the combined fragment. Different operands can be interleaved in any way as long as the ordering imposed by each operand is preserved.</p></td></tr>
 * <tr><td></td><td>async</td><td></td><td></td><td></td><td>The async means send message and proceed immediately without waiting for return value.<p></p></td></tr>
 * <tr><td>2.1</td><td>PCRequest Event</td><td>SDP<td></td><td></td><td><p>The SDP PC Request event which triggers to send an PCUpdateConfigRequest to the Client.</p></td></tr>
 * <tr><td>2.2</td><td>Assign MessageId</td><td>SDP</td><td></td><td></td><td><p>The SDP generates the messageId for the message by incrementing a sequence counter.</p></td></tr>
 * <tr><td>2.3</td><td>Send PCUpdateConfigRequest Message</td><td>SDP</td><td>PCUpdateConfigRequest</td><td>${iot:ClientId}/PC</td><td><p>The SDP populates the PCUpdateConfigRequest Message with the required elements and publishes to the PC topic.</p></td></tr>
 * <tr><td>2.4</td><td>Process Message</td><td>TBM</td><td></td><td></td><td><p>The Client processes the message and generates an PCUpdateConfigResponse Message with the status and the correlationId set to the messageId from the received PCUpdateConfigRequest Message.</p></td></tr>
 * <tr><td>2.5</td><td>Assign CorrelationID</td><td>TBM</td><td></td><td></td><td><p>The correlationId set to the messageId from the received PCUpdateConfigRequest Message.</p></td></tr>
 * <tr><td>2.6</td><td>Send PCUpdateConfigResponse Message</td><td>TBM</td><td>PCUpdateConfigResponse</td><td>/PC/${iot:ClientId}</td><td><p>The Client publishes the response message to the PC topic for the SDP to receive.</p></td></tr>
 * <tr><td>2.7</td><td>Process Response</td><td>SDP</td><td></td><td></td><td><p>The SDP receives the message and verifies the correlationId matches the messageId of the sent request.</p></td></tr>
 * <tr><td>3.1</td><td>Trigger Event</td><td>TBM</td><td></td><td></td><td><p>Once the PC is Configured after the appropriate out of band approval steps, the Client will build a new PCConfiguredAlertPublish Message with the required elements.  </p></td></tr>
 * <tr><td>3.2</td><td>Send PCConfiguredAlertPublish Message</td><td>TBM</td><td><p>PCConfiguredAlertPublish</td><td>/PC/${iot:ClientId}</td><td>The Client publishes the PCConfiguredAlertPublish message to the PC topic for the SDP to receive.</p></td></tr>
 * <tr><td>3.3</td><td>Process ConfiguredAlert</td><td>SDP</td><td></td><td></td><td><p>The SDP receives the message and process configured Alert.</p></td></tr>
 * <tr><td>4.1</td><td>Send PCLogUploads Message</td><td>TBM</td><td><p>PCLogUploads</td><td>/PC/${iot:ClientId}</td><td>The Client publishes the configured and required logs via this message</p></td></tr>
 * <tr><td>4.2</td><td>Process Logs</td><td>SDP</td><td></td><td></td><td><p>The SDP receives the message and process the logs.</p></td></tr>
 *  <tr><td>4.3</td><td>Process Logs</td><td>SDP</td><td></td><td></td><td><p>Ack Message returned.</p></td></tr>
 * </tbody>
 * </table>
 *
 *
 **/

syntax="proto3";
package com.fca.uconnect.global;


// import public "Global_Uconnect_Control.proto";
import public "Global_Uconnect_VehicleInfo.proto";
import public "Global_Uconnect_GNSS.proto";

/**
 * This message represents  PCUpdateConfigRequest which triggers from SDP.
 * <div class=exmsg-main>
 * <h4>PCUpdateConfigRequest Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 *		timestamp: 1490711212633
 * 		messageId: 11
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.pcUpdateConfigRequest]
 * 		 {
 * 		  configTypeVehicle
 * 		  {
 * 			speedAlerts
 * 			{
 * 			 beginTime: 1000
 * 			 endTime: 10000
 * 			 activeDaysOfWeek: 1
 * 			 activeDaysOfWeek: 2
 * 			 thresholdAbovePostedSpeed: 60
 * 			 thresholdPostedSpeedAbsent: 80
 * 			 thresholdAbsolute: 70
 * 			}
 * 		   updateSpeedAlertConfig: true
 * 		  }
 * 		 }
 * 		}
 *	</code>
 *   </div>
 * </div>
 */
message PCUpdateConfigRequest {

/**
* Set of rules used by the TBM to generate asynchronous alerts based on time, position and vehicle behavior.
* Each message may be a complete set of configuration data, or may use the boolean 'update' fields to update only particular configuration types.
* For each alert type, send the complete list of up to 5 alerts each time you submit.
If a particular alert identifier is present in the one message and absent in the next, it should be removed. The exception is ValetAlerts
* as there is only one ValetAlert, use the isEnabled boolean to enable and disable.
*/

/**	message config {
		ConfigTypeVehicle configTypeVehicle = 1; /// supported in NAFTA
		// ConfigTypeSDP configTypeSDP = 2; /// supported in EMEA, APAC
	}
*/

 ConfigTypeVehicle config = 1;
}

	message ConfigTypeVehicle {

		message LogAlerts {
		//string name = 13;
		//string identifier = 14;
		bool TripLog = 10;
		bool DriveStyle = 11;
		bool SpeedViolationReport = 12;
							}
		message CurfewAlertConfig {
			 string name = 6;	/// Display text name for the configuration
			 string identifier = 1; /// the identifier of the config that was triggered will be put in the generated alert
			 int32 beginTime = 2; /// seconds after midnight
			 int32 endTime = 3; /// seconds after midnight
			repeated int32 activeDaysOfWeek = 4; /// 0 == Sunday, 1 == Monday ...
			bool recurringAlert = 5; /// should happen only once or recurring.
			ConfigActionEnum configAction = 7;
							}

		message SpeedAlertConfig {
			string name = 10;	/// Display text name for the configuration
			 string identifier = 1; /// the identifier of the config that was triggered will be put in the generated alert
			 int32 beginTime = 2; /// seconds after midnight
			 int32 endTime = 3; /// seconds after midnight
			repeated int32 activeDaysOfWeek = 4; /// 0 == Sunday, 1 == Monday ... 
			 int32 thresholdAbovePostedSpeed = 5; /// if posted speed is available from Nav, alert if speed > thresholdAbovePostedSpeed + posted
			 int32 thresholdPostedSpeedAbsent = 6; /// if nav present but posted speed currently not valid alert if speed > thresholdPostedSpeedAbsent
			 int32 thresholdAbsolute = 7; /// alert if speed > thresholdAbsolute, unless nav is present and posted speed is available and speed <= thresholdAbovePostedSpeed + posted
			 bool recurringAlert = 8; /// should happen only once or recurring.
			ConfigActionEnum configAction = 11;
			 UnitOfMeasure unitOfMeasure = 9;
								}

		
		message ValetAlertConfig {
			 bool isEnabled = 8; /// Enable or disable this alert
			 string identifier = 1; /// the identifier of the config that was triggered will be put in the generated alert
			 bool Activate = 7; /// 0 deactivates and 1 activates
			 float alertRadius = 5;/// Radius Units (i.e 1.2)
			 ConfigActionEnum configAction = 9;
			 UnitOfMeasure radiusUnitsEnum = 6;/// This represents whether alertRadius is in miles or kilometers.

			}

		

		message GeoFenceAlertConfig {
			string name = 11;	/// Display text name for the configuration
			 string identifier = 1; /// the identifier of the config that was triggered will be put in the generated alert
			 int32 beginTime = 2; /// seconds after midnight.
			 int32 endTime = 3; /// seconds after midnight
			GeoFenceType geoFenceTypeEnum = 10; ///
			repeated int32 activeDaysOfWeek = 4; /// 0 == Sunday, 1 == Monday ... 
			repeated Location boundaryPoints = 5;	
			Location radiusCenter = 7; /// Center Location for Radius Fence
			float Radius = 8; /// Radius for Radius Fence
			UnitOfMeasure radiusUnitsEnum = 6;/// This represents whether alertRadius is in miles or kilometers.
			bool recurringAlert = 9; /// should happen only once or recurring.
			BreachTypeEnum breachType = 12; // Only used for responses, not used to configure
			ConfigActionEnum configAction = 13;
		}


			enum BreachTypeEnum {
				DEFAULT = 0;
				OUT_OF_BOUNDARY = 1;
				IN_BOUNDARY = 2;
				BOTH = 3;

			}
			enum UnitOfMeasure {
				KILOMETERS = 0; // Default Value
				MILES = 1; // // Miles Per Hour
				}



			enum GeoFenceType {
				Polygon = 0;
				Radius =1;
								}

			enum ConfigActionEnum {
				DEFAULTACTION = 0;
				ADD = 1;
				DELETE = 2;
				UPDATE = 3;
				//REPLACE =4;
			}



		LogAlerts logAlerts = 8; /// Configure Log Alerts
		repeated CurfewAlertConfig curfewAlerts = 1;  /// 0 to 5 ranges
		//  bool updateCurfewAlertConfig = 2; /// If false, this message should not update curfewAlerts.
		repeated SpeedAlertConfig speedAlerts = 3;  /// 0 to 5 ranges
		// bool updateSpeedAlertConfig = 4; /// If false, this message should not update speedAlerts.
		 ValetAlertConfig valetAlert = 5; /// 0 or 1 configurations
		 // bool updateValetAlertConfig = 6;  /// If false, this message should not update valetAlert.
		repeated GeoFenceAlertConfig geoFenceAlerts = 7; /// If exactly one GeoFenceAlert is sent, begin and end time may both be set to zero to indicate the boundary is always active
		 // bool updateGeoFenceAlertConfig = 8; /// If false, this message should not update geoFenceAlerts.

	}



	/** message ConfigTypeSDP {
		 bool enablePositionSending = 1; /// send position updates if true
		 int32 positionSendingFrequency = 2; /// interval in seconds between position updates, ignored if enablePositionSending is false
		 int32 positionSendingActiveFrequency = 4; /// if enablePositionSending is on, the TBM shall notify the HU/IPC at this interval in seconds
		 bool enableSpeedSending = 5; /// enable or disable periodic sending of speed
		 int32 speedSendingFrequency = 6; /// interval in seconds between speed updates, ignored if enableSpeedSending is false
		 float harshAccelerationThreshold = 7; /// alert if positive acceleration is greater than this value, in m/s^2. Ignored if less than or equal to 0.0f;
		 float harshBrakingThreshold = 8; /// alert if negative acceleration is below this value, in m/s^2.  Ignored if greater than or equal to 0.0f;
		 float suddenCorneringThreshold = 9; /// vehicle acceleration Y Threshold. alert if negative acceleration is below this value, in m/s^2.  Ignored if greater than or equal to 0.0f;
		 bool userDeclinedGPSSending = 10; /// if true, no GPS values will be sent from the vehicle
	}
**/


/**
 * This message is response to PCUpdateConfigRequest .
 * <div class=exmsg-main>
 * <h4>PCUpdateConfigResponse Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1490712208347
 * 		messageId: 1
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.pcUpdateConfigResponse]
 * 		 {
 * 			responseEnum: SUCCESS
 * 		 }
 * 		}
 *	</code>
 *   </div>
 * </div>
 */
message PCUpdateConfigResponse {
	enum ResponseEnum {
		SUCCESS = 0;/// Config successful
		FAILURE = 1;/// Config failed
		CONFIG_TYPE_NOT_ALLOWED = 3;/// Config type not supported in this region 
		FAILURE_PRIVACY_ON = 4; /// Privacy Mode On
	}
	 ResponseEnum response = 1; ///
	 bool isTransient = 2; ///
	 int32 failureReasonCode = 3; ///

	 repeated ConfigResponseType configResponse = 4;

	 message ConfigResponseType {
	 	ResponseEnum configurationResponse = 1;
	 	string name = 2;
	 	string identifier = 3;
	 	int32 failureReasonCode = 4;
	 	bool isTransient = 5;

	 }



	 }

/**
 * This message is to notify SDP for Parental Controlconfigured Alert.
 * <div class=exmsg-main>
 * </div>
 */
message PCConfiguredAlertPublish {
	   oneof eventSource {
		ConfigTypeVehicle.CurfewAlertConfig curfewAlertConfig = 1; /// the configuration that triggered this alert
		ConfigTypeVehicle.SpeedAlertConfig speedAlertConfig = 2; /// the configuration that triggered this alert
		ConfigTypeVehicle.ValetAlertConfig valetAlertConfig = 3; /// the configuration that triggered this alert
		ConfigTypeVehicle.GeoFenceAlertConfig geoFenceAlertConfig = 4; /// the configuration that triggered this alert
	} 
	 Location eventLocation= 5; /// location of the vehicle when the event was triggered
	 int64 eventTimestampUTC= 6; /// UTC time the event was triggered
	 int32 eventTimeUTCOffset= 7; /// offset in seconds of the vehicle time zone from UTC
	 int32 vehicleSpeed= 8; /// speed in km/h  when the event was triggered
	 int32 postedSpeed= 9; /// posted speed value from NAV system
	 bool postedSpeedValid= 10; /// if false, postedSpeed was not available and/or did not participate in the trigger
}
/**
 * This message is to Notify SDP for Parental Control alert.
 * <div class=exmsg-main>
 * <h4>PCNotificationPublish Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1490713760069
 * 		messageId: 2
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.pcNotificationPublish]
 * 		 {
 * 			notificatonType: PERIODIC_SEND
 * 			speed: 75
 * 			speedSource: TBM_ACCELEROMETER
 * 			acceleration: 35.0
 * 			accelerationSource: TBM_ACCELEROMETER
 * 			suddenCorneringRate: 15.5
 * 			vehiclePosition
 * 			{
 * 			 vehiclePosition
 * 			 {
 * 			  positionLatitude: -84.54635620117188
 * 			  positionLongitude: 43.999900817871094
 * 			 }
 * 			 positionEncrypted: false
 * 			 gpsTimestamp: 360108355
 * 			 vehicleDirection: 32
 * 			}
 * 		   }
 * 		  }
 *	</code>
 *   </div>
 * </div>
 */

 message PCLogUploads {
 	TripLog tripLog = 1;
 	DrivingStyleLog driveStyleLog = 2;
 	SpeedAlertsLog speedAlertsLog = 3;
}

 		message TripLog {
 		string tripID = 5;
 		int64 IgnitionOnTimeStamp = 1; /// Time of IgnitionOn
 		Location startLocation = 2; /// Location at IgntionOn
 		int64 IgnitionOffTimeStamp = 3; /// Time of Igntion Off
 		int32 eventTimeUTCOffset= 7; /// offset in seconds of the vehicle time zone from UTC
 		Location endLocation = 4; /// Location at Ignition Off
 		}

message DrivingStyleLog {
	string tripID = 11;
	repeated Acceleration harshAcceleration = 8;
	repeated Braking  harshBraking = 9;
	repeated Cornering suddenCornering = 7;
	repeated SeatBelt seatBeltNotFastened = 10;
	}


message SpeedAlertsLog {
	string tripID = 5;
	int32 ViolationTotals = 1; /// Total number of speed alert threshold violations this trip

	}
	message Acceleration{
	int32 eventTimeUTCOffset = 3; /// offset in seconds of the vehicle time zone from UTC

		int64 violationTimestamp = 2;
		bool HARSH_ACCELERATION = 1; /// Harsh Acceleration threshold reached
	}

	message Braking {
		int32 eventTimeUTCOffset = 3; /// offset in seconds of the vehicle time zone from UTC
		int64 violationTimestamp = 1;
		bool HARSH_BREAKING = 2; /// Harsh Breaking threshold reached
	}
	message Cornering {
		int32 eventTimeUTCOffset = 3; /// offset in seconds of the vehicle time zone from UTC
		int64 violationTimestamp = 1;
		bool SUDDEN_CORNERING = 2; /// Harsh Breaking threshold reached
	}

	message SeatBelt {
		int32 eventTimeUTCOffset = 3; ///
		int64 violationTimestamp = 1;
		bool SEATBELT_NOT_FASTENED = 2; /// Harsh Breaking threshold reached
	}





	
// extend UconnectAny {
   //  PCUpdateConfigRequest pcUpdateConfigRequest = 1310;
   //  PCUpdateConfigResponse pcUpdateConfigResponse = 1311;
   //  PCConfiguredAlertPublish pcAlertPublish = 1312;
   //  PCNotificationPublish pcNotificationPublish = 1313;
   //  AckMessage pcAckMessage=1314;

// }


