Пример #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);
     }
 }
Пример #2
0
        private void buttonChart_Click(object sender, EventArgs e)
        {
            ScopeViewControlChart chart = scopeViewControl2.NewChart();



            if (scopeViewControl2.Charts.Count == 0)
            {
                MessageBox.Show(this, "Please create a chart first!", "No chart connected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            else
            {
                AxisSettings(AbstandAxis, "Abstand");
                AxisSettings(ServoSpeedAxis, "Servospeed");
                AxisSettings(EncDistanzAxis, "Strecke");
                AxisSettings(LuftDruckAxis, "Luftdruck");
            }



            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, "This sample contains only one channel!", "Channel still connected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                ScopeViewControlChannel channel1 = scopeViewControl2.Charts[0].Axes[0].NewChannel();
                ChangeChannelSettings(channel1, Color.Red, Color.DarkRed);
                SetAcquisition(channel1, "Scope.Abstand");

                ScopeViewControlChannel channel2 = scopeViewControl2.Charts[0].Axes[1].NewChannel();
                ChangeChannelSettings(channel2, Color.Green, Color.DarkGreen);
                SetAcquisition(channel2, "Scope.ServoSpeed");
                ScopeViewControlChannel channel3 = scopeViewControl2.Charts[0].Axes[2].NewChannel();
                ChangeChannelSettings(channel3, Color.Orange, Color.DarkOrange);
                SetAcquisition(channel3, "Scope.EncDistanz");
                ScopeViewControlChannel channel4 = scopeViewControl2.Charts[0].Axes[3].NewChannel();
                ChangeChannelSettings(channel4, Color.Blue, Color.DarkBlue);
                SetAcquisition(channel4, "Scope.LuftDruck");
            }
        }
Пример #3
0
        private void buttonChannel_Click(object sender, EventArgs e)
        {
            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, "This sample contains only one channel!", "Channel still connected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                ScopeViewControlChannel channel1 = scopeViewControl2.Charts[0].Axes[0].NewChannel();
                ChangeChannelSettings(channel1, Color.Red, Color.DarkRed);
                SetAcquisition(channel1, "Scope.Abstand");

                ScopeViewControlChannel channel2 = scopeViewControl2.Charts[0].Axes[1].NewChannel();
                ChangeChannelSettings(channel2, Color.Green, Color.DarkGreen);
                SetAcquisition(channel2, "Scope.ServoSpeed");
                ScopeViewControlChannel channel3 = scopeViewControl2.Charts[0].Axes[2].NewChannel();
                ChangeChannelSettings(channel3, Color.Orange, Color.DarkOrange);
                SetAcquisition(channel3, "Scope.EncDistanz");
                ScopeViewControlChannel channel4 = scopeViewControl2.Charts[0].Axes[3].NewChannel();
                ChangeChannelSettings(channel4, Color.Blue, Color.DarkBlue);
                SetAcquisition(channel4, "Scope.LuftDruck");

                /*dataGridView1.Columns.Add(channel1.Acquisition.SymbolName, channel1.Acquisition.SymbolName);
                 * dataGridView1.Columns[channel1.Acquisition.SymbolName].DefaultCellStyle.ForeColor = channel1.Style.Color;
                 * dataGridView1.Columns.Add(channel2.Acquisition.SymbolName, channel2.Acquisition.SymbolName);
                 * dataGridView1.Columns[channel2.Acquisition.SymbolName].DefaultCellStyle.ForeColor = channel2.Style.Color;
                 * dataGridView1.Columns.Add(channel3.Acquisition.SymbolName, channel3.Acquisition.SymbolName);
                 * dataGridView1.Columns[channel3.Acquisition.SymbolName].DefaultCellStyle.ForeColor = channel3.Style.Color;
                 * dataGridView1.Columns.Add(channel4.Acquisition.SymbolName, channel4.Acquisition.SymbolName);
                 * dataGridView1.Columns[channel4.Acquisition.SymbolName].DefaultCellStyle.ForeColor = channel4.Style.Color;
                 */
            }
        }
Пример #4
0
 private void ChangeChannelSettings(ScopeViewControlChannel channel, Color colorLine, Color colorMark)
 {
     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
     {
         channel.Style.LineColor = colorLine;
         channel.Style.MarkColor = colorMark;
         channel.Style.LineWidth = 2;
     }
 }