色婷婷AV无码久久精品,久久天天躁狠狠躁夜夜97,羞羞麻豆国产精品1区2区3区,啪影院免费线观看视频,思思久久er99精品亚洲

常州機(jī)器視覺(jué)培訓(xùn)

常州上位機(jī)軟件開(kāi)發(fā)

常州工業(yè)機(jī)器人編程設(shè)計(jì)培訓(xùn)

常州PLC培訓(xùn)

常州PLC

常州PLC編程培訓(xùn)

常州電工培訓(xùn)

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

本篇C#測(cè)試程序的源碼如下:

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

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

//使用集成實(shí)時(shí)編譯器hdev和hdvp的過(guò)程。

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

//此外,還可以控制在什么時(shí)間點(diǎn)執(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();

        // 啟用或禁用編譯過(guò)程的執(zhí)行,即JIT的開(kāi)關(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();

        // 模式為預(yù)編譯方式的處理

        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)信息:
  • 沒(méi)有資料
版權(quán)所有 CopyRight 2006-2017 江蘇和訊自動(dòng)化設(shè)備有限公司 常州自動(dòng)化培訓(xùn)中心 電話(huà):0519-85602926 地址:常州市新北區(qū)府琛商務(wù)廣場(chǎng)2號(hào)樓1409室
蘇ICP備14016686號(hào)-2 技術(shù)支持:常州山水網(wǎng)絡(luò)
本站關(guān)鍵詞:常州PLC培訓(xùn) 常州PLC編程培訓(xùn) 常州PLC編程 常州PLC培訓(xùn)班 網(wǎng)站地圖 網(wǎng)站標(biāo)簽
在線與我們?nèi)〉寐?lián)系
色婷婷AV无码久久精品,久久天天躁狠狠躁夜夜97,羞羞麻豆国产精品1区2区3区,啪影院免费线观看视频,思思久久er99精品亚洲