public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields() { IType hl7Type = new ChannelDefinition { ChannelIdentifier = new ChannelIdentifier { ChannelNumber = 1 }, WaveformSource = new WaveformSource { SourceOneName = "2" }, ChannelSensitivityAndUnits = new ChannelSensitivityAndUnits { ChannelSensitivity = 3 }, ChannelCalibrationParameters = new ChannelCalibrationParameters { ChannelCalibrationSensitivityCorrectionFactor = 4 }, ChannelSamplingFrequency = 5, MinimumAndMaximumDataValues = new NumericRange { LowValue = 6 } }; string expected = "1^2^3^4^5^6"; string actual = hl7Type.ToDelimitedString(); Assert.Equal(expected, actual); }
public static string GetChannelLabel(int channel) { if (ChannelsToLabel != null) { if (ChannelsToLabel.ContainsKey(channel)) { return(ChannelsToLabel[channel]); } else { ChannelDefinition def = new ChannelDefinition(); def.Channel = channel; def.Label = channel.ToString(); DMXConfigurationFile.Current.Definitions.Add(def); RefreshChannelList(); return(def.Label); } } else { return(channel.ToString()); } }
private static Channel ParseSeries(SeriesDefinition seriesDefinition) { ChannelDefinition channelDefinition = seriesDefinition.ChannelDefinition; // Populate series properties Series series = new Series(); series.Channel = new Channel(); series.SeriesType = new SeriesType(); series.SourceIndexes = string.Empty; // Populate channel properties Channel channel = series.Channel; channel.Series = new List <Series>() { series }; channel.MeasurementType = new MeasurementType(); channel.MeasurementCharacteristic = new MeasurementCharacteristic(); channel.Phase = new openXDA.Model.Phase(); channel.Name = channelDefinition.ChannelName; channel.HarmonicGroup = 0; channel.Series.Add(series); if (seriesDefinition.HasElement(SeriesDefinition.SeriesNominalQuantityTag)) { channel.PerUnitValue = seriesDefinition.SeriesNominalQuantity; } // Populate measurement type properties QuantityMeasured quantityMeasured = channelDefinition.QuantityMeasured; channel.MeasurementType.Name = quantityMeasured.ToString(); // Populate characteristic properties Guid quantityTypeID = channelDefinition.QuantityTypeID; Guid quantityCharacteristicID = seriesDefinition.QuantityCharacteristicID; // Workaround for bad quantity characteristic in files produced by PQube Classic if (quantityTypeID == QuantityType.Phasor && quantityCharacteristicID == QuantityCharacteristic.Instantaneous) { quantityCharacteristicID = QuantityCharacteristic.RMS; } channel.MeasurementCharacteristic.Name = QuantityCharacteristic.ToName(quantityCharacteristicID) ?? quantityCharacteristicID.ToString(); channel.MeasurementCharacteristic.Description = QuantityCharacteristic.ToString(quantityCharacteristicID); // Popuplate phase properties Phase phase = channelDefinition.Phase; channel.Phase.Name = phase.ToString(); // Populate series type properties series.SeriesType.Name = SeriesValueType.ToString(seriesDefinition.ValueTypeID) ?? seriesDefinition.ValueTypeName ?? seriesDefinition.ValueTypeID.ToString(); series.SeriesType.Description = seriesDefinition.ValueTypeName; return(channel); }
internal static ChannelDefinition ToServiceModel(this ChannelDefinitionEntity dataObject) { ChannelDefinition serviceModel = new ChannelDefinition(); serviceModel.Id = dataObject.Id; serviceModel.IsEnabled = dataObject.IsEnabled; serviceModel.Name = new ChannelName(dataObject.Name, dataObject.Aliases); serviceModel.GroupId = dataObject.GroupId; serviceModel.LogoUrl = dataObject.LogoUrl; return(serviceModel); }
private void OnAddChannel(object sender, RoutedEventArgs e) { if (Data.Definitions.Count < 512) { ChannelDefinition def = new ChannelDefinition(); def.Channel = Convert.ToInt16(Data.Definitions.Count); Data.Definitions.Add(def); } else { MessageBox.Show("Maximum Channels defined already.", "DMX Commander", MessageBoxButton.OK, MessageBoxImage.Hand); } }
internal static ChannelDefinitionEntity ToDataObject(this ChannelDefinition serviceModel) { ChannelDefinitionEntity dataObject = new ChannelDefinitionEntity(); dataObject.Id = serviceModel.Id; dataObject.IsEnabled = serviceModel.IsEnabled; dataObject.Name = serviceModel.Name.Value; dataObject.GroupId = serviceModel.GroupId; dataObject.LogoUrl = serviceModel.LogoUrl; dataObject.Aliases = serviceModel.Name.Aliases.ToList(); return(dataObject); }
private ICollection <ChannelDefinition> SetupChannels() { var list = new List <ChannelDefinition>(); if (StreamRotationAsQuaternion) { string[] quatlabels = { "x", "y", "z", "w" }; foreach (var item in quatlabels) { var definition = new ChannelDefinition(); definition.label = item; definition.unit = "unit quaternion"; definition.type = "quaternion component"; list.Add(definition); } } if (StreamRotationAsEuler) { string[] eulerLabels = { "x", "y", "z" }; foreach (var item in eulerLabels) { var definition = new ChannelDefinition(); definition.label = item; definition.unit = "degree"; definition.type = "axis angle"; list.Add(definition); } } if (StreamPosition) { string[] eulerLabels = { "x", "y", "z" }; foreach (var item in eulerLabels) { var definition = new ChannelDefinition(); definition.label = item; definition.unit = "meter"; definition.type = "position in world space"; list.Add(definition); } } return(list); }
private static Channel ParseSeries(SeriesDefinition seriesDefinition) { ChannelDefinition channelDefinition = seriesDefinition.ChannelDefinition; QuantityMeasured quantityMeasured = channelDefinition.QuantityMeasured; Phase phase = channelDefinition.Phase; // Populate series properties Series series = new Series(); series.Channel = new Channel(); series.SeriesType = new SeriesType(); series.SourceIndexes = string.Empty; // Populate channel properties Channel channel = series.Channel; channel.Series = new List <Series>() { series }; channel.MeasurementType = new MeasurementType(); channel.MeasurementCharacteristic = new MeasurementCharacteristic(); channel.Phase = new openXDA.Model.Phase(); channel.Name = channelDefinition.ChannelName; channel.HarmonicGroup = 0; channel.Series.Add(series); if (seriesDefinition.HasElement(SeriesDefinition.SeriesNominalQuantityTag)) { channel.PerUnitValue = seriesDefinition.SeriesNominalQuantity; } // Populate measurement type properties channel.MeasurementType.Name = quantityMeasured.ToString(); // Populate characteristic properties channel.MeasurementCharacteristic.Name = QuantityCharacteristic.ToName(seriesDefinition.QuantityCharacteristicID) ?? seriesDefinition.QuantityCharacteristicID.ToString(); channel.MeasurementCharacteristic.Description = QuantityCharacteristic.ToString(seriesDefinition.QuantityCharacteristicID); // Popuplate phase properties channel.Phase.Name = phase.ToString(); // Populate series type properties series.SeriesType.Name = SeriesValueType.ToString(seriesDefinition.ValueTypeID) ?? seriesDefinition.ValueTypeName ?? seriesDefinition.ValueTypeID.ToString(); series.SeriesType.Description = seriesDefinition.ValueTypeName; return(channel); }
public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields() { IType expected = new ChannelDefinition { ChannelIdentifier = new ChannelIdentifier { IsSubcomponent = true, ChannelNumber = 1 }, WaveformSource = new WaveformSource { IsSubcomponent = true, SourceOneName = "2" }, ChannelSensitivityAndUnits = new ChannelSensitivityAndUnits { IsSubcomponent = true, ChannelSensitivity = 3 }, ChannelCalibrationParameters = new ChannelCalibrationParameters { IsSubcomponent = true, ChannelCalibrationSensitivityCorrectionFactor = 4 }, ChannelSamplingFrequency = 5, MinimumAndMaximumDataValues = new NumericRange { IsSubcomponent = true, LowValue = 6 } }; IType actual = new ChannelDefinition(); actual.FromDelimitedString("1^2^3^4^5^6"); expected.Should().BeEquivalentTo(actual); }
public AMFEndpoint(MessageBroker messageBroker, ChannelDefinition channelDefinition) : base(messageBroker, channelDefinition) { _waitingPollRequests = new AtomicInteger(); }
/// <summary> /// 将GEO文件转换为CIT文件 /// </summary> /// <param name="geoFile">GEO文件路径</param> /// <param name="citFile">CIT文件路径</param> /// <param name="citDataHeadInfo">cit头部信息</param> /// <returns>成功:true,失败:false</returns> public bool ConvertData(string geoFile, string citFile, FileInformation citDataHeadInfo) { try { int type = 1; //10号车通道对应表 if (citDataHeadInfo.sTrain.Contains("999307")) { type = 307;//iType=307时,geo转换有特殊情况 } int iPostion = 18; QueryDataChannelInfoHead(geoFile); string mileageRange = GetExportDataMileageRange(geoFile); mileageRange = mileageRange.Substring(2); float startMileage = float.Parse(mileageRange.Substring(0, mileageRange.IndexOf("-"))); float endMileage = float.Parse(mileageRange.Substring(mileageRange.IndexOf("-") + 1)); if (citDataHeadInfo.iKmInc == 0) { if (endMileage < startMileage) { float temp = startMileage; startMileage = endMileage; endMileage = temp; } } else { if (endMileage > startMileage) { float temp = startMileage; startMileage = endMileage; endMileage = temp; } } citDataHeadInfo.fkmFrom = startMileage; citDataHeadInfo.fkmTo = endMileage; using (FileStream fs = new FileStream(geoFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (BinaryReader br = new BinaryReader(fs, Encoding.Default)) { br.BaseStream.Position = 0; gfh = GetDataInfoHead(br.ReadBytes(GEO_FILE_HEADER_SIZE)); //添加通道信息 iChannelLength = BitConverter.ToInt16(br.ReadBytes(2), 0); iChannelCount = BitConverter.ToInt16(br.ReadBytes(2), 0); citDataHeadInfo.iChannelNumber = 2 + channelMappingList.Count; #region 通道定义 dciL = new List <DataChannelInfo>(); byte[] bChannelData = br.ReadBytes(iChannelLength - 2); //读取通道 for (int j = 0; j < iChannelLength - 2;) { DataChannelInfo dci = GetChannelInfo(bChannelData, ref j); dciL.Add(dci); if (dciL.Count > iChannelCount) { break; } if (type == 10) { if (dci.sNameEn.ToLower().Contains("null")) { break; } } } //通道匹配 int channelID = 2; List <int> listID = new List <int>(); List <ChannelDefinition> channelList = new List <ChannelDefinition>(); channelList.Add(new ChannelDefinition { sID = 1, sNameEn = "Km", sNameCh = "Km", fScale = 1.0f, fOffset = 0.0f, sUnit = "" }); channelList.Add(new ChannelDefinition { sID = 2, sNameEn = "Meter", sNameCh = "Meter", fScale = 4.0f, fOffset = 0.0f, sUnit = "" }); for (int i = 0; i < channelMappingList.Count; i++) { for (int j = 0; j < dciL.Count; j++) { if (dciL[j].sNameEn.Equals(channelMappingList[i].sGEO)) { listID.Add(j); ChannelDefinition channelInfoItem = new ChannelDefinition(); channelInfoItem.sID = channelID; channelInfoItem.sNameEn = channelMappingList[i].sCIT; channelInfoItem.sNameCh = channelMappingList[i].sChinese; channelInfoItem.fScale = dciL[j].fScale; channelInfoItem.fOffset = 0.0f; channelInfoItem.sUnit = dciL[j].sUnit; channelList.Add(channelInfoItem); ++channelID; break; } } } #endregion #region 通道数据 List <byte[]> bytes = GetChannelData(br, gfh, type, listID, iPostion); #endregion citHelper.WriteCitFile(citFile, citDataHeadInfo, channelList, "", bytes); br.Close(); } fs.Close(); } return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public EndpointBase(MessageBroker messageBroker, ChannelDefinition channelDefinition) { _messageBroker = messageBroker; _channelDefinition = channelDefinition; }
/// <summary> /// This method supports the Fluorine infrastructure and is not intended to be used directly from your code. /// </summary> /// <param name="configFolderPaths">Possible configuration file locations.</param> /// <param name="serviceBrowserAvailable">Indicates whether the service browser is avaliable.</param> public void Init(string[] configFolderPaths, bool serviceBrowserAvailable) { _messageBroker = new MessageBroker(this); string servicesConfigFile = null; for (int i = 0; i < configFolderPaths.Length; i++) { servicesConfigFile = Path.Combine(configFolderPaths[i], "services-config.xml"); if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.MessageServer_TryingServiceConfig, servicesConfigFile)); } if (File.Exists(servicesConfigFile)) { break; } } if (servicesConfigFile != null && File.Exists(servicesConfigFile)) { if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.MessageServer_LoadingServiceConfig, servicesConfigFile)); } _servicesConfiguration = ServicesConfiguration.Load(servicesConfigFile); } else { if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.MessageServer_LoadingConfigDefault)); } _servicesConfiguration = ServicesConfiguration.CreateDefault(); } foreach (ChannelDefinition channelDefinition in _servicesConfiguration.Channels) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(channelDefinition.Endpoint.Class)); if (type != null) { IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, channelDefinition }) as IEndpoint; if (endpoint != null) { _messageBroker.AddEndpoint(endpoint); } } else { log.Error(__Res.GetString(__Res.Type_InitError, channelDefinition.Class)); } } ChannelDefinition rtmptChannelDefinition = new ChannelDefinition(); rtmptChannelDefinition.Id = RtmptEndpoint.FluorineRtmptEndpointId; IEndpoint rtmptEndpoint = new RtmptEndpoint(_messageBroker, rtmptChannelDefinition); _messageBroker.AddEndpoint(rtmptEndpoint); if (_servicesConfiguration.Factories != null) { foreach (Factory factory in _servicesConfiguration.Factories) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(factory.Class)); if (type != null) { IFlexFactory flexFactory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory; if (flexFactory != null) { _messageBroker.AddFactory(factory.Id, flexFactory); } } else { log.Error(__Res.GetString(__Res.Type_InitError, factory.Class)); } } } //Add the dotnet Factory _messageBroker.AddFactory(DotNetFactory.Id, new DotNetFactory()); if (serviceBrowserAvailable) { ServiceDefinition serviceConfiguration = _servicesConfiguration.GetServiceByClass("flex.messaging.services.RemotingService"); if (serviceConfiguration != null) { AdapterDefinition adapter = serviceConfiguration.GetAdapterByClass(typeof(Remoting.RemotingAdapter).FullName); if (adapter != null) { InstallServiceBrowserDestinations(serviceConfiguration, adapter); } else { adapter = serviceConfiguration.GetDefaultAdapter(); if (adapter != null) { InstallServiceBrowserDestinations(serviceConfiguration, adapter); } } } } if (_servicesConfiguration.Services.ServiceDefinitions != null) { foreach (ServiceDefinition serviceDefinition in _servicesConfiguration.Services.ServiceDefinitions) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only if (type != null) { IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService; if (service != null) { _messageBroker.AddService(service); } } else { log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class)); } } } if (_servicesConfiguration.Services.Includes != null) { foreach (ServiceInclude include in _servicesConfiguration.Services.Includes) { ServiceDefinition serviceDefinition = include.ServiceDefinition; Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only if (type != null) { IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService; if (service != null) { _messageBroker.AddService(service); } } else { log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class)); } } } if (_servicesConfiguration.Security != null) { if (_servicesConfiguration.Security.LoginCommands != null && _servicesConfiguration.Security.LoginCommands.Length > 0) { LoginCommand loginCommand = _servicesConfiguration.Security.GetLoginCommand(LoginCommand.FluorineLoginCommand); if (loginCommand != null) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(loginCommand.Class)); if (type != null) { ILoginCommand loginCommandObj = ObjectFactory.CreateInstance(type, new object[] { }) as ILoginCommand; _messageBroker.LoginManager.LoginCommand = loginCommandObj; _messageBroker.LoginManager.IsPerClientAuthentication = loginCommand.IsPerClientAuthentication; } else { log.Error(__Res.GetString(__Res.Type_InitError, loginCommand.Class)); } } else { log.Error(__Res.GetString(__Res.Type_InitError, "<<LoginCommand class>>")); } } } InitAuthenticationService(); try { if (FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null && FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable) { IResource resource; if (FluorineContext.Current != null) { resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); } else { resource = new FileSystemResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); } if (resource.Exists) { log.Info(__Res.GetString(__Res.Silverlight_StartPS, resource.File.FullName)); _policyServer = new PolicyServer(resource.File.FullName); } else { throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); } } } catch (Exception ex) { log.Error(__Res.GetString(__Res.Silverlight_PSError), ex); } }
/// <summary> /// Adds a new channel definition to the collection /// of channel definitions in this data source record. /// </summary> public ChannelDefinition AddNewChannelDefinition() { CollectionElement channelDefinitionsElement = m_physicalRecord.Body.Collection.GetCollectionByTag(ChannelDefinitionsTag); CollectionElement channelDefinitionElement = new CollectionElement() { TagOfElement = OneChannelDefinitionTag }; ChannelDefinition channelDefinition = new ChannelDefinition(channelDefinitionElement, this); if ((object)channelDefinitionsElement == null) { channelDefinitionsElement = new CollectionElement() { TagOfElement = ChannelDefinitionsTag }; m_physicalRecord.Body.Collection.AddElement(channelDefinitionsElement); } channelDefinitionsElement.AddElement(channelDefinitionElement); return channelDefinition; }
public SecureAmfEndpoint(MessageBroker messageBroker, ChannelDefinition channelDefinition) : base(messageBroker, channelDefinition) { }
public StreamingAmfEndpoint(MessageBroker messageBroker, ChannelDefinition channelDefinition) : base(messageBroker, channelDefinition) { _streamingClientsCount = new AtomicInteger(); }
/// <summary> /// Removes the given channel definition from the collection of channel definitions. /// </summary> /// <param name="channelDefinition">The channel definition to be removed.</param> public void Remove(ChannelDefinition channelDefinition) { CollectionElement channelDefinitionsElement = m_physicalRecord.Body.Collection.GetCollectionByTag(ChannelDefinitionsTag); List<CollectionElement> channelDefinitionElements; ChannelDefinition definition; if ((object)channelDefinitionsElement == null) return; channelDefinitionElements = channelDefinitionsElement.GetElementsByTag(OneChannelDefinitionTag).Cast<CollectionElement>().ToList(); foreach (CollectionElement channelDefinitionElement in channelDefinitionElements) { definition = new ChannelDefinition(channelDefinitionElement, this); if (Equals(channelDefinition, definition)) channelDefinitionsElement.RemoveElement(channelDefinitionElement); } }
public RtmptEndpoint(MessageBroker messageBroker, ChannelDefinition channelDefinition) : base(messageBroker, channelDefinition) { }
/// <summary> /// 创建波形配置文件 /// </summary> /// <param name="sFileName">文件路径</param> /// <param name="iType"></param> /// <param name="dciL">通道定义集合</param> /// <returns>配置文件路径</returns> public static string CreateWaveXMLConfig(string sFileName, int sigleChannelHeight, int iType, List <ChannelDefinition> dciL) { string sDestFileName = ""; if (iType == 0) { if (Path.GetDirectoryName(sFileName).EndsWith("\\")) { sDestFileName = Path.GetDirectoryName(sFileName) + "默认配置文件.xml"; } else { sDestFileName = Path.GetDirectoryName(sFileName) + "\\" + "默认配置文件.xml"; } } else { sDestFileName = sFileName; } try { if (File.Exists(sDestFileName)) { File.Delete(sDestFileName); } if (dciL != null && dciL.Count > 0) { XmlDocument xmldoc = new XmlDocument(); XmlDeclaration xmldecl; xmldecl = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null); xmldoc.AppendChild(xmldecl); XmlElement xmlelem = xmldoc.CreateElement("", "app", ""); xmldoc.AppendChild(xmlelem); XmlNode root = xmldoc.SelectSingleNode("app"); XmlElement xmlelem1 = xmldoc.CreateElement("channels"); xmlelem1.SetAttribute("count", (dciL.Count - 2).ToString()); root.AppendChild(xmlelem1); XmlNode root1 = root.SelectSingleNode("channels"); int interLen = (100 / ((dciL.Count - 2 + 1))); int singleHeight = (channelTotalHeight / ((dciL.Count - 2 + 1))); for (int i = 2; i < dciL.Count; i++) { ChannelDefinition dci = dciL[i]; XmlElement xmlelem2 = xmldoc.CreateElement("channel"); xmlelem2.SetAttribute("id", dci.sID.ToString()); xmlelem2.SetAttribute("name", dci.sNameEn); xmlelem2.SetAttribute("non-chinese_name", dci.sNameEn); xmlelem2.SetAttribute("chinese_name", dci.sNameCh); xmlelem2.SetAttribute("color", GetRandomColor());//"ff0000b4" xmlelem2.SetAttribute("visible", "True"); if (dciL[i].sNameEn == "Superelevation" || dciL[i].sNameEn == "Speed") { xmlelem2.SetAttribute("zoomin", "20"); } else if (dciL[i].sNameEn == "LACC" || dciL[i].sNameEn == "VACC") { xmlelem2.SetAttribute("zoomin", "0.01"); } else { xmlelem2.SetAttribute("zoomin", "1"); } xmlelem2.SetAttribute("units", dci.sUnit); xmlelem2.SetAttribute("mea-offset", "False"); xmlelem2.SetAttribute("location", ((i - 1) * interLen + (i - 1)).ToString()); xmlelem2.SetAttribute("line_width", "1"); xmlelem2.SetAttribute("sigleHeight", singleHeight.ToString()); root1.AppendChild(xmlelem2); } xmldoc.Save(sDestFileName); } } catch (Exception ex) { throw ex; } return(sDestFileName); }