From 718ac5621b08952f8614376f1d004cc0cc8db117 Mon Sep 17 00:00:00 2001 From: Artyom Date: Mon, 20 May 2024 19:57:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=BE=20=D0=B2=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=D0=B9=D1=81=D1=82=D0=B2=D0=B8=D0=B5=20=D1=81=D0=BE?= =?UTF-8?q?=20SCADA=20Fuxa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiServer/Controllers/StateController.cs | 33 ++++++++++++------- .../ApiServer/Properties/launchSettings.json | 4 +-- CyberSystem/fuxa-project.json | 1 + 3 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 CyberSystem/fuxa-project.json diff --git a/CyberSystem/ApiServer/Controllers/StateController.cs b/CyberSystem/ApiServer/Controllers/StateController.cs index 7cf54ee..6a4eafd 100644 --- a/CyberSystem/ApiServer/Controllers/StateController.cs +++ b/CyberSystem/ApiServer/Controllers/StateController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http.HttpResults; +using Microsoft.AspNetCore.Mvc; namespace ApiServer.Controllers { @@ -6,22 +7,30 @@ namespace ApiServer.Controllers [Route("api/state")] public class StateContoller { - [HttpGet] - public byte GetActualState() - { - return GetActualStateFromCom.CurrentState; - } + //[HttpGet] + //public byte GetActualState() + //{ + // return GetActualStateFromCom.CurrentState; + //} [HttpGet] [Route("modbus")] - public ActionResult GetActualState(int inputIndex) + [Produces("application/json")] + public JsonResult GetActualState() { - if (inputIndex > 1) - { - return new NotFoundResult(); + //if (inputIndex > 1) + //{ + //return new NotFoundResult(); //throw new ArgumentOutOfRangeException(nameof(inputIndex), "Значение может быть от 0 до 1 включительно."); - } - return GetActualStateFromComWithModbus.CurrentState[inputIndex]; + //} + var inputIndex = 1; + var result = GetActualStateFromComWithModbus.CurrentState[inputIndex] + ? 1 + : 0; + + var obj = new { CoilResult = result }; + + return new JsonResult(obj); } } } diff --git a/CyberSystem/ApiServer/Properties/launchSettings.json b/CyberSystem/ApiServer/Properties/launchSettings.json index 99277b1..3785afb 100644 --- a/CyberSystem/ApiServer/Properties/launchSettings.json +++ b/CyberSystem/ApiServer/Properties/launchSettings.json @@ -4,7 +4,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:3819", + "applicationUrl": "http://0.0.0.0:3819", "sslPort": 0 } }, @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:12344", + "applicationUrl": "http://0.0.0.0:12344", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/CyberSystem/fuxa-project.json b/CyberSystem/fuxa-project.json new file mode 100644 index 0000000..93c85a5 --- /dev/null +++ b/CyberSystem/fuxa-project.json @@ -0,0 +1 @@ +{"devices":{"0":{"id":"0","name":"FUXA Server","type":"FuxaServer","property":{},"enabled":true,"tags":{"t_f76a7b7e-ea8e4178":{"id":"t_f76a7b7e-ea8e4178","daq":{"restored":false,"enabled":false,"changed":false,"interval":60},"name":"Maser Connection Status","label":"Maser Connection Status","type":"number","memaddress":"d_cf82a6fa-17b24fab","sysType":1,"init":"","timestamp":1716223999827}},"polling":1000},"d_cf82a6fa-17b24fab":{"id":"d_cf82a6fa-17b24fab","property":{"address":"http://172.20.10.2:12344/api/state/modbus","port":null,"slot":null,"rack":null,"baudrate":9600,"databits":8,"stopbits":1,"parity":"None","method":"GET","format":"JSON"},"enabled":true,"tags":{"t_b5de94c1-5efd4df9":{"id":"t_b5de94c1-5efd4df9","daq":{"restored":false,"enabled":false,"changed":false,"interval":60},"name":"coilResult","label":"coilResult","type":"boolean","address":"coilResult","timestamp":1716223999840}},"name":"Master","type":"WebAPI","polling":1000}},"hmi":{"views":[{"id":"v_71057412b12-8119b","name":"MainView","profile":{"width":1024,"height":768,"bkcolor":"#ffffffff","margin":10},"items":{"HXT_94d610d6-0245443c":{"id":"HXT_94d610d6-0245443c","type":"svg-ext-html_switch","name":"switch_1","property":{"events":[],"actions":[],"variableId":"t_b5de94c1-5efd4df9","options":{"offValue":0,"onValue":1,"offBackground":"#ccc","onBackground":"#ccc","offText":"","onText":"","offSliderColor":"#fff","onSliderColor":"#0CC868","offTextColor":"#000","onTextColor":"#fff","fontSize":12,"fontFamily":"","radius":0,"height":22}},"label":"HtmlSwitch"}},"variables":{},"svgcontent":"\n \n \n \n \n Layer 1\n \n \n \n \n \n \n \n"}],"layout":{"autoresize":false,"start":"v_71057412b12-8119b","navigation":{"bkcolor":"#F4F5F7","fgcolor":"#1D1D1D","logo":false,"mode":"over","type":"block"},"header":{"bkcolor":"#ffffff","fgcolor":"#000000","fontSize":13,"itemsAnchor":"left"},"showdev":true,"inputdialog":"false","hidenavigation":false,"theme":"","loginonstart":false,"loginoverlaycolor":"none","show_connection_error":true}},"version":"1.00","server":{"id":"0","name":"FUXA Server","type":"FuxaServer","property":{}}} \ No newline at end of file