Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More API #1209

Merged
merged 5 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions TLM/TLM/Manager/Impl/LaneArrowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class LaneArrowManager
/// </summary>
public const VehicleInfo.VehicleType VEHICLE_TYPES = VehicleInfo.VehicleType.Car;

public NetInfo.LaneType LaneTypes => LANE_TYPES;

public VehicleInfo.VehicleType VehicleTypes => VEHICLE_TYPES;


public const ExtVehicleType EXT_VEHICLE_TYPES =
ExtVehicleType.RoadVehicle & ~ExtVehicleType.Emergency;

Expand All @@ -39,9 +44,6 @@ protected override void InternalPrintDebugInfo() {
Log.NotImpl("InternalPrintDebugInfo for LaneArrowManager");
}

/// <summary>
/// Get the final lane arrows considering both the default lane arrows and user modifications.
/// </summary>
public LaneArrows GetFinalLaneArrows(uint laneId) {
return Flags.GetFinalLaneArrowFlags(laneId, true);
}
Expand Down
19 changes: 3 additions & 16 deletions TLM/TLM/Manager/Impl/LaneConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class LaneConnectionManager
| VehicleInfo.VehicleType.Metro
| VehicleInfo.VehicleType.Monorail
| VehicleInfo.VehicleType.Trolleybus;
public NetInfo.LaneType LaneTypes => LANE_TYPES;

public VehicleInfo.VehicleType VehicleTypes => VEHICLE_TYPES;

static LaneConnectionManager() {
Instance = new LaneConnectionManager();
Expand All @@ -41,13 +44,6 @@ protected override void InternalPrintDebugInfo() {
Log.NotImpl("InternalPrintDebugInfo for LaneConnectionManager");
}

/// <summary>
/// Checks if traffic may flow from source lane to target lane according to setup lane connections
/// </summary>
/// <param name="sourceLaneId"></param>
/// <param name="targetLaneId"></param>
/// <param name="sourceStartNode">(optional) check at start node of source lane?</param>
/// <returns></returns>
public bool AreLanesConnected(uint sourceLaneId, uint targetLaneId, bool sourceStartNode) {
if (!Options.laneConnectorEnabled) {
return true;
Expand Down Expand Up @@ -91,11 +87,6 @@ public bool HasConnections(uint sourceLaneId) {
return HasConnections(sourceLaneId, IsHeadingTowardsStartNode(sourceLaneId));
}

/// <summary>
/// Determines if the given lane has outgoing connections
/// </summary>
/// <param name="sourceLaneId"></param>
/// <returns></returns>
public bool HasConnections(uint sourceLaneId, bool startNode) {
if (!Options.laneConnectorEnabled) {
return false;
Expand Down Expand Up @@ -131,10 +122,6 @@ public bool HasSegmentConnections(ushort segmentId, ushort nodeId) {
return false;
}

/// <summary>
/// Determines if there exist custom lane connections at the specified node
/// </summary>
/// <param name="nodeId"></param>
public bool HasNodeConnections(ushort nodeId) {
if (!Options.laneConnectorEnabled) {
return false;
Expand Down
4 changes: 4 additions & 0 deletions TLM/TLM/Manager/Impl/SpeedLimitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class SpeedLimitManager
VehicleInfo.VehicleType.Metro | VehicleInfo.VehicleType.Train |
VehicleInfo.VehicleType.Monorail | VehicleInfo.VehicleType.Trolleybus;

public NetInfo.LaneType LaneTypes => LANE_TYPES;

public VehicleInfo.VehicleType VehicleTypes => VEHICLE_TYPES;

public static readonly SpeedLimitManager Instance = new();

// For each NetInfo (by name) and lane index: custom speed limit
Expand Down
3 changes: 2 additions & 1 deletion TLM/TLM/TLM.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand All @@ -13,6 +13,7 @@
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<LangVersion>preview</LangVersion>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
krzychu124 marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
15 changes: 14 additions & 1 deletion TLM/TMPE.API/Manager/ILaneArrowManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
namespace TrafficManager.API.Manager {
namespace TrafficManager.API.Manager {
using TrafficManager.API.Traffic.Enums;

public interface ILaneArrowManager {
// TODO define me!

/// <summary>lane types for all road vehicles.</summary>
public NetInfo.LaneType LaneTypes { get; }

/// <summary>vehicle types for all road vehicles</summary>
public VehicleInfo.VehicleType VehicleTypes { get; }

/// <summary>
/// Get the final lane arrows considering both the default lane arrows and user modifications.
/// </summary>
public LaneArrows GetFinalLaneArrows(uint laneId);
}
}
25 changes: 23 additions & 2 deletions TLM/TMPE.API/Manager/ILaneConnectionManager.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
namespace TrafficManager.API.Manager {
namespace TrafficManager.API.Manager {
public interface ILaneConnectionManager {
// TODO define me!

public NetInfo.LaneType LaneTypes { get; }

public VehicleInfo.VehicleType VehicleTypes { get; }

/// <summary>
/// Determines whether u-turn connections exist for the given segment end.
/// </summary>
/// <param name="segmentId">segment id</param>
/// <param name="startNode">at start node?</param>
/// <returns><code>true</code> if u-turn connections exist, <code>false</code> otherwise</returns>
/// <returns><code>true</code> if u-turn connections exist, <code>false</code> otherwise.</returns>
bool HasUturnConnections(ushort segmentId, bool startNode);

/// <summary>
/// Determines if there exist custom lane connections at the specified node.
/// </summary>
bool HasNodeConnections(ushort nodeId);

/// <summary>
/// Determines if the given lane has outgoing connections.
/// </summary>
/// <param name="startNode">start node for the segment of the lane.</param>
public bool HasConnections(uint sourceLaneId, bool startNode);

/// <summary>
/// Checks if traffic may flow from source lane to target lane according to setup lane connections
/// </summary>
/// <param name="sourceStartNode">check at start node of the segment of the source lane?</param>
public bool AreLanesConnected(uint sourceLaneId, uint targetLaneId, bool sourceStartNode);
}
}
4 changes: 4 additions & 0 deletions TLM/TMPE.API/Manager/ISpeedLimitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ namespace TrafficManager.API.Manager {
public interface ISpeedLimitManager {
// TODO define me!

public NetInfo.LaneType LaneTypes { get; }

public VehicleInfo.VehicleType VehicleTypes { get; }

/// <summary>
/// For use by external code.
/// Retrieves the speed limit for the given lane without locking.
Expand Down