瀏覽代碼

1111

样式分支
fyf 2 年之前
父節點
當前提交
ba473a93ec
共有 4 個文件被更改,包括 85 次插入0 次删除
  1. +9
    -0
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  2. 二進制
     
  3. 二進制
     
  4. +76
    -0
      BPASmartClient.SCADAControl/Hepler/Config.cs

+ 9
- 0
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj 查看文件

@@ -10,6 +10,15 @@
<None Remove="Images\光柱.png" />
</ItemGroup>

<ItemGroup>
<Reference Include="Antlr3.Runtime">
<HintPath>DLL\Antlr3.Runtime.dll</HintPath>
</Reference>
<Reference Include="Unvell.ReoScript">
<HintPath>DLL\Unvell.ReoScript.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<Resource Include="Images\光柱.png" />
</ItemGroup>


二進制
查看文件


二進制
查看文件


+ 76
- 0
BPASmartClient.SCADAControl/Hepler/Config.cs 查看文件

@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Unvell.ReoScript;

namespace BPASmartClient.SCADAControl.Hepler
{
public class Config
{
private static ScriptRunningMachine srm { get; } = new ScriptRunningMachine();

static Config()
{
srm.WorkMode |=
// Enable DirectAccess
MachineWorkMode.AllowDirectAccess
// Ignore exceptions in CLR calling (by default)
| MachineWorkMode.IgnoreCLRExceptions
// Enable CLR Event Binding
| MachineWorkMode.AllowCLREventBind;

RegisterFunction();
}

/// <summary>
/// 运行脚本
/// </summary>
/// <param name="script"></param>
public static void RunJsScipt(string script)
{
try
{
srm.Run(script);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "脚本错误");
}
}

/// <summary>
/// 注册对象到js
/// </summary>
public static void SetVariable(string name, object obj)
{
srm.SetGlobalVariable(name, obj);
}

/// <summary>
/// 注册方法到Js
/// </summary>
private static void RegisterFunction()
{
srm["ShowMessage"] = new NativeFunctionObject("ShowMessage", (ctx, owner, args) =>
{
StringBuilder sb = new StringBuilder();
foreach (var item in args)
{
sb.Append(item.ToString());
}

MessageBox.Show($"{sb}", "提示");
return null;
});

srm["SetICDValue"] = new NativeFunctionObject("SetICDValue", (ctx, owner, args) =>
{
MessageBox.Show($"发送ICD数据", "提示");
return null;
});
}
}
}

Loading…
取消
儲存