mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-20 16:26:34 +08:00
使用emit代替表达式树构造委托。
内置了websocket server与相应的导航功能,可在实例工程中找到相应的实现。
This commit is contained in:
85
Net462DllTest/Web/FlowController.cs
Normal file
85
Net462DllTest/Web/FlowController.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
using Net462DllTest.Enums;
|
||||
using Net462DllTest.Signal;
|
||||
using Net462DllTest.Trigger;
|
||||
using Serein.Library.Attributes;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Library.Web;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net462DllTest.Web
|
||||
{
|
||||
[AutoHosting]
|
||||
public class FlowController : ControllerBase
|
||||
{
|
||||
private readonly SiemensPlcDevice plcDevice;
|
||||
private readonly ViewManagement viewManagement;
|
||||
|
||||
public FlowController(SiemensPlcDevice plcDevice, ViewManagement viewManagement)
|
||||
{
|
||||
this.plcDevice = plcDevice;
|
||||
this.viewManagement = viewManagement;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 类型 :POST
|
||||
* url : http://127.0.0.1:8089/flow/plcop?var=
|
||||
* url : http://127.0.0.1:8089/flow/plcop?var=SpaceNum
|
||||
* body :[JSON]
|
||||
*
|
||||
* {
|
||||
* "value":0,
|
||||
* }
|
||||
*/
|
||||
[WebApi(API.POST)]
|
||||
public dynamic PlcOp([Url] string var, int value)
|
||||
{
|
||||
if (EnumHelper.TryConvertEnum<PlcVarName>(var,out var signal))
|
||||
{
|
||||
Console.WriteLine($"外部触发 {signal} 信号,信号内容 : {value} ");
|
||||
plcDevice.TriggerSignal(signal, value);// 通过 Web Api 模拟外部输入信号
|
||||
return new { state = "succeed" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new { state = "fail" };
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 类型 :POST
|
||||
* url : http://127.0.0.1:8089/flow/trigger?command=
|
||||
* url : http://127.0.0.1:8089/flow/trigger?command=Command_1
|
||||
* body :[JSON]
|
||||
*
|
||||
* {
|
||||
* "value":0,
|
||||
* }
|
||||
*/
|
||||
[WebApi(API.POST)]
|
||||
public dynamic Trigger([Url] string command, int value)
|
||||
{
|
||||
if (EnumHelper.TryConvertEnum<CommandSignal>(command, out var signal))
|
||||
{
|
||||
Console.WriteLine($"外部触发 {signal} 信号,信号内容 : {value} ");
|
||||
viewManagement.TriggerSignal(signal, value);// 通过 Web Api 模拟外部输入信号
|
||||
return new { state = "succeed" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new { state = "fail" };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user