跳轉到

步 (Step)

什麼是步?

MachiningStepHi.MachiningSteps.MachiningStep (API))是 HiNC 仿真中的單一計算單位。預設情況下,一個步對應一個主軸轉,但此間隔可透過 基礎仿真 工作流程設定。

每個步包含兩個連續步間(從前一步到當前步)的 時間區間 資料。由於這代表時段而非瞬時,許多欄位用前綴表示簡化形式:平均(Avg)、極值(Min、Max)、區間(Delta)、絕對值最大(MaxAbs)。


註冊自訂步變數

除了預設屬性外,可使用 RegisterStepVariable (API) 註冊自訂步變數:

RegisterStepVariable(
    "ChipVolume",          // key
    "Chip Volume",         // display name
    "mm3",                 // unit
    "F2",                  // format string
    (step) => step.ChipVolume_mm3  // value function
);

PlayNcFile("NC/file1.nc");

參數:

  • key:唯一識別碼
  • name:顯示名稱(UI 中可見)
  • unit:物理單位(可為 null)
  • formatString:.NET 數值格式字串(可為 null)
  • variableFunction:由步計算值的 lambda(可為 null)

註冊後的變數會出現在 UI 與 WriteStepFiles (API) 的輸出檔中。

索引器存取

使用 MachiningStep (API) 的索引器可在步上讀寫自訂資料:

SessionStepBuilt += (preStep, curStep) => {
    if (curStep != null)
        curStep["MyCustomField"] = someCalculation();
};

存取步資料

GetMillingStep

GetMillingStep (API) 依索引取得步:

var step = GetMillingStep(100);
if (step != null)
{
    Message($"ToolId={step.ToolId}, Force={step.MaxAbsForce_N} N");
}

StepCount

StepCount (API) 回傳步總數:

Message($"Total steps: {StepCount}");

迭代全部步

for (int i = 0; i < StepCount; i++)
{
    var step = GetMillingStep(i);
    // process step...
}

步輸出檔

步可由 WriteStepFiles (API) 匯出為 CSV:

WriteStepFiles("Output/[NcName].step.csv");

CSV 包含所有預設屬性與已註冊的自訂變數。檔案可由 PlayCsvFile (API) 讀回。

波形級資料(次步時間解析)可使用 WriteShotFiles (API):

WriteShotFiles("Output/[NcName].shot.csv", 1);  // 1 ms 時間解析度

訓練後動態註冊變數

執行 TrainMillingPara (API) 或 ReTrainMillingPara (API) 後,訓練區內的步會自動註冊兩個額外步變數:

變數 說明
TrainingErrRatio 每步仿真與量測之間的誤差指標
AngleOffset 量測與仿真資料的刀具旋轉相位差

延伸閱讀