/// <summary>
        /// Генерирование функционального текста для вставки
        /// </summary>
        /// <param name="isIOLink">Является ли модуль IO-Link</param>
        /// <returns>Функциональный текст</returns>
        private string GenerateFunctionalText(bool isIOLink)
        {
            const string PhoenixContact = "PXC";

            string functionalText = SelectedDevice.EPlanName + NewLine;

            if (string.IsNullOrEmpty(SelectedDevice.Description) == false)
            {
                functionalText += SelectedDevice.Description + NewLine;
            }
            if (string.IsNullOrEmpty(SelectedChannel.Comment) == false)
            {
                functionalText += SelectedChannel.Comment + NewLine;
            }

            int propertyNumber = (int)Eplan.EplApi.DataModel.Properties
                                 .Article.ARTICLE_MANUFACTURER;
            string manufacturer = GetSelectedIOModuleArticleProperty(
                propertyNumber);

            if (isIOLink == true &&
                manufacturer.Contains(PhoenixContact) &&
                SelectedDevice.Channels.Count > 1)
            {
                string channelType = SelectedChannel.GetChannelTypeForIOLink();
                functionalText += channelType;
            }

            return(functionalText);
        }
Example #2
0
        private void ChangeChannel()
        {
            SelectedNote = null;
            if (string.Equals(SelectedChannel, "All channels"))
            {
                channelId = 0;
            }
            else
            {
                try
                {
                    channelId = Int32.Parse(SelectedChannel.Split(' ')[1]);
                }
                catch (NullReferenceException ex)
                {
                    channelId = 0;
                }
            }
            ParsedNotes    = _midiEventsTextParser.GetNotesOfChannel(channelId);
            PresentedNotes = _midiEventsTextParser.NotesInChannel[channelId];

            currentlyPlayingDevice?.Dispose();
            if (playback != null)
            {
                PlaybackCurrentTimeWatcher.Instance.RemoveAllPlaybacks();
                PlaybackCurrentTimeWatcher.Instance.CurrentTimeChanged -= OnCurrentTimeChanged;
            }
            playback?.Dispose();

            currentlyPlayingDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth");
            if (channelId == 0)
            {
                playback = _dancerSong.Midi.GetPlayback(currentlyPlayingDevice);
            }
            else
            {
                playback = midiChannels.ToArray()[channelId - 1].GetPlayback(currentlyPlayingDevice);
            }
            PlaybackCurrentTimeWatcher.Instance.AddPlayback(playback, TimeSpanType.Midi);
            PlaybackCurrentTimeWatcher.Instance.CurrentTimeChanged += OnCurrentTimeChanged;
            OnPropertyChange("CurrentSongPlayTime");
            if (channelId == 0)
            {
                EventSystem.Publish <OnChannelChangeMessage>(
                    new OnChannelChangeMessage
                {
                    channelID = this.channelId
                });
            }
            else
            {
                EventSystem.Publish <OnChannelChangeMessage>(
                    new OnChannelChangeMessage
                {
                    channelID = this.channelId - 1
                });
            }
        }
        /// <summary>
        /// Привязать канал
        /// </summary>
        private void BindChannel()
        {
            if (SelectedIOModuleFunction == null)
            {
                return;
            }

            var regex = new Regex(IOModuleNamePattern);
            var match = regex.Match(SelectedIOModuleFunction.VisibleName);

            if (match.Success == false)
            {
                return;
            }

            int propertyNumber = (int)Eplan.EplApi.DataModel
                                 .Properties.Article.ARTICLE_TYPENR;
            string name = GetSelectedIOModuleArticleProperty(propertyNumber);

            var deviceNumber = Convert.ToInt32(match.Groups["n"].Value);
            var moduleNumber = deviceNumber % 100;
            int nodeNumber;
            var clampNumber = SelectedClampFunction.Properties
                              .FUNC_ADDITIONALIDENTIFYINGNAMEPART.ToInt();

            // Есть ли PXC A1 в проекте
            if (IOManager.GetInstance().IONodes[0].Type ==
                IONode.TYPES.T_PHOENIX_CONTACT_MAIN)
            {
                // Если есть "A1", то учитываем, что он первый
                nodeNumber = deviceNumber / 100;
            }
            else
            {
                // Если нету, оставляем как было
                nodeNumber = deviceNumber / 100 - 1;
            }

            var moduleInfo = new IOModuleInfo();

            moduleInfo = moduleInfo.GetIOModuleInfo(name, out _);
            var logicalPort = Array.IndexOf(moduleInfo.ChannelClamps,
                                            clampNumber) + 1;
            var moduleOffset = IOManager.GetInstance()
                               .IONodes[nodeNumber].
                               IOModules[moduleNumber - 1].InOffset;

            SelectedChannel.SetChannel(nodeNumber, moduleNumber,
                                       clampNumber, deviceNumber, logicalPort, moduleOffset);
        }
Example #4
0
        public async static Task <SelectedChannel> GetRequestSelectedChanel(int chanel, GetToken token)
        {
            string url = "https://demo.ratmon.com/api/Channel/Get" + "?id=" + chanel.ToString();

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Token);
                using (HttpResponseMessage response = await client.GetAsync(url))
                {
                    using (HttpContent content = response.Content)
                    {
                        string mycontent = await content.ReadAsStringAsync();

                        var             t = new SelectedChannel();
                        SelectedChannel selectedChannel = JsonConvert.DeserializeObject <SelectedChannel>(mycontent);
                        return(selectedChannel);
                    }
                }
            }
        }
 public void DecreaseChannel()
 {
     SelectedChannel = SelectedChannel.Previous();
 }
 public void IncreaseChannel()
 {
     SelectedChannel = SelectedChannel.Next();
 }
Example #7
0
 public SelectedChannelView(SelectedChannel ch)
 {
     this.ChannelId     = ch.ChannelId;
     this.Resistance    = ch.Resistance;
     this.ResThresholds = ch.ResThresholds;
 }