WcsController.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Microsoft.AspNetCore.Mvc;
  2. using WCS.Core;
  3. using WCS.WorkEngineering.Systems;
  4. namespace WCS.WorkEngineering.WebApi.Controllers
  5. {
  6. /// <summary>
  7. /// WCS相关接口控制器
  8. /// </summary>
  9. [ApiController]
  10. [Route("api/[controller]/[action]")]
  11. public class WcsController : ControllerBase, IDeviceWriter
  12. {
  13. /// <summary>
  14. /// 设备信息写入接口
  15. /// </summary>
  16. /// <param name="deviceType">需要写入信息的设备类型</param>
  17. /// <param name="devCode">设备编号</param>
  18. /// <param name="protocol">设备协议类名</param>
  19. /// <param name="propName">写入字段名</param>
  20. /// <param name="value">值</param>
  21. [HttpPost]
  22. public void Write(DeviceTypeEnum deviceType, string devCode, string protocol, string propName, string value)
  23. {
  24. World.GetSystemInstance<DeviceWriteSystem>().Invoke(new DeviceWriteInfo
  25. {
  26. DeviceType = deviceType,
  27. Code = devCode,
  28. Protocol = protocol,
  29. Property = propName,
  30. Value = value
  31. });
  32. }
  33. /// <summary>
  34. /// 获取设备配置信息接口
  35. /// </summary>
  36. /// <returns></returns>
  37. [HttpGet]
  38. public List<Device> GetDeviceList()
  39. {
  40. return Device.All.ToList();
  41. }
  42. }
  43. public interface IDeviceWriter
  44. {
  45. [HttpPost]
  46. void Write(DeviceTypeEnum deviceType, string devCode, string protocol, string propName, string value);
  47. }
  48. }