public static bool ConnectionServer(ChannelModel model) { //获取远程对象 var channelGroup = model.ChannelGroupType == "1" ? ChannelGroup.TCP : ChannelGroup.HTTP; string protocol = "tcp"; if (channelGroup == ChannelGroup.HTTP) protocol = "http"; string uri = GetServerUrl(protocol, model); try { ChannelClass.StartChannel(channelGroup, model.ChannelName); _iHiCoordinator = Activator.GetObject(typeof(IHiCoordinator), uri) as IHiCoordinator; _wrapper = new EventWrapper(); _wrapper.Server2ClientEvent += GetServerMessage; if (_iHiCoordinator != null) _iHiCoordinator.Server2ClientEvent += _wrapper.OnServer2ClientEvent; ChannelDetail = model; string clientName = ChannelClass.GetMyHostName(); if (_iHiCoordinator != null) _iHiCoordinator.IClient2Server(clientName + "成功连接服务"); return true; } catch (Exception ex) { MsgBox.ShowInformation("启动服务失败:" + ex.Message + "\n\n" + uri); return false; } }
public float GetFastFadingdB(ISimCellBase carrier, ISimUser user, LinkType type) { float speed = user.TrafficUser.Mobility.MeanSpeed; float frequency = (float)(carrier.Cell.FreqBand.DLFrequency * 1e6); //ChannelTypeManage CTManage = new ChannelTypeManage(); //CTManage.GetChannelTypeInfo(); ChannelType CT = m_CTManage.SpeedChannelDic[speed]; ChannelModel CM = new ChannelModel(CT.ChannelPath, speed, frequency); CalcFastFading calc = new CalcFastFading(10); return calc.GetFastFadingdB(CM, m_TimeSpan); }
public static WebSocketChannelUpdateModel FromChannelModel(ChannelModel channel) { bool hasActiveStream = (channel.ActiveStreams.Count() > 0); int activeStreamId = hasActiveStream ? channel.ActiveStreams.First().Id : -1; return(new WebSocketChannelUpdateModel() { ChannelId = channel.Id, ChannelName = channel.Name, HasActiveStream = hasActiveStream, ActiveStreamId = activeStreamId, }); }
internal override void Update(ChannelModel model) { Recipients = new ReadOnlyDictionary <Snowflake, RestUser>(model.Recipients.Value.ToDictionary(x => new Snowflake(x.Id), x => new RestUser(Client, x))); IconHash = model.Icon.Value; OwnerId = model.OwnerId.Value; if (!model.Name.HasValue || string.IsNullOrWhiteSpace(model.Name.Value)) { model.Name = string.Join(", ", Recipients.Values); } base.Update(model); }
private InteractiveClient(ChannelModel channel, InteractiveGameListingModel interactiveGame, OAuthTokenModel authToken, IEnumerable <string> interactiveConnections) { Validator.ValidateVariable(channel, "channel"); Validator.ValidateVariable(interactiveGame, "interactiveGame"); Validator.ValidateVariable(authToken, "authToken"); Validator.ValidateList(interactiveConnections, "interactiveConnections"); this.Channel = channel; this.InteractiveGame = interactiveGame; this.interactiveConnections = interactiveConnections; this.oauthAccessToken = authToken.accessToken; }
public void GetChannelByID() { TestWrapper(async(TwitchConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetCurrentChannel(connection); ChannelModel result = await connection.V5API.Channels.GetChannelByID(channel.id); Assert.IsNotNull(result); Assert.IsNotNull(result.id); Assert.AreEqual(channel.id, result.id); }); }
public void GetChannelUserSubscription() { TestWrapper(async(TwitchConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetCurrentChannel(connection); UserModel user = await connection.V5API.Users.GetCurrentUser(); UserSubscriptionModel result = await connection.V5API.Channels.GetChannelUserSubscription(channel, user); Assert.IsNotNull(result); }); }
/// <summary> /// Attempts to follow the given channel for a specific user. /// </summary> /// <param name="channel">The channel to follow</param> /// <param name="user">The user trying to follow</param> /// <returns>True if successful</returns> public async Task <bool> Follow(ChannelModel channel, UserModel user) { string uri = $"channels/{channel.id}/follow"; JObject payload = new JObject(); payload["user"] = user.id; HttpResponseMessage response = await this.PostAsync(uri, this.CreateContentFromObject(payload)); return(response.IsSuccessStatusCode); }
public AddChannelPage(ChannelModel channel) { InitializeComponent(); On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true); viewModel = new AddChannelViewModel(); BindingContext = viewModel; titleLabel.Text = channel != null ? "Редактирование" : "Добавить канал"; viewModel.IsEditing = channel != null; viewModel.Channel = channel != null ? channel : new ChannelModel(); }
public ActionResult Create() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageChannel)) { return(AccessDeniedView()); } var model = new ChannelModel(); PrepareChannelModel(model, null, true); //templates PrepareTemplatesModel(model); return(View(model)); }
/// <summary> /// Creates a Discord invite for the specified channel and user. /// </summary> /// <param name="channel">The channel to generate a Discord invite for</param> /// <param name="user">The user to generate a Discord invite for</param> /// <returns>The generated invite</returns> public async Task <string> GetUserDiscordInvite(ChannelModel channel, UserModel user) { Validator.ValidateVariable(channel, "channel"); JObject jobj = await this.GetJObjectAsync("channels/" + channel.id + "/discord/roles?user="******"redirectUri", out invite)) { return(invite.ToString()); } return(null); }
private static AdaptiveColumnSet FormatScheduleData(ChannelModel channel) { var days = new AdaptiveColumn(); days.Items.Add(new AdaptiveTextBlock { Text = $"Day of Week", HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Weight = AdaptiveTextWeight.Bolder, }); days.Items.AddRange(channel.Schedule.Select(day => new AdaptiveTextBlock { Text = $"{day.DayOfWeek}", })); var from = new AdaptiveColumn(); from.Items.Add(new AdaptiveTextBlock { Text = $"From", HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Weight = AdaptiveTextWeight.Bolder, }); from.Items.AddRange(channel.Schedule.Select(day => new AdaptiveTextBlock { Text = $"{day.LocalStartTime}", })); var to = new AdaptiveColumn(); to.Items.Add(new AdaptiveTextBlock { Text = $"To", HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Weight = AdaptiveTextWeight.Bolder, }); to.Items.AddRange(channel.Schedule.Select(day => new AdaptiveTextBlock { Text = $"{day.LocalEndTime}", })); var schedule = new AdaptiveColumnSet(); schedule.Columns.AddRange(new List <AdaptiveColumn> { days, from, to }); return(schedule); }
public static async Task <bool> JoinChannel(string _channelName, MainWindow mainWindow) { string Port = await ChannelModel.SendJoinRequestAsync(_channelName); if (Port == null) { return(false); } Client.Port = Convert.ToInt32(Port); try { Client.voiceClient = new VoiceClient(); Client.voiceClient.Connect("192.168.1.112", Client.Port); Client.hubProxy = Client.hubConnection.CreateHubProxy("ChatHub"); await Client.hubConnection.Start(); Client.ChannelMemberList = new Dictionary <string, byte[]>(); Client.hubProxy.On <Dictionary <string, byte[]> >("LoadData", members => { mainWindow.Dispatcher.Invoke(() => { Client.ChannelMemberList = members; mainWindow.ChannelMemberList = new Dictionary <string, ImageBrush>(); foreach (var member in Client.ChannelMemberList) { mainWindow.ChannelMemberList.Add(member.Key, mainWindow.FillImage(member.Value)); } mainWindow.MemberList.ItemsSource = mainWindow.ChannelMemberList; mainWindow.MemberList.Items.Refresh(); }); }); await Client.hubProxy.Invoke("JoinChannel", _channelName, Client.Name); mainWindow.ChannelName.Content = _channelName; } catch (SocketException) { return(false); } if (!Client.RecentlyVisitedChannels.Contains(_channelName)) { Client.RecentlyVisitedChannels.Add(_channelName); mainWindow.RecentlyVisitedRooms.Items.Refresh(); } DirectHelper.OnBufferFulfill += new EventHandler(Client.voiceClient.SendVoiceBuffer); return(true); }
internal override void Update(ChannelModel model) { if (model.LastMessageId.HasValue) { LastMessageId = model.LastMessageId.Value; } if (model.LastPinTimestamp.HasValue) { LastPinTimestamp = model.LastPinTimestamp.Value; } base.Update(model); }
//Channel main page public IActionResult Main(string id) { if (id == null) { return(NotFound()); } var channel = _service.GetChannel(id).Result; if (channel == null) { return(NotFound()); } ViewData["public"] = _service.CheckIfPublic(channel); ViewData["owner"] = false; var user = _userManager.GetUserAsync(User).Result; if (user != null) { var channelMember = _service.GetChannelMember(user, channel).Result; //Check if the user is a channel member if (channelMember == null) { ViewData["member"] = false; } else { ViewData["member"] = true; } if (channel.CreatorId == user.Id) { ViewData["owner"] = true; } } var albums = _albumService.GetAlbumModels(channel); //List of all channel albums var members = _service.GetChannelMembers(channel); //List of all channel members var creator = _userManager.FindByIdAsync(channel.CreatorId).Result; //Channel creator var tags = _service.GetChannelTags(channel); //List of all channel tags var channelModel = new ChannelModel { Id = channel.Id, Title = channel.Title, Description = channel.Description, Creator = creator, CreationDate = channel.CreationDate, Albums = albums, ChannelMembers = members, Tags = tags }; return(View(channelModel)); }
public static async Task <ChannelModel> GetChannel(MixerConnection connection) { UserModel user = await connection.Users.GetCurrentUser(); Assert.IsNotNull(user); Assert.IsTrue(user.id > (uint)0); ChannelModel channel = await connection.Channels.GetChannel(user.username); Assert.IsNotNull(channel); Assert.IsTrue(channel.id > (uint)0); return(channel); }
private static string FormatNextStream(ChannelModel channel) { if (channel.NextStream.UtcStartTime.Date == DateTime.UtcNow.Date) { return($"will be streaming next **today** at {channel.NextStream.LocalStartTime:h:mm tt}"); } else if (channel.NextStream.UtcStartTime.Date == DateTime.UtcNow.Date.AddDays(1)) { return($"will be streaming next **tomorrow** at {channel.NextStream.LocalStartTime:h:mm tt}"); } return(string.Format("will be streaming next on {0:dddd, MMMM dd} at {0:h:mm tt}", channel.NextStream.LocalStartTime, channel.NextStream.LocalStartTime)); }
public static void UpdateChannel(ChannelModel channel) { //var query = Query.EQ("_id", channel.Id); //var update = Update<ChannelModel>.Set(e => e.Description, channel.Description); //update.Set(u => u.Name, channel.Name); //update.Set(u => u.CateId, channel.CateId); //update.Set(u => u.Status, channel.Status); //update.Set(u => u.Image, channel.Image); //update.Set(u => u.CreateTime, channel.CreateTime); //update.Set(u => u.UpdateTime, DateTime.Now); //Collection.Update(query, update); }
public async Task <IActionResult> Create([Bind("Id,ChannelName,ServerModelId")] ChannelModel channel) { if (ModelState.IsValid) { _context.Add(channel); var server = _context.Servers.Find(channel.ServerModelId); server.Channels.Add(channel); _context.Update(server); await _context.SaveChangesAsync(); return(RedirectToAction("Edit", "Servers", new { Id = channel.ServerModelId })); } return(View(channel)); }
public void GetChannelChatBadges() { TestWrapper(async(TwitchConnection connection) => { UserModel user = await connection.V5API.Users.GetUserByLogin("Ninja"); ChannelModel channel = await connection.V5API.Channels.GetChannelByID(user.id); ChannelChatBadgesModel result = await connection.V5API.Chat.GetChannelChatBadges(channel); Assert.IsNotNull(result); Assert.IsNotNull(result.subscriber); }); }
internal override void Update(ChannelModel model) { if (model.Bitrate.HasValue) { Bitrate = model.Bitrate.Value; } if (model.UserLimit.HasValue) { MemberLimit = model.UserLimit.Value; } base.Update(model); }
public void GetChannelByID() { TestWrapper(async(GlimeshConnection connection) => { string channelID = "6343"; ChannelModel channel = await connection.Channel.GetChannelByID(channelID); Assert.IsNotNull(channel); Assert.IsTrue(!string.IsNullOrEmpty(channel.id)); Assert.IsTrue(!string.IsNullOrEmpty(channel.status)); Assert.IsTrue(string.Equals(channelID, channel.id)); }); }
public static void ClassInitialize(TestContext context) { TestWrapper(async(MixerConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection); testGameListing = await InteractiveServiceUnitTests.CreateTestGame(connection, channel); interactiveClient = await InteractiveClient.CreateFromChannel(connection, channel, testGameListing); Assert.IsTrue(await interactiveClient.Connect()); Assert.IsTrue(await interactiveClient.Ready()); }); }
internal override void Update(ChannelModel model) { if (model.Position.HasValue) { Position = model.Position.Value; } if (model.PermissionOverwrites.HasValue) { Overwrites = model.PermissionOverwrites.Value.Select(x => new CachedOverwrite(Client, x, this)).ToImmutableArray(); } base.Update(model); }
internal override void Update(ChannelModel model) { if (model.Position.HasValue) { Position = model.Position.Value; } if (model.PermissionOverwrites.HasValue) { Overwrites = model.PermissionOverwrites.Value.ToReadOnlyList( this, (x, @this) => new CachedOverwrite(@this, x)); } base.Update(model); }
public IActionResult ChannelsList() { var channelModels = new List <ChannelModel>(); var ChannelList = dropdownObj.GetChannels(); foreach (var item in ChannelList) { var model = new ChannelModel() { Name = item.Text }; channelModels.Add(model); } return(View(channelModels)); }
public void GetChannelEmoticons() { TestWrapper(async(MixerConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection); UserModel user = await connection.Users.GetCurrentUser(); Assert.IsNotNull(user); Assert.IsTrue(user.id > (uint)0); IEnumerable <EmoticonPackModel> emoticonPacks = await connection.Channels.GetEmoticons(channel, user); Assert.IsNotNull(emoticonPacks); }); }
public void FollowChannel() { TestWrapper(async(TwitchConnection connection) => { UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection); ChannelModel channel = await connection.V5API.Channels.GetCurrentChannel(); UserFollowModel result = await connection.V5API.Users.FollowChannel(user, channel); Assert.IsNotNull(result); Assert.IsNotNull(result.user); Assert.IsNotNull(result.user.id); }); }
public void UpdateChannel() { TestWrapper(async(MixerConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection); string newName = "Test Name"; channel.name = newName; channel = await connection.Channels.UpdateChannel(channel); Assert.IsNotNull(channel); Assert.IsTrue(string.Equals(channel.name, newName)); }); }
public void GetChannelRecordings() { TestWrapper(async(MixerConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection); Assert.IsNotNull(channel); Assert.IsTrue(channel.id > (uint)0); IEnumerable <ChannelRecordingModel> recordings = await connection.Channels.GetRecordings(channel); Assert.IsNotNull(recordings); Assert.IsTrue(recordings.Count() > 0); }); }
public void GetChannelBroadcast() { TestWrapper(async(MixerConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection); Assert.IsNotNull(channel); Assert.IsTrue(channel.id > (uint)0); BroadcastModel broadcast = await connection.Channels.GetCurrentBroadcast(channel); Assert.IsNotNull(broadcast); Assert.AreEqual(channel.id, broadcast.channelId); }); }
public void LiveSubscribeAndUnsubscribe() { this.ConstellationWrapper(async(MixerConnection connection, ConstellationClient constellationClient) => { ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection); this.ClearPackets(); ConstellationEventType eventType = new ConstellationEventType(ConstellationEventTypeEnum.channel__id__update, channel.id); Assert.IsTrue(await constellationClient.SubscribeToEventsWithResponse(new List <ConstellationEventType>() { eventType })); this.ClearPackets(); bool eventReceived = false; constellationClient.OnSubscribedEventOccurred += (sender, le) => { if (le.channel.Equals(eventType.ToString())) { eventReceived = true; } }; string newName = "Test Name - " + DateTimeOffset.Now; channel.name = newName; channel = await connection.Channels.UpdateChannel(channel); Assert.IsNotNull(channel); Assert.IsTrue(string.Equals(channel.name, newName)); this.ClearPackets(); await Task.Delay(5000); if (!eventReceived) { Assert.Fail("Did not get live event for channel updating"); } Assert.IsTrue(await constellationClient.UnsubscribeToEventsWithResponse(new List <ConstellationEventType>() { eventType })); }); }
private static void ClearChannel(ChannelModel channel) { foreach (var item in channel.Messages) item.Dispose(); foreach (var item in channel.Ads) item.Dispose(); channel.Messages.Clear(); channel.Ads.Clear(); }
private float CalcParamArray(ChannelModel channelType) { float fadeLinear = 0f; float Bn = 0f, Cn = 0f, Dp = 0f, Xc = 0f, Xs = 0f; int k = 0, index = 0; foreach (KeyValuePair<float, float> timePower in channelType.Paths) { float fp = CalcOneParam(channelType, ref Bn, ref Cn, ref Dp, ref Xc, ref Xs, ref k, ref index); fadeLinear = fadeLinear + timePower.Value * fp; } return fadeLinear; }
private float CalcOneParam(ChannelModel channelType, ref float Bn, ref float Cn, ref float Dp, ref float Xc, ref float Xs, ref int k, ref int index) { Xc = 0f; Xs = 0f; //int n; for (int n = 1; n < channelType.OscillatorM[k] + 1; n++) { CalcOneParamProperty(channelType, ref Bn, ref Cn, ref Xc, ref Xs, k, ref index, n); } return UpdateParam(channelType, ref Dp, ref Xc, ref Xs, ref k, ref index); //return fp; }
private void CalcOneParamProperty(ChannelModel channelType, ref float Bn, ref float Cn, ref float Xc, ref float Xs, int k, ref int index, int n) { Bn = n * (float)Math.PI / channelType.OscillatorM[k]; Cn = m_ParamCosList[index] * m_RandomCosPhaseArray[m_RandomPhaseIndex] - m_ParamSinList[index] * m_RandomSinPhaseArray[m_RandomPhaseIndex]; Xc = Xc + 2 * (float)(Math.Cos(Bn) * Cn); Xs = Xs + 2 * (float)(Math.Sin(Bn) * Cn);//how ? m_RandomPhaseIndex++; ResetPhaseIndex(); index++; }
private static void ClearChannel(ChannelModel channel) { channel.Messages.Clear(); channel.Ads.Clear(); }
protected override void Dispose(bool isManaged) { if (isManaged) { PropertyChanged -= OnThisPropertyChanged; Model.PropertyChanged -= OnModelPropertyChanged; Events.GetEvent<ConnectionClosedEvent>().Unsubscribe(OnDisconnect); model = null; } base.Dispose(isManaged); }
public static void NewChannelUpdate(this IEventAggregator events, ChannelModel channel, ChannelUpdateEventArgs e) => events.NewUpdate(new ChannelUpdateModel(channel, e));
private void RequestNavigate(string channelId) { automation.UserDidAction(); Log("Requested " + channelId); var wantsNoteView = false; var wantsProfileView = false; if (channelId.EndsWith("/notes")) { channelId = channelId.Substring(0, channelId.Length - "/notes".Length); wantsNoteView = true; } if (channelId.EndsWith("/profile")) { channelId = channelId.Substring(0, channelId.Length - "/profile".Length); wantsProfileView = true; } if (lastSelected != null) { if (lastSelected.Id.Equals(channelId, StringComparison.OrdinalIgnoreCase)) return; Dispatcher.Invoke(() => { var toUpdate = cm.CurrentChannels.FirstByIdOrNull(lastSelected.Id) ?? (ChannelModel) cm.CurrentPms.FirstByIdOrNull(lastSelected.Id); if (toUpdate == null) lastSelected = null; else toUpdate.IsSelected = false; }); } var channelModel = cm.CurrentChannels.FirstByIdOrNull(channelId) ?? (ChannelModel) cm.CurrentPms.FirstByIdOrNull(channelId); if (channelModel == null) throw new ArgumentOutOfRangeException(nameof(channelId), "Cannot navigate to unknown channel"); var pmChannelModel = channelModel as PmChannelModel; if (pmChannelModel != null) { pmChannelModel.ShouldViewNotes = wantsNoteView || pmChannelModel.ShouldViewNotes; pmChannelModel.ShouldViewProfile = wantsProfileView || pmChannelModel.ShouldViewProfile; } channelModel.IsSelected = true; cm.CurrentChannel = channelModel; if (!channelModel.Messages.Any() && !channelModel.Ads.Any()) { var history = new RawChannelLogModel(); if (!channelId.Equals("Home")) history = logger.GetLogs(channelModel.Title, channelModel.Id); if (history.RawLogs.Any()) { Dispatcher.Invoke(() => history.RawLogs .Select(item => new MessageModel(item, characters.Find, history.DateOfLog)) .Each(item => channelModel.AddMessage(item) )); } } Log("Requesting " + channelModel.Id + " channel view"); Dispatcher.Invoke(() => { foreach (var r in region.Regions[ChatWrapperView.ConversationRegion].Views) { var view = r as DisposableView; if (view != null) { var toDispose = view; toDispose.Dispose(); region.Regions[ChatWrapperView.ConversationRegion].Remove(toDispose); } else region.Regions[ChatWrapperView.ConversationRegion].Remove(r); } region.Regions[ChatWrapperView.ConversationRegion].RequestNavigate( StringExtensions.EscapeSpaces(channelModel.Id)); }); lastSelected = channelModel; }
///// <summary> ///// !!! ///// </summary> ///// <param name="datafilepath"></param> //public static void InitialData(string datafilepath) //{ // StreamReader sr = new StreamReader(datafilepath); // uint length = 0; // while (!sr.EndOfStream) // { // string currentLine = sr.ReadLine(); // length++; // } // length /= 2; // sr = new StreamReader(datafilepath); // m_RandomCosPhaseArray = new float[length]; // m_RandomSinPhaseArray = new float[length]; // string currentVale; // for (uint i = 0; i < length; i++) // { // currentVale = sr.ReadLine(); // m_RandomCosPhaseArray[i] = Convert.ToSingle(currentVale); // currentVale = sr.ReadLine(); // m_RandomSinPhaseArray[i] = Convert.ToSingle(currentVale); // } // sr.Close(); // paramsList = new Dictionary<string, FadingParamStruct>(); //} /// <summary> /// 根据信道条件及时间给出快衰落的dB值,时间t的单位是秒 /// </summary> /// <param name="channelType">信道类型</param> /// <param name="t">时间</param> /// <returns>快衰值(dB)</returns> public float GetFastFadingdB(ChannelModel channelType, float t) { //if (paramsList == null) // return 0;//no sense PreLoadParamArray(channelType, t); float fadeLinear = CalcParamArray(channelType); return Convert.ToSingle(UnitTrans.mwTodBm((double)fadeLinear));//CommonCalcMethod.ConvertLinearityToDB(fadeLinear); }
private void AddParam(ChannelModel channelType, float t) { float An = 0f, Wn = 0f; int k = 0; foreach (KeyValuePair<float, float> timePower in channelType.Paths) { CalcCosSinParam(channelType, t, ref An, ref Wn, ref k, timePower); } AddParam(channelType); }
private void CalcCosSinParam(ChannelModel channelType, float t, ref float An, ref float Wn, ref int k, KeyValuePair<float, float> timePower) { for (int n = 1; n < channelType.OscillatorM[k] + 1; n++) { An = 2 * (float)Math.PI * n / channelType.OscillatorN[k]; Wn = channelType.Wm * (float)Math.Cos(An); m_ParamCosList.Add((float)(Math.Cos(Wn * (t + timePower.Key * 1e-9)))); m_ParamSinList.Add((float)(Math.Sin(Wn * (t + timePower.Key * 1e-9)))); } m_ParamCosList.Add((float)(Math.Cos(channelType.Wm * (t + timePower.Key * 1e-9)))); m_ParamSinList.Add((float)(Math.Sin(channelType.Wm * (t + timePower.Key * 1e-9)))); k++; }
private void ReadParam(ChannelModel channelType) { string index = channelType.Index.ToString() + " " + channelType.Frequency.ToString(); FadingParamStruct fstruct = m_ParamsList[index]; m_ParamCosList = fstruct.paramCosList; m_ParamSinList = fstruct.paramSinList; }
private void AddParam(ChannelModel channelType) { string index = channelType.Index.ToString() + " " + channelType.Frequency.ToString(); FadingParamStruct fstruct = new FadingParamStruct(); fstruct.paramCosList = m_ParamCosList; fstruct.paramSinList = m_ParamSinList; m_ParamsList.Add(index, fstruct); }
private static string GetServerUrl(string protocol, ChannelModel model) { return string.Format("{0}://{1}:{2}/{3}", protocol, model.Ip, model.Port, model.CoordinatorName); }
private void RequestNavigate(string channelId) { automation.UserDidAction(); if (lastSelected != null) { if (lastSelected.Id.Equals(channelId, StringComparison.OrdinalIgnoreCase)) return; Dispatcher.Invoke( (Action) delegate { var toUpdate = model.CurrentChannels.FirstByIdOrNull(lastSelected.Id) ?? (ChannelModel) model.CurrentPms.FirstByIdOrNull(lastSelected.Id); if (toUpdate == null) lastSelected = null; else toUpdate.IsSelected = false; }); } var channelModel = model.CurrentChannels.FirstByIdOrNull(channelId) ?? (ChannelModel) model.CurrentPms.FirstByIdOrNull(channelId); if (channelModel == null) throw new ArgumentOutOfRangeException("channelId", "Cannot navigate to unknown channel"); channelModel.IsSelected = true; model.CurrentChannel = channelModel; Dispatcher.Invoke( (Action) delegate { foreach (var r in region.Regions[ChatWrapperView.ConversationRegion].Views) { var view = r as DisposableView; if (view != null) { var toDispose = view; toDispose.Dispose(); region.Regions[ChatWrapperView.ConversationRegion].Remove(toDispose); } else region.Regions[ChatWrapperView.ConversationRegion].Remove(r); } region.Regions[ChatWrapperView.ConversationRegion].RequestNavigate( HelperConverter.EscapeSpaces(channelModel.Id)); }); lastSelected = channelModel; }
protected override void Dispose(bool isManaged) { if (isManaged) { PropertyChanged -= OnThisPropertyChanged; Model.PropertyChanged -= OnModelPropertyChanged; model = null; } base.Dispose(isManaged); }
private bool IsExistParam(ChannelModel channelType) { string index = channelType.Index.ToString() + " " + channelType.Frequency.ToString(); return m_ParamsList.ContainsKey(index); }
/// <summary> /// 预先加载参数数组 /// </summary> /// <param name="channelType"></param> /// <param name="t"></param> private void PreLoadParamArray(ChannelModel channelType, float t) { SetLastTime(t); if (IsExistParam(channelType)) { ReadParam(channelType); return; } AddParam(channelType, t); }
private float UpdateParam(ChannelModel channelType, ref float Dp, ref float Xc, ref float Xs, ref int k, ref int index) { Dp = m_ParamCosList[index] * m_RandomCosPhaseArray[m_RandomPhaseIndex] - m_ParamSinList[index] * m_RandomSinPhaseArray[m_RandomPhaseIndex]; Xc = Xc + Dp; Xs = Xs + Dp; m_RandomPhaseIndex++; ResetPhaseIndex(); index++; float fp = (Xc * Xc + Xs * Xs) / channelType.OscillatorN[k] * 2; k++; return fp; }
internal Inline MakeChannelLink(ChannelModel channel) { return MakeInlineContainer(channel, "ChannelTemplate"); }
/// <summary> /// Makes a channel link. /// </summary> internal Inline MakeChannelLink(ChannelModel channel) { var toReturn = new InlineUIContainer { Child = new ContentControl { ContentTemplate = Locator.Find<DataTemplate>("ChannelTemplate"), Content = channel }, BaselineAlignment = BaselineAlignment.TextBottom }; return toReturn; }