/// <summary>To get all known T2G systems.</summary> private void InitializeSystemList() { try { LogManager.WriteLog(TraceType.INFO, "Getting system list...", "PIS.Ground.Core.T2G.LocalDataStorage.GetSystemList", null, EventIdEnum.GroundCore); using (PIS.Ground.Core.T2G.WebServices.Identification.IdentificationPortTypeClient objIdentification = new IdentificationPortTypeClient()) { systemList lSystemStructList = objIdentification.enumSystems(_sessionData.SessionId); List <SystemInfo> lSystemList; if (T2GDataConverter.BuildSystemList(lSystemStructList, out lSystemList)) { // Construct the current system list from the returned data UpdateSystemList(lSystemList); } SubscribeToMessageNotifications(); SubscribeToServiceNotifications(); } } catch (Exception ex) { LogManager.WriteLog(TraceType.ERROR, ex.Message, "PIS.Ground.Core.T2G.T2GClient.GetSystemList", ex, EventIdEnum.GroundCore); } }
/// <summary>Search AvailableElementData by mission code (aka commercial number).</summary> /// <param name="commercialNumber">Mission code (aka commercial number)</param> /// <returns>list of found AvailableElementData.</returns> internal ElementList <AvailableElementData> GetAvailableElementDataListByMissionCode(string commercialNumber) { ElementList <AvailableElementData> elementDataList = new ElementList <AvailableElementData>(); if (!string.IsNullOrEmpty(commercialNumber)) { IList <SystemInfo> systemList; lock (_systemListLock) { systemList = _systemList.Where(element => (element.Value.PisMission != null && element.Value.PisMission.CommercialNumber == commercialNumber)).Select(e => e.Value).ToList(); } elementDataList.Capacity = systemList.Count; foreach (SystemInfo system in systemList) { AvailableElementData elementData = T2GDataConverter.BuildAvailableElementData(system); if (elementData != null) { elementDataList.Add(elementData); } } } return(elementDataList); }
/// <summary>Process Service Notification.</summary> /// <param name="systemId">system id.</param> /// <param name="isSystemOnline">is system online.</param> /// <param name="subscriptionId">service subscription id.</param> /// <param name="serviceList">list of services.</param> public void OnServiceNotification(string systemId, bool isSystemOnline, int subscriptionId, serviceStruct[] serviceList) { lock (_lock) { // This notification is sent by T2G for a single subscription, i.e. for a specific service ID. The list is not the // complete list of services on a train, it is a list of services with the same service ID. T2G supports multiple // services with the same ID present on a train, but PIS ground uses only those services that can only have one // instance on a given train. if (!string.IsNullOrEmpty(systemId)) { ServiceInfoList services = T2GDataConverter.BuildServiceList(serviceList); if (services != null) { _localDataStorage.OnServiceChanged(systemId, isSystemOnline, subscriptionId, services); ElementEventArgs elementEventArgs = _localDataStorage.BuildElementInfoChangedEvent(systemId); if (elementEventArgs != null) { _notifierTarget.RaiseOnElementInfoChangeEvent(elementEventArgs); } } } } }
/// <summary>Process File Transfer Notification.</summary> /// <param name="taskId">task id.</param> /// <param name="taskState">task state.</param> /// <param name="taskPhase">task phase.</param> /// <param name="activeFileTransferCount">file transfer count.</param> /// <param name="errorCount">error count.</param> /// <param name="acquisitionCompletionPercent">acquisition complete percentage.</param> /// <param name="transferCompletionPercent">transfer complete percentage.</param> /// <param name="distributionCompletionPercent">distribute complete percentage.</param> public void OnFileTransferNotification( int taskId, taskStateEnum taskState, taskPhaseEnum taskPhase, ushort activeFileTransferCount, ushort errorCount, sbyte acquisitionCompletionPercent, sbyte transferCompletionPercent, sbyte distributionCompletionPercent) { if (_fileDistributionManager != null) { lock (_lock) { FileDistributionStatusArgs fdsArgs = new FileDistributionStatusArgs(); fdsArgs.TaskId = taskId; fdsArgs.RequestId = _fileDistributionManager.GetFileDistributionRequestIdByTaskId(taskId); fdsArgs.ActiveFileTransferCount = activeFileTransferCount; fdsArgs.AcquisitionCompletionPercent = acquisitionCompletionPercent; fdsArgs.TransferCompletionPercent = transferCompletionPercent; fdsArgs.ErrorCount = errorCount; fdsArgs.DistributionCompletionPercent = distributionCompletionPercent; fdsArgs.TaskStatus = T2GDataConverter.BuildTaskState(taskState); fdsArgs.CurrentTaskPhase = T2GDataConverter.BuildTaskPhase(taskPhase); if (LogManager.IsTraceActive(TraceType.INFO)) { StringBuilder msg = new StringBuilder(200); msg.Append("OnFileTransferNotification("); msg.Append("task=").Append(fdsArgs.TaskId); msg.Append(",request=").Append(fdsArgs.RequestId); msg.Append(",aftc=").Append(fdsArgs.ActiveFileTransferCount); msg.Append(",acp=").Append(fdsArgs.AcquisitionCompletionPercent); msg.Append(",dcp=").Append(fdsArgs.DistributionCompletionPercent); msg.Append(",tcp=").Append(fdsArgs.TransferCompletionPercent); msg.Append(",TaskStatus=").Append(fdsArgs.TaskStatus); msg.Append(",CurrentTaskPhase=").Append(fdsArgs.CurrentTaskPhase); msg.Append(")"); LogManager.WriteLog(TraceType.INFO, msg.ToString(), "PIS.Ground.Core.T2G.T2GNotificationProcessor.OnFileTransferNotification", null, EventIdEnum.GroundCore); } _notifierTarget.RaiseOnFileDistributeNotificationEvent(fdsArgs, taskId); } } }
/// <summary>Search AvailableElementData By ElementNumber.</summary> /// <param name="elementNumber">element number.</param> /// <param name="objAvailableElementData">[out] Information describing the object available element.</param> /// <returns>if found return AvailableElementData else null.</returns> internal AvailableElementData GetAvailableElementDataByElementNumber(string elementNumber) { AvailableElementData elementData = null; if (!string.IsNullOrEmpty(elementNumber)) { lock (_systemListLock) { SystemInfo system; if (_systemList.TryGetValue(elementNumber, out system)) { elementData = T2GDataConverter.BuildAvailableElementData(system); } } } return(elementData); }
/// <summary>Process Message Notification.</summary> /// <param name="systemId">system id.</param> /// <param name="messageId">message id.</param> /// <param name="fieldList">field list.</param> public void OnMessageNotification(string systemId, string messageId, fieldStruct[] fieldList) { lock (_lock) { if (!string.IsNullOrEmpty(systemId) && !string.IsNullOrEmpty(messageId) && fieldList != null && fieldList.Length != 0) { if (messageId == T2GDataConverter.PisBaseline) { PisBaseline baseline = T2GDataConverter.BuildPisBaseLine(fieldList); if (baseline != null) { _localDataStorage.OnMessageChanged(systemId, messageId, baseline); } } else if (messageId == T2GDataConverter.PisVersion) { PisVersion version = T2GDataConverter.BuildPisVersion(fieldList); if (version != null) { _localDataStorage.OnMessageChanged(systemId, messageId, version); } } else if (messageId == T2GDataConverter.PisMission || messageId == T2GDataConverter.SivngMission) { PisMission mission = T2GDataConverter.BuildPisMission(fieldList); if (mission != null) { _localDataStorage.OnMessageChanged(systemId, messageId, mission); } } ElementEventArgs elementEventArgs = _localDataStorage.BuildElementInfoChangedEvent(systemId); if (elementEventArgs != null) { _notifierTarget.RaiseOnElementInfoChangeEvent(elementEventArgs); } } } }
/// <summary>Get all AvailableElementData</summary> /// <returns>list of all AvailableElementData.</returns> internal ElementList <AvailableElementData> GetAvailableElementDataList() { ElementList <AvailableElementData> elementDataList = new ElementList <AvailableElementData>(); lock (_systemListLock) { elementDataList.Capacity = _systemList.Count; foreach (KeyValuePair <string, SystemInfo> system in _systemList) { AvailableElementData elementData = T2GDataConverter.BuildAvailableElementData(system.Value); if (elementData != null) { elementDataList.Add(elementData); } } } return(elementDataList); }
/// <summary>Process System Changed Notification.</summary> /// <param name="system">The system.</param> public void OnSystemChangedNotification(systemInfoStruct system) { lock (_lock) { if (system != null) { SystemInfo newSystem = T2GDataConverter.BuildSystem(system); if (newSystem != null) { _localDataStorage.OnSystemChanged(newSystem); ElementEventArgs args = _localDataStorage.BuildElementInfoChangedEvent(newSystem.SystemId); if (args != null) { _notifierTarget.RaiseOnElementInfoChangeEvent(args); } } } } }