<?xml version="1.0" encoding="utf-8"?>
<Templates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://gpsgate.com/xml/">
  <Template type="ApplicationEntity">
    <Object>
      <TemplateGuid>a69d6690-f802-48ec-9766-dfb68edb5d79</TemplateGuid>
      <TemplateVersion>10</TemplateVersion>
      <ObjectType>GpsGate.Online.Scripting.ScriptApp</ObjectType>
      <ObjectData>
        <Name>Back to Garage</Name>
        <ClickScripts>
          <ClickScriptRef UsedInRoles="f3f977f4-266b-46bd-a3f3-e1e4aba1ab68 1a87c0ae-bc80-4ed8-a0eb-469767145b85 b72d758e-05f7-4f75-94c9-62c55ae3f49b">850f5f41-5e9b-4e47-a44b-4bd359dc8296</ClickScriptRef>
        </ClickScripts>
        <Roles>
          <RoleRef>b72d758e-05f7-4f75-94c9-62c55ae3f49b</RoleRef>
        </Roles>
        <ExplicitRefs />
        <WebServiceScripts />
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>850f5f41-5e9b-4e47-a44b-4bd359dc8296</TemplateGuid>
      <TemplateVersion>10</TemplateVersion>
      <ObjectType>GpsGate.Online.Scripting.NotifierClickScript</ObjectType>
      <ObjectData>
        <Name>Back to Garage</Name>
        <Disabled>false</Disabled>
        <Script>// Script for Notifier actions.

// Define total vehicle number
var total_vehicle_number=1;

var geo_id = Number(context.resolve('[NEW_GEOFENCE_ID]'));

log(geo_id)

if(geo_id &gt;0)
{ 
  var vehicle = geofences.getUsers(geo_id);
  if(vehicle.length == total_vehicle_number)
  {
	geofences.updateGroup('Garage Full',[geo_id],[]);
	log('add to full');
  }
  else 
  {
	geofences.updateGroup('Garage Full',[],[geo_id]);
	log('Not full')
  }
 
}





log("OK");</Script>
        <EventRuleRef>3728028b-1c42-4387-964a-aeafe1c1e53d</EventRuleRef>
        <NotifierStart>true</NotifierStart>
        <NotifierEnd>false</NotifierEnd>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>3728028b-1c42-4387-964a-aeafe1c1e53d</TemplateGuid>
      <TemplateVersion>11</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.EventExpressionEvaluatorWriter</ObjectType>
      <ObjectData>
        <Name>Inside Garage</Name>
        <Description></Description>
        <EvaluationOperator>AND</EvaluationOperator>
        <EndEvaluationOperator>AND</EndEvaluationOperator>
        <SupportUI>false</SupportUI>
        <AutoClose>true</AutoClose>
        <Disabled>false</Disabled>
        <FinishOnPreCondition>true</FinishOnPreCondition>
        <UserMatchMethod>Tags</UserMatchMethod>
        <Expressions>
          <ExpressionRef>d5397ce9-a56f-4e98-8610-4245ec6b4f1e</ExpressionRef>
          <ExpressionRef>42632234-ecfa-484f-be0a-9bd15b3afc86</ExpressionRef>
        </Expressions>
        <Notifiers>
          <NotifierRef>88c7fe22-dcc2-4a69-8f94-f4ca40e735d7</NotifierRef>
          <NotifierRef>3c405baf-43d8-41f8-96c5-da7ec3e79050</NotifierRef>
        </Notifiers>
        <PostConditions>
          <PostConditionRef>6b705e88-5c56-46de-b44a-2eb0a9eeead2</PostConditionRef>
        </PostConditions>
        <PreConditions>
          <PreConditionRef>b4c97ab1-53fe-44f1-8d25-68f88555baab</PreConditionRef>
        </PreConditions>
        <TagIDs />
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>d5397ce9-a56f-4e98-8610-4245ec6b4f1e</TemplateGuid>
      <TemplateVersion>11</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.ScriptExpression</ObjectType>
      <ObjectData>
        <IsEndExpression>false</IsEndExpression>
        <IsOneShot>false</IsOneShot>
        <Script>var geofence_group = 'Garage';

var st = context.state || {
  geofenceId: 0
};

var gfs = geofence.find(trackPoint.position.longitude, trackPoint.position.latitude, geofence_group);


var current = {
  geofenceId: gfs.length &gt; 0 ? gfs[0].id : 0
};

var result = st.geofenceId != current.geofenceId;

context.setState(current);

log(current.geofenceId)

if (result) { 
  context.setVariable('NEW_GEOFENCE_ID', current.geofenceId);  
  if (st.geofenceId != current.geofenceId) {
	context.setVariable('OLD_GEOFENCE_ID', st.geofenceId);
  }  
}

return result;</Script>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>42632234-ecfa-484f-be0a-9bd15b3afc86</TemplateGuid>
      <TemplateVersion>11</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.AnalogMessageExpression</ObjectType>
      <ObjectData>
        <IsEndExpression>true</IsEndExpression>
        <IsOneShot>false</IsOneShot>
        <MessageField>
          <MessageFieldIDRef>Speed</MessageFieldIDRef>
          <MessageNamespace>GpsGate</MessageNamespace>
        </MessageField>
        <RelationalOperator>GREATER_OR_EQUAL</RelationalOperator>
        <CompareValue>0</CompareValue>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>88c7fe22-dcc2-4a69-8f94-f4ca40e735d7</TemplateGuid>
      <TemplateVersion>11</TemplateVersion>
      <ObjectType>GpsGate.Online.Notification.SignalStartNotifier</ObjectType>
      <ObjectData>
        <Name>Signal Start Notifier</Name>
        <NotifierGroup>default</NotifierGroup>
        <Mode>Start</Mode>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>3c405baf-43d8-41f8-96c5-da7ec3e79050</TemplateGuid>
      <TemplateVersion>11</TemplateVersion>
      <ObjectType>GpsGate.Online.Notification.SignalEndNotifier</ObjectType>
      <ObjectData>
        <Name>Signal End Notifier</Name>
        <NotifierGroup>default</NotifierGroup>
        <Mode>Start</Mode>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>6b705e88-5c56-46de-b44a-2eb0a9eeead2</TemplateGuid>
      <TemplateVersion>11</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.EventDurationEvaluatorPostCondition</ObjectType>
      <ObjectData>
        <Name>Event duration evaluator post condition</Name>
        <RelationalOperator>GREATER_OR_EQUAL</RelationalOperator>
        <EventDuration>0</EventDuration>
        <AutoTrigger>false</AutoTrigger>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>b4c97ab1-53fe-44f1-8d25-68f88555baab</TemplateGuid>
      <TemplateVersion>11</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.DayOfWeekPeriodEvaluatorPreCondition</ObjectType>
      <ObjectData>
        <Name>Day of week evaluator pre condition</Name>
        <Periods>
          <Period>
            <StartTimeOfDay>0</StartTimeOfDay>
            <StopTimeOfDay>863999990000</StopTimeOfDay>
            <DayOfWeek>All</DayOfWeek>
            <EvaluationMethod>Inside</EvaluationMethod>
          </Period>
        </Periods>
      </ObjectData>
    </Object>
  </Template>
</Templates>