亚洲mv大片欧洲mv大片入口,国产粉嫩无码一区二区三区,国内精品自产拍在线观看91,久久久亚洲欧洲日产国码二区,中文字幕人妻久久一区二区三区

常州機器視覺培訓

常州上位機軟件開發(fā)

常州工業(yè)機器人編程設(shè)計培訓

常州PLC培訓

常州PLC

常州PLC編程培訓

常州電工培訓

常州和訊plc培訓中心歡迎您!
當前位置:網(wǎng)站首頁 > 技術(shù)資料 技術(shù)資料
本篇C#測試程序的源碼如下:_機器視覺培訓_西門子PLC培訓_三菱PLC培訓
日期:2023-12-5 13:36:13人氣:  標簽:_機器視覺培訓_西門子PLC培訓_三菱PLC培訓

本篇C#測試程序的源碼如下:

//下面的演示程序的目的:

//演示如何控制HDevelop的編譯

//使用集成實時編譯器hdev和hdvp的過程。

//可以全局控制是否應(yīng)該在執(zhí)行之前編譯過程。

//此外,還可以控制在什么時間點執(zhí)行編譯。

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using HalconDotNet;

namespace UseJitCompiler

{

  ///

  /// Summary description for Form1.

  ///

  public class UseJitCompilerForm : System.Windows.Forms.Form

  {

    internal System.Windows.Forms.Button NoCompileBtn;

    internal System.Windows.Forms.Button ExplicitBtn;

    internal System.Windows.Forms.Button ImplicitBtn;

    ///

    /// Required designer variable.

    ///

    private System.ComponentModel.Container components = null;

    // path of HDevelop program

    String ProgramPathString;

    // procedure calls

    private DataGridView resultGrid;

    enum CompileMode

    {

      eNoCompile,

      eExplicit,

      eImplicit

    };

    public UseJitCompilerForm()

    {

      InitializeComponent();

    }

    protected override void Dispose(bool disposing)

    {

      if (disposing)

      {

        if (components != null)

        {

          components.Dispose();

        }

      }

      base.Dispose(disposing);

    }

    #region Windows Form Designer generated code

    ///

    /// Required method for Designer support - do not modify

    /// the contents of this method with the code editor.

    ///

    private void InitializeComponent()

    {

            this.NoCompileBtn = new System.Windows.Forms.Button();

            this.ExplicitBtn = new System.Windows.Forms.Button();

            this.ImplicitBtn = new System.Windows.Forms.Button();

            this.resultGrid = new System.Windows.Forms.DataGridView();

            ((System.ComponentModel.ISupportInitialize)(this.resultGrid)).BeginInit();

            this.SuspendLayout();

            // 

            // NoCompileBtn

            // 

       #    this.NoCompileBtn.Location = new System.Drawing.Point(19, 68);

    &nb{p;       this.NoCompileBtn.Name = "NoCompileBtn";

            this.NoCompileBtn.Size = new System.Drawing.Size(192, 55);

            this.NoCompileBtn.TabIndex = 4;

            this.NoCompileBtn.Text = "No compile";

            this.NoCompileBtn.Click += new System.EventHandler(this.NoCompileBtn_Click);

            // 

            // ExplicitBtn

            // 

            this.ExplicitBtn.Location = new System.Drawing.Point(19, 145);

            this.ExplicitBtn.Name = "ExplicitBtn";

            this.ExplicitBtn.Size = new System.Drawing.Size(192, 56);

            this.ExplicitBtn.TabIndex = 7;

            this.ExplicitBtn.Text = "Explicit Compile";

            this.ExplicitBtn.Click += new System.EventHandler(this.ExplicitBtn_Click);

            // 

            // ImplicitBtn

            // 

            this.ImplicitBtn.Location = new System.Drawing.Point(19, 223);

            this.ImplicitBtn.Name = "ImplicitBtn";

            this.ImplicitBtn.Size = new System.Drawing.Size(192, 55);

            this.ImplicitBtn.TabIndex = 8;

            this.ImplicitBtn.Text = "Implicit Compile";

            this.ImplicitBtn.Click += new System.EventHandler(this.ImplicitBtn_Click);

            // 

            // resultGrid

            // 

            this.resultGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;

            this.resultGrid.Location = new System.Drawing.Point(217, 15);

            this.resultGrid.Name = "resultGrid";

            this.resultGrid.Size = new System.Drawing.Size(983, 278);

            this.resultGrid.TabIndex = 9;

            // 

            // UseJitCompilerForm

            // 

            this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);

            this.ClientSize = new System.Drawing.Size(1220, 305);

            this.Controls.Add(this.resultGrid);

            this.Controls.Add(this.ImplicitBtn);

            this.Controls.Add(this.ExplicitBtn);

            this.Controls.Add(this.NoCompileBtn);

            this.Name = "UseJitCompilerForm";

            this.Text = "Execute procedure with and without JIT compilation";

            this.Load += new System.EventHandler(this.UseJitCompilerForm_Load);

            ((System.ComponentModel.ISupportInitialize)(this.resultGrid)).EndInit();

            this.ResumeLayout(false);

    }

    #endregion

    [STAThread]

    static void Main()

    {

      Application.Run(new UseJitCompilerForm());

    }

    private void UseJitCompilerForm_Load(object sender, System.EventArgs e)

    {

      

      string halconExamples = HSystem.GetSystem("example_dir");

      ProgramPathString = halconExamples +

        @"\hdevengine\hdevelop\test_jit_speedup.hdev";

      if (!HalconAPI.isWindows)

      {

        ProgramPathString = ProgramPathString.Replace('\\', '/');

      }

      resultGrid.ColumnCount = 9;

      resultGrid.RowCount = HalconAPI.isWindows ? 3 : 4;

      resultGrid.RowHeadersVisible = false;

      resultGrid.Columns[0].Name = "Compile Fibonacci";

      resultGrid.Columns[1].Name = "Prepare Fibonacci";

      resultGrid.Columns[2].Name = "Execute Fibonacci";

      resultGrid.Columns[3].Name = "Compile Mean";

      resultGrid.Columns[4].Name = "Prepare Mean";

      resultGrid.Columns[5].Name = "Execute Mean";

      resultGrid.Columns[6].Name = "Compile Process";

      resultGrid.Columns[7].Name = "Prepare Process";

      resultGrid.Columns[8].Name = "Execute Process";

      resultGrid.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

      resultGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

      resultGrid.AutoResizeColumns();

      int height = ExplicitBtn.Top - NoCompileBtn.Top;

      resultGrid.Rows[0].Height = height;

      resultGrid.Rows[1].Height = height;

      resultGrid.Rows[2].Height = height;

      resultGrid.CurrentCell.Selected = false;

      resultGrid.ReadOnly = true;

      for (int i = 0; i < resultGrid.Columns.Count; i++)

      {

        resultGrid.Columns[i].SortMode = DataGridViewColumnSortMode.Programmatic;

      }

    }

    delegate void ProcInputParamSetter(HDevProcedureCall call);

    private void ShowTime(int row, int col, double seconds)

    {

      resultGrid[col, row].Value = String.Format("{0,7:F1} ms",1000*seconds);

      resultGrid.Update();

    }

    private void ClearTime(int row)

    {

      for (int i = 0; i < resultGrid.Columns.Count; i++)

      {

        resultGrid[i, row].Value = "";

      }

      resultGrid.Update();

    }

    private void RunProc(string name, CompileMode mode, int rowIndex,

                       int columnOffset, ProcInputParamSetter setter)

    {

      HDevEngine        Engine  = null;

      HDevProgram       Program = null;

      HDevProcedure     Proc    = null;

      HDevProcedureCall Call    = null;

      try

      {

        Engine = new HDevEngine();

        // 啟用或禁用編譯過程的執(zhí)行,即JIT的開關(guān)

        Engine.SetEngineAttribute("execute_procedures_jit_compiled",

          mode == CompileMode.eNoCompile ? "false" : "true");

        Program = new HDevProgram(ProgramPathString);

        //載入主程序test_jit_speedup.hdev

        Proc = new HDevProcedure(Program, name);

        double T1 = HSystem.CountSeconds();

        // 模式為預編譯方式的處理

        if (mode == CompileMode.eExplicit)

          Proc.CompileUsedProcedures();

        double T2 = HSystem.CountSeconds();

        ShowTime(rowIndex, columnOffset, T2 - T1);

        // 創(chuàng)建調(diào)用函數(shù)并設(shè)置參數(shù)

        Call = new HDevProcedureCall(Proc);

        setter(Call);

        double T3 = HSystem.CountSeconds();

        ShowTime(rowIndex, columnOffset + 1, T3 - T2);

        // 執(zhí)行調(diào)用函數(shù)

        Call.Execute();

        double T4 = HSystem.CountSeconds();

        ShowTime(rowIndex, columnOffset + 2, T4 - T3);

      }

      catch (HDevEngineException Ex)

      {

        MessageBox.Show(Ex.Message, "HDevEngine Exception");

      }

      finally

      {

        // Cleanup

        if (Call != null)

          Call.Dispose();

        if (Proc != null)

          Proc.Dispose();

        if (Program != null)

          Program.Dispose();

        if (Engine != null)

          Engine.Dispose();

      }

    }

    private void RunProcs(CompileMode mode)

    {

      Cursor = Cursors.WaitCursor;

      int rowIndex = mode == CompileMode.eNoCompile ? 0 :

        mode == CompileMode.eExplicit ? 1 : 2;

      ClearTime(rowIndex);

      HImage image      = new HImage("fabrik");

      HImage imageUInt2 = image.ConvertImageType("uint2");

      RunProc("fib", mode, rowIndex, 0,

            (ProcInputParamSetter) delegate(HDevProcedureCall call)

          {

            call.SetInputCtrlParamTuple(1,20);

          });

      RunProc("mean_sp_real", mode, rowIndex, 3,

          (ProcInputParamSetter)delegate(HDevProcedureCall call)

          {

            call.SetInputIconicParamObject(1, imageUInt2);

            call.SetInputCtrlParamTuple(1, 3);

            call.SetInputCtrlParamTuple(2, 3);

            call.SetInputCtrlParamTuple(3, 10);

            call.SetInputCtrlParamTuple(4, 250);

          });

      RunProc("process", mode, rowIndex, 6,

          (ProcInputParamSetter)delegate(HDevProcedureCall call)

          {

            call.SetInputIconicParamObject(1, imageUInt2);

          });

      imageUInt2.Dispose();

      image.Dispose();

      Cursor = Cursors.Default;

    }

    private void NoCompileBtn_Click(object sender, System.EventArgs e)

    {

      RunProcs(CompileMode.eNoCompile);

    }

    private void ExplicitBtn_Click(object sender, System.EventArgs e)

    {

      RunProcs(CompileMode.eExplicit);

    }

    private void ImplicitBtn_Click(object sender, System.EventArgs e)

    {

      RunProcs(CompileMode.eImplicit);

    }

  }

}


本文網(wǎng)址:

相關(guān)信息:
  • 沒有資料
版權(quán)所有 CopyRight 2006-2017 江蘇和訊自動化設(shè)備有限公司 常州自動化培訓中心 電話:0519-85602926 地址:常州市新北區(qū)府琛商務(wù)廣場2號樓1409室
蘇ICP備14016686號-2 技術(shù)支持:常州山水網(wǎng)絡(luò)
本站關(guān)鍵詞:常州PLC培訓 常州PLC編程培訓 常州PLC編程 常州PLC培訓班 網(wǎng)站地圖 網(wǎng)站標簽
在線與我們?nèi)〉寐?lián)系
亚洲mv大片欧洲mv大片入口,国产粉嫩无码一区二区三区,国内精品自产拍在线观看91,久久久亚洲欧洲日产国码二区,中文字幕人妻久久一区二区三区