- 最後登錄
- 2024-5-19
- 在線時間
- 0 小時
- 註冊時間
- 2007-11-11
- 閱讀權限
- 20
- 精華
- 0
- UID
- 2758227
- 帖子
- 277
- 積分
- 194 點
- 潛水值
- 29497 米
| 分享使你變得更實在,可以使其他人感到快樂,分享是我們的動力。今天就來分享你的資訊、圖片或檔案吧。 本帖最後由 b06003740095 於 2011-2-27 04:11 PM 編輯
就是我想要用C#的Windows Form做一個 可以呼叫 labview的程式labview的主要是擷取X光的攝影機所拍到的醫學影像,我需要把影像
CALL進去c#裡面,不知道該怎麼做
- public Form1()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- }
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.OpenLV = new System.Windows.Forms.Button();
- this.RunVI = new System.Windows.Forms.Button();
- this.QuitLV = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.SuspendLayout();
- //
- // OpenLV
- //
- this.OpenLV.Location = new System.Drawing.Point(16, 24);
- this.OpenLV.Name = "OpenLV";
- this.OpenLV.Size = new System.Drawing.Size(120, 40);
- this.OpenLV.TabIndex = 0;
- this.OpenLV.Text = "Launch LabVIEW";
- this.OpenLV.Click += new System.EventHandler(this.OpenLV_Click);
- //
- // RunVI
- //
- this.RunVI.Enabled = false;
- this.RunVI.Location = new System.Drawing.Point(16, 80);
- this.RunVI.Name = "RunVI";
- this.RunVI.Size = new System.Drawing.Size(120, 40);
- this.RunVI.TabIndex = 1;
- this.RunVI.Text = "Run VI";
- this.RunVI.Click += new System.EventHandler(this.RunVI_Click);
- //
- // QuitLV
- //
- this.QuitLV.Enabled = false;
- this.QuitLV.Location = new System.Drawing.Point(16, 144);
- this.QuitLV.Name = "QuitLV";
- this.QuitLV.Size = new System.Drawing.Size(120, 40);
- this.QuitLV.TabIndex = 2;
- this.QuitLV.Text = "Exit LabVIEW";
- this.QuitLV.Click += new System.EventHandler(this.QuitLV_Click);
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(168, 88);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(152, 20);
- this.textBox1.TabIndex = 3;
- this.textBox1.Text = "";
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(168, 160);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(152, 20);
- this.textBox2.TabIndex = 4;
- this.textBox2.Text = "";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(168, 48);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(136, 40);
- this.label2.TabIndex = 8;
- this.label2.Text = "Enter an arithmetic expression. Recognized operators are +,-,*,/,%,(,)";
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(168, 136);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(136, 24);
- this.label3.TabIndex = 9;
- this.label3.Text = "Result";
- //
- // checkBox1
- //
- this.checkBox1.Location = new System.Drawing.Point(168, 16);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(136, 32);
- this.checkBox1.TabIndex = 10;
- this.checkBox1.Text = "Display VI front panel";
- //
- // Form1
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(368, 213);
- this.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.checkBox1,
- this.label3,
- this.label2,
- this.textBox2,
- this.textBox1,
- this.QuitLV,
- this.RunVI,
- this.OpenLV});
- this.Name = "Form1";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "LabVIEW Server";
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- System.Windows.Forms.Application.Run(new Form1());
- }
- private void OpenLV_Click(object sender, System.EventArgs e)
- {
- //Instantiate a reference to LabVIEW
- lv = new LabVIEW.ApplicationClass();
- //Set the path to the VI
- string vipath=lv.ApplicationDirectory.ToString() + @"\Examples\General\Strings.llb\Parse Arithmetic Expression.vi";
- //Get reference to that VI
- vi= lv.GetVIReference(vipath,"",true);
- OpenLV.Enabled=false;
- RunVI.Enabled=true;
- QuitLV.Enabled=true;
- }
- private void RunVI_Click(object sender, System.EventArgs e)
- {
- /*
- * Initialize the variables and define the strings corresponding to
- * the VI connector labels. Note the strings are case sensitive
- **/
- string[] str1 = new String[2];
- str1[0]="Arithmetic Expression";
- str1[1]="Result";
- //The wrapper function expects to be passed a object type by reference.
- //We pass the string array to the object type here
- object param1 = (object)str1;
- //Define the variable that will pass the expression to be evaluated to
- //LabVIEW and typecast it to type object
- object[] str2 = new object[2];
- str2[0]=textBox1.Text.ToString();
- object param2= (object)str2;
- //Check if front panel of VI should be displayed
- if(checkBox1.Checked==false)
- vi.ShowFPOnCall=false;
- else
- vi.ShowFPOnCall=true;
- //Call the VI
- vi.Call(ref param1,ref param2);
- //Display the result
- textBox2.Text=((object[])param2)[1].ToString();
- }
- private void QuitLV_Click(object sender, System.EventArgs e)
- {
- //Close LabVIEW
- if(lv!=null)
- lv.Quit();
- OpenLV.Enabled=true;
- RunVI.Enabled=false;
- QuitLV.Enabled=false;
- }
- }
- }
複製代碼
這是一個網路上看到的範例
可是我現在只能做到把labivew打開
但是沒辦法把裡面的影像拿出來... |
|