Collaboration diagram for C# Rtc API:
Modules | |
DTO | |
Enumerations | |
Classes | |
class | RtcManager |
Implementation of IRtcManager. Start point for interacting with Deepsy Rtc service More... | |
interface | IRtc |
Interface RTC More... | |
interface | IRtcManager |
The Rtc interface that should be used to interact with the installed rtc. More... | |
Detailed Description
To work with Deepsy Rtc Manager service it is necessary to use RtcManager located in GMV.ITS.HAL.DEEPSY.Rtc.Facade for getting the initial RtcManager object.
RtcManager RtcManager = new RtcManager("");
RtcManager has an optional parameter indicating the ip address of remote service. For instance:
RtcManager RtcManager = new RtcManager("172.22.198.103");
RtcManager implements IDisposable. It can hold resources (such as socket handles) until it is disposed. The Dispose method is automatically called when existing a using or try / catch block, for which the object has been declared. This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur.
- * RtcManager RtcManager= null;try{RtcManager = new RtcManager("172.22.198.103");List<IRtc> Rtcs = RtcManager.GetRtcs().ToList();} catch (Exception e) {throw e;}RtcManager.Dispose();
Examples
-
Get Config
using System;using System.Collections.Generic;using System.Linq;using System.Text;{public class GetRtcConfigValue{static void Main(string[] args){string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];using (RtcManager rtcManager = new RtcManager(deepsyServerIp)){IRtc rtc = rtcManager.GetRtc();IParamConfig config = rtc.GetConfigValues();Console.WriteLine($"MaxDiffTimeSconds {config.MaxDiffTimeSconds} SyncTimeSeconds {config.SyncTimeSeconds }");}}}}
-
Get Sources list
using System;using System.Collections.Generic;using System.Linq;using System.Text;{public class GetRtcSources{static void Main(string[] args){string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];using (RtcManager rtcManager = new RtcManager(deepsyServerIp)){IRtc rtc = rtcManager.GetRtc();List<IRtcDateSource>sources = rtc.GetDateSources().ToList();foreach(IRtcDateSource source in sources){Console.WriteLine($"**************************");Console.WriteLine($"Source Name: {source.Name}");Console.WriteLine($"Source Priority: {source.Priority}");Console.WriteLine($"Source Uri: {source.Uri}");Console.WriteLine($"Source Time Local: {source.DateTimeLocal}");Console.WriteLine($"Source Source Type: {source.DateSourceType}");}}}}}
-
Get Rtc Date
using System;using System.Collections.Generic;using System.Linq;using System.Text;{public class GetRtcDate{static void Main(string[] args){string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];using (RtcManager rtcManager = new RtcManager(deepsyServerIp)){IRtc rtc = rtcManager.GetRtc();IDateAndTimeSync date = rtc.GetDateTime();Console.WriteLine($"Date {date.Datetime.ToString("yyyy/MM/dd HH:mm:ss")}");Console.WriteLine($"Last Date {date.LastSetDateAndTime.ToString("yyyy/MM/dd HH:mm:ss")}");Console.WriteLine($"Sync {date.Sync}");}}}}
-
Set Rtc synchronism time period in seconds
using System;using System.Collections.Generic;using System.Linq;using System.Text;{public class SetRtcSync{static void Main(string[] args){string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];using (RtcManager rtcManager = new RtcManager(deepsyServerIp)){IRtc rtc = rtcManager.GetRtc();rtc.SetSyncTime(5);}}}}
-
Add source
using System;using System.Collections.Generic;using System.Linq;using System.Text;{public class AddRtcSource{static void Main(string[] args){string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];using (RtcManager rtcManager = new RtcManager(deepsyServerIp)){IRtc rtc = rtcManager.GetRtc();rtc.AddNewDateSource("test", new RtcDateSource(){DateSourceType = DEEPSY.Rtc.Interface.Enum.DateSourceType.Type.GNSS,DateTimeLocal = false,Priority = 2,Uri = "127.0.0.1"});}}}}
</ul>