public async Task DisconnectAsync() { if (client != null) { log.Debug(l => l(LogMessages.Disconnecting, Host)); Device.Disconnect(); await disconnected.Task; disconnectedTokenSource.Cancel(); try { await processMessagesTask; } catch (Exception e) { if (!(e is OperationCanceledException)) { log.Warn(l => l(LogMessages.ProcessMessagesTaskFailed), e); } } processMessagesTask = null; connected = null; disconnected = null; Device.Dispose(); Device = null; client.Dispose(); client = null; } }
internal SystemSetupPictureModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (SystemSetupPictureStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(SystemSetupPictureStruct)); }
public async Task ConnectAsync(string host, string applicationName, string userName, string password, CancellationToken cancellationToken) { if (client != null) { throw new InvalidOperationException(); } log.Debug(l => l(LogMessages.Connecting, userName, host)); connected = new TaskCompletionSource <bool>(); disconnected = new TaskCompletionSource <bool>(); client = SDK.CreateSDK(applicationName); Device = client.CreateMTA(); Device.NotifyConnectHandlers = NotifyConnectHandler; Device.NotifyConnectionStateHandlers = NotifyConnectionStateHandler; Device.Connect(host, userName, password); disconnectedTokenSource = new CancellationTokenSource(); var disconnectedToken = disconnectedTokenSource.Token; processMessagesTask = Task.Run(() => ProcessMessages(disconnectedToken), cancellationToken); try { await connected.Task; } catch (Exception e) { log.Error(l => l(LogMessages.ConnectFailed), e); disconnected.TrySetResult(true); DisconnectAsync(); throw; } }
internal BeaconDownloadConfigModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (BeaconDownloadConfigStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(BeaconDownloadConfigStruct)); }
public static void LoadNextPacs(string nudFileName, ModelContainer modelContainer) { // Read pacs to hide meshes. string pacDirectory = nudFileName.Replace("model.nud", ""); if (!Directory.Exists(pacDirectory)) { return; } string[] pacs = Directory.GetFiles(pacDirectory, "*.pac"); foreach (string s in pacs) { PAC p = new PAC(); p.Read(s); byte[] data; if (p.Files.TryGetValue("display", out data)) { MTA m = new MTA(); m.read(new FileData(data)); modelContainer.NUD.ApplyMta(m, 0); } if (p.Files.TryGetValue("default.mta", out data)) { MTA m = new MTA(); m.read(new FileData(data)); modelContainer.NUD.ApplyMta(m, 0); } } }
internal TransponderModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (TransponderStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(TransponderStruct)); _label = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.label); }
internal ChartImage(System.IntPtr nativePointer, MTA context) { _nativePointer = nativePointer; _data = (ChartImageStruct)System.Runtime.InteropServices.Marshal.PtrToStructure( nativePointer, typeof(ChartImageStruct)); _handleWrapper = context; }
internal SequenceSegment(System.IntPtr nativePointer, MTA context) { _nativePointer = nativePointer; _data = (SequenceSegmentStruct)System.Runtime.InteropServices.Marshal.PtrToStructure( nativePointer, typeof(SequenceSegmentStruct)); _handleWrapper = context; }
internal Timezone(System.IntPtr nativePointer, MTA context) { _nativePointer = nativePointer; _data = (TimezoneStruct)System.Runtime.InteropServices.Marshal.PtrToStructure( nativePointer, typeof(TimezoneStruct)); _handleWrapper = context; _name = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.name); }
internal SequenceModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (SequenceStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(SequenceStruct)); _name = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.name); _description = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.description); }
internal static System.Collections.Generic.List <Timezone> FromNativePointerArray( System.IntPtr pointerToNativeArray, uint count, MTA context) { var ptrArray = new System.IntPtr[count]; System.Runtime.InteropServices.Marshal.Copy(pointerToNativeArray, ptrArray, 0, (int)count); return(new System.Collections.Generic.List <Timezone>( System.Array.ConvertAll <System.IntPtr, Timezone>(ptrArray, ptr => new Timezone(ptr, context)))); }
internal DecoderPresetGroup(System.IntPtr nativePointer, MTA context) { _nativePointer = nativePointer; _data = (DecoderPresetGroupStruct)System.Runtime.InteropServices.Marshal.PtrToStructure( nativePointer, typeof(DecoderPresetGroupStruct)); _handleWrapper = context; _name = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.name); _description = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.description); }
private M AddModifier(IntPtr p) { if (p == IntPtr.Zero) { throw new MylapsException("failed to create a TransponderGroupModifier"); } var modifier = NewModifier(p); MTA.AddModifier(modifier); return(modifier); }
internal ApplianceContainer(MTA mta, IntPtr mtaHandle) { _mta = mta; _mtaHandle = mtaHandle; _connectionNotifier = NotifyConnect; _connectionStateNotifier = NotifyConnectionState; NativeMethods.mta_notify_connect(mtaHandle, _connectionNotifier); NativeMethods.mta_notify_connectionstate(mtaHandle, _connectionStateNotifier); }
internal TrackSolution(System.IntPtr nativePointer, MTA context) { _nativePointer = nativePointer; _data = (TrackSolutionStruct)System.Runtime.InteropServices.Marshal.PtrToStructure( nativePointer, typeof(TrackSolutionStruct)); _handleWrapper = context; _name = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.name); _description = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.description); _lapcounters = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.lapcounters); }
internal static Competitor FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new Competitor(pointerToNativeStruct, context)); } }
internal static SystemSetupPicture FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new SystemSetupPicture(pointerToNativeStruct, context)); } }
internal static Timezone FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new Timezone(pointerToNativeStruct, context)); } }
internal static Segment FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new Segment(pointerToNativeStruct, context)); } }
internal static TrackSolution FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new TrackSolution(pointerToNativeStruct, context)); } }
internal static DecoderPresetGroup FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new DecoderPresetGroup(pointerToNativeStruct, context)); } }
internal static TransponderGroup FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new TransponderGroup(pointerToNativeStruct, context)); } }
internal static BeaconDownloadConfig FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new BeaconDownloadConfig(pointerToNativeStruct, context)); } }
internal static IOTerminal FromNativePointer( System.IntPtr pointerToNativeStruct, MTA context) { if (pointerToNativeStruct == System.IntPtr.Zero) { return(null); } else { return(new IOTerminal(pointerToNativeStruct, context)); } }
internal CompetitorModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (CompetitorStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(CompetitorStruct)); _number = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.number); _firstname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.firstname); _lastname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.lastname); _competitorclass = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.competitorclass); _imagehash = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.imagehash); _guid = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.guid); }
internal SystemSetupModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (SystemSetupStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(SystemSetupStruct)); _description = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.description); _imagehash = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.imagehash); _reserved = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.reserved); _timezoneid = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.timezoneid); _masterhostname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.masterhostname); _masterusername = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.masterusername); _masterpassword = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.masterpassword); }
internal UserModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (UserStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(UserStruct)); _username = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.username); _password = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.password); _firstname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.firstname); _lastname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.lastname); _companyname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.companyname); _role = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.role); _imagehash = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.imagehash); _nickname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.nickname); }
private void NotifyConnectionStateHandler(CONNECTIONSTATE state, MTA sender) { log.Debug(l => l(LogMessages.ConnectionStateChanged, state)); switch (state) { case CONNECTIONSTATE.csConnectFailed: Task.Run(() => connected.TrySetException(new X2ConnectFailedException())); break; case CONNECTIONSTATE.csAuthenticationFailed: Task.Run(() => connected.TrySetException(new X2ConnectFailedException(Resources.AuthenticationFailed))); break; } }
internal TrackSolutionContainer(MTA mta) { _mta = mta; _nativeHandle = mta.NativeHandle; _allTrackSolutionDataAvailable = false; _allTrackSolutionGroupDataAvailable = false; _allSectorDataAvailable = false; _allSequenceDataAvailable = false; _allSequenceSegmentDataAvailable = false; _allTimingConfigurationDataAvailable = false; _pfTrackSolutionGroupNotifier = NotifyTrackSolutionGroup; _pfTrackSolutionNotifier = NotifyTrackSolutions; _pfSectorNotifier = NotifySectors; _pfSequenceNotifier = NotifySequences; _pfSequenceSegmentNotifier = NotifySequenceSegments; RegisterNotifyDelegate(); }
private void NotifyConnectHandler(bool newValue, MTA sender) { isConnected = newValue; if (isConnected) { log.Info(l => l(LogMessages.Connected, Host)); OnConnected(); } else { log.Info(l => l(LogMessages.Disconnected)); OnDisconnected(); } if (isConnected) { Task.Run(() => connected.TrySetResult(true)); } else { Task.Run(() => disconnected.TrySetResult(true)); } }