Exemple #1
0
 private void SetAcquisition(ScopeViewControlChannel channel, string Symbolname)
 {
     if (scopeViewControl2.Charts.Count == 0)
     {
         MessageBox.Show(this, "Please create a chart first!", "No chart connected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (scopeViewControl2.Charts[0].Axes.Count == 0)
     {
         MessageBox.Show(this, "Please create an YAxis first!", "No axis connected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (scopeViewControl2.Charts[0].Axes[0].Channels.Count == 0)
     {
         MessageBox.Show(this, "Please create a Channel first!", "No channel connected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         // AmsNetId und AmsPort benötigen die TwinCAT.Ads.dll
         channel.Acquisition.AmsNetId      = AmsNetId.Parse("192.168.0.2.1.1");
         channel.Acquisition.TargetPort    = 851;
         channel.Acquisition.IsSymbolBased = true;
         channel.Acquisition.SymbolName    = Symbolname;
         channel.Acquisition.DataType      = DataTypeConverter.AdsToScope2Datatype(AdsDatatypeId.ADST_REAL64);
         channel.Acquisition.SampleTime    = (uint)(1 * TimeSpan.TicksPerMillisecond);
     }
 }
Exemple #2
0
        private void button_Load_Click(object sender, EventArgs e)
        {
            string filename = "";

            openFileDialog1.FileName    = "";
            openFileDialog1.FilterIndex = 3;
            openFileDialog1.Filter      = "CSV Files (*.csv)|*.csv|Scope Files(*.sv2)|*.sv2|Scope Files(*.svd)|*.svd|Scope Files(*.tcscope)|*.tcscope|All files (*.*)|*.*";
            openFileDialog1.Title       = "Scope Files hunterladen";

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                filename = openFileDialog1.FileName;

                FileInfo finfo = new FileInfo(filename);
                if (!finfo.Exists)
                {
                    MessageBox.Show(this, "File not found! Please use the 'Add Chart' buttons to create a config.\r\nOnce a config is created and saved it can be load using the 'Load' -Button!", "File not found!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    // alte Konfiguration löschen
                    while (scopeViewControl2.Charts.Count > 0)
                    {
                        scopeViewControl2.DeleteChart(scopeViewControl2.Charts[0]);
                    }

                    // Konfiguration laden
                    scopeViewControl2.LoadScopeConfig(filename);

                    foreach (ScopeViewControlChannel channel in scopeViewControl2.ConnectedChannels)
                    {
                        channel.Acquisition.AmsNetId   = AmsNetId.Parse("192.168.0.2.1.1");
                        channel.Acquisition.TargetPort = 851;
                        //dataGridView1.Columns.Add(channel.Acquisition.SymbolName, channel.Acquisition.SymbolName);
                        //dataGridView1.Columns[channel.Acquisition.SymbolName].DefaultCellStyle.ForeColor = channel.Style.Color;
                    }
                }
            }
        }
Exemple #3
0
 public bool TryAddRoute(RouteSetting route)
 {
     return(amsTcpIpRouter.TryAddRoute(new Route(route.Name, AmsNetId.Parse(route.AmsNetId), route.IpAddress)));
 }
 public Option <string> GetHostname(AmsNetId amsNetId)
 {
     return(_cachedHostnames.GetOrAdd(amsNetId.ToString(), x => QueryHostname(AmsNetId.Parse(x)).SomeNotNull()));
 }