| | |
| | | } |
| | | |
| | | // å°è£
对象å建é»è¾ |
| | | private Dt_DeviceProtocol CreateDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset, int additionalOffset, string dataType, int dataLength, string paramName) |
| | | private Dt_DeviceProtocol CreateDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset, int additionalOffset, string dataType, int dataLength, string paramName, string DeviceProDataBlock, string DeviceProParamType) |
| | | { |
| | | decimal DeviceProOffsets = DeviceProOffset + additionalOffset; |
| | | return new Dt_DeviceProtocol |
| | | { |
| | | DeviceId = DeviceID, |
| | | DeviceChildCode = DeviceChildCode, |
| | | DeviceProDataBlock = "DB1000", |
| | | DeviceProDataBlock = DeviceProDataBlock, |
| | | DeviceProOffset = DeviceProOffsets, |
| | | DeviceProDataLength = dataLength, |
| | | DeviceProDataType = dataType, |
| | | DeviceProParamName = paramName, |
| | | DeviceProParamType = "DeviceCommand", |
| | | DeviceProParamType = DeviceProParamType, |
| | | DeviceProParamDes = "1", |
| | | DeviceProRemark = "", |
| | | Creater = "admin", |
| | |
| | | }; |
| | | } |
| | | |
| | | public WebResponseContent AddDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset) |
| | | public WebResponseContent AddAfterDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 0, "int", 1, "ConveyorLineTargetAddress"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 2, "int", 1, "ConveyorLineTaskNum"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 6, "string", 25, "ConveyorLineBarcode"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 34, "int", 1, "Reserve1"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 36, "int", 1, "Reserve2"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 38, "int", 1, "Reserve3"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 40, "byte", 1, "InteractiveSignal"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 42, "int", 1, "HasPallet"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 44, "int", 1, "ConveyorLineAlarm"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 46, "int", 1, "ResponState"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 48, "int", 1, "Reserve5") |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 0, "int", 1, "ConveyorLineTargetAddress","DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 2, "int", 1, "ConveyorLineTaskNum", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 6, "string", 25, "ConveyorLineBarcode", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 34, "int", 1, "Reserve1", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 36, "int", 1, "Reserve2", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 38, "int", 1, "Reserve3", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 40, "byte", 1, "InteractiveSignal", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 42, "int", 1, "HasPallet", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 44, "int", 1, "ConveyorLineAlarm", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 46, "int", 1, "ResponState", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 48, "int", 1, "Reserve5", "DB1000", "DeviceCommand") |
| | | |
| | | }; |
| | | var result=BaseDal.AddData(protocols); |
| | | return content.OK(data:result); |
| | | var result = BaseDal.AddData(protocols); |
| | | return content.OK(data: result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public WebResponseContent AddBeforeDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead, decimal DeviceProOffsetWrite) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (DeviceProtocolExists(DeviceID, DeviceChildCode, DeviceProOffsetRead)) |
| | | { |
| | | throw new InvalidOperationException("å·²åå¨è¯¥èç¹æç»"); |
| | | } |
| | | |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 0, "int", 1, "InteractiveSignal","DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 2, "string", 25, "ConveyorLineBarcode", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 30, "dint", 1, "ConveyorLineTargetAddress", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 34, "dint", 1, "ConveyorLineTaskNum", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 38, "dint", 1, "ConveyorLineAlarm", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 0, "w", 1, "WriteInteractiveSignal", "DB901", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 2, "string", 25, "WriteConveyorLineBarcode", "DB901", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 30, "dint", 1, "WriteConveyorLineTargetAddress", "DB901", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 34, "dint", 1, "WriteConveyorLineTaskNum", "DB901", "DeviceCommand"), |
| | | |
| | | }; |
| | | var result = BaseDal.AddData(protocols); |
| | | return content.OK(data: result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent AddBeforReadDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (DeviceProtocolExists(DeviceID, DeviceChildCode, DeviceProOffsetRead)) |
| | | { |
| | | throw new InvalidOperationException("å·²åå¨è¯¥èç¹æç»"); |
| | | } |
| | | |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 0, "int", 1, "InteractiveSignal","DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 2, "string", 25, "ConveyorLineBarcode", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 30, "dint", 1, "ConveyorLineTargetAddress", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 34, "dint", 1, "ConveyorLineTaskNum", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 38, "dint", 1, "ConveyorLineAlarm", "DB900", "ReadDeviceCommand"), |
| | | }; |
| | | var result = BaseDal.AddData(protocols); |
| | | return content.OK(data: result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <param name="fileInput">æä»¶</param> |
| | | /// <returns>è¿å读åç»æï¼æåè¿åæ°æ®ï¼å¤±è´¥è¿åé误信æ¯</returns> |
| | | WebResponseContent GetImportData(List<IFormFile> fileInput); |
| | | WebResponseContent AddDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset); |
| | | WebResponseContent AddAfterDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset); |
| | | |
| | | WebResponseContent AddBeforeDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead, decimal DeviceProOffsetWrite); |
| | | WebResponseContent AddBeforReadDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead); |
| | | } |
| | | } |
| | |
| | | return Service.GetImportData(fileInput); |
| | | } |
| | | |
| | | [HttpPost, Route("AddDeviceProtocol"), AllowAnonymous] |
| | | [HttpPost, Route("AddAfterDeviceProtocol"), AllowAnonymous] |
| | | public WebResponseContent AddDeviceProtocol(int DeviceID,string DeviceChildCode, decimal DeviceProOffset) |
| | | { |
| | | |
| | | return Service.AddDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset); |
| | | return Service.AddAfterDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset); |
| | | } |
| | | |
| | | [HttpPost, Route("AddBeforeDeviceProtocol"), AllowAnonymous] |
| | | public WebResponseContent AddBeforeDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead, decimal DeviceProOffsetWrite) |
| | | { |
| | | return Service.AddBeforeDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, DeviceProOffsetWrite); |
| | | } |
| | | [HttpPost, Route("AddBeforReadDeviceProtocol"), AllowAnonymous] |
| | | public WebResponseContent AddBeforReadDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead) |
| | | { |
| | | return Service.AddBeforReadDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "urls": "http://*:9291", //webæå¡ç«¯å£ï¼å¦æç¨IISé¨ç½²ï¼æè¿ä¸ªå»æ |
| | | "Logging": { |
| | | "LogLevel": { |
| | | "Default": "Information", |
| | | "Microsoft.AspNetCore": "Warning" |
| | | } |
| | | }, |
| | | "dics": "deviceType,devicePlcType,jobAssembly,jobClassName,deviceStatus,taskType,taskState,inOutType", |
| | | "AllowedHosts": "*", |
| | | "ConnectionStringsEncryption": false, |
| | | "MainDB": "DB_WIDESEA", //å½å项ç®ç主åºï¼æå¯¹åºçè¿æ¥å符串çEnabledå¿
须为true |
| | | //è¿æ¥å符串 |
| | | "ConnectionString": "Data Source=.;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCSDB_BB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | //è·¨å |
| | | "Cors": { |
| | | "PolicyName": "CorsIpAccess", //çç¥åç§° |
| | | "EnableAllIPs": true, //å½ä¸ºtrueæ¶ï¼å¼æ¾ææIPåå¯è®¿é®ã |
| | | // æ¯æå¤ä¸ªåå端å£ï¼æ³¨æç«¯å£å·åä¸è¦å¸¦/ææï¼æ¯å¦localhost:8000/ï¼æ¯éç |
| | | // 注æï¼http://127.0.0.1:1818 å http://localhost:1818 æ¯ä¸ä¸æ ·ç |
| | | "IPs": "http://127.0.0.1:8080,http://localhost:8080,http://127.0.0.1:8081,http://localhost:8081" |
| | | }, |
| | | "ApiName": "WIDESEA", |
| | | "ExpMinutes": 120, |
| | | "QuartzJobAutoStart": true, |
| | | "LogDeubgEnable": true |
| | | } |