Creating the GenetecVSO macro in the Transportation Sensor Management plugin - To simulate TSS data to be used as Genetec™ events, you must first create the GenetecVSO macro. - Transportation Sensor Management 5.10.5.0 - Plugin and extension guides
To simulate TSS data to be used as Genetec™ events, you must first create the GenetecVSO
macro.
What you should know
Using the GenetecVSO macro, you can send simulated TSS data.
Using the GentecVSO-interval macro, you can send TSS data at an interval for a set
amount of time.
To use this macro, add FrequencySecondsPerEvent
and Number_of_runs.
Procedure
Open the System task, then click General
settings and select the Events page.
From the entity tree, select the TSS zone data input event, and
take note of the string in the Value column.
Select the Macros page.
Click Macro () and
enter a name for the macro.
Click the Properties tab.
Copy the following macro in the text editor and configure your TSS Zone Data
Input.
using System;
using System.Collections.Generic;
using System.Data;
using System.Xml;
using Genetec.Sdk.Helpers;
using Genetec.Sdk;
using Genetec.Sdk.Entities;
using Genetec.Sdk.Entities.CustomEvents;
using Genetec.Sdk.Entities.Utilities;
using Genetec.Sdk.Enumerations;
using Genetec.Sdk.Events;
using Genetec.Sdk.Queries;
using Genetec.Sdk.Scripting;
public sealed class TSSZoneDataInputMacro : UserMacro
{
public int CustomEventId { get; set; }
public Guid TssGuid { get; set; }
public int ZoneId { get; set; }
public int Count { get; set; }
public string Classification { get; set; }
public int SpeedKPH { get; set; }
public int Occupancy { get; set; }
public Guid PluginEntityGUID {get;set;}
[Serializable]
public class Volume
{
public int Count { get; set; }
public string Classification { get; set; }
}
[Serializable]
public class GenetecZoneData
{
public Guid TssGuid { get; set; }
public int ZoneId { get; set; }
public List<Volume> Counts { get; set; }
public int Speed { get; set; }
public int Occupancy { get; set; }
}
/// <summary>
/// Entry point of the macro. Provide an implementation of this method.
/// </summary>
public override void Execute()
{
if (CustomEventId == 0 || TssGuid == Guid.Empty) return;
var data = new GenetecZoneData { TssGuid = TssGuid, ZoneId = ZoneId };
data.Counts = new List<TSSZoneDataInputMacro.Volume>();
data.Speed = (int)Math.Round(SpeedKPH * 0.277778);
data.Occupancy = Occupancy;
data.Counts.Add(new TSSZoneDataInputMacro.Volume { Count = Count, Classification = Classification });
var evt = Sdk.ActionManager.BuildEvent(EventType.CustomEvent, PluginEntityGUID) as CustomEventInstance;
if (evt == null) return;
evt.Id = new CustomEventId(CustomEventId);
evt.Message = SerializationHelper.SerializeToString(data);
Sdk.ActionManager.RaiseEvent(evt);
}
/// <summary>
/// Called when the macro needs to clean up.
/// </summary>
protected override void CleanUp()
{
// Release objects created by the Execute method, unhook events, and so on.
}
}
NOTE: The macro can also be imported from a file.
Click the Default context execution tab, and in the
Custom event ID field, enter the Value you
copied from the TSS zone data input event.