This commit is contained in:
郭睿AMD7950X 2024-12-06 16:52:19 +08:00
commit 0f3f95285f
76 changed files with 2395 additions and 437 deletions

5
README.txt Normal file
View File

@ -0,0 +1,5 @@
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet ef dbcontext scaffold "Data Source=protdb.sql3" Microsoft.EntityFrameworkCore.Sqlite -o Models

View File

@ -103,6 +103,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTestDotnettyClient", "test\ConsoleTestDotnettyClient\ConsoleTestDotnettyClient.csproj", "{6F188128-F359-492A-99CF-BF219B886FFA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProtectionDeviceSqlite", "ProtectionDeviceSqlite", "{9D1CDEF4-094D-4906-8D8B-7A9109CD84BE}"
ProjectSection(SolutionItems) = preProject
README.txt = README.txt
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YunDa.SOMS.Commdb", "src\YunDa.Domain\ProtectionDeviceSqlite\YunDa.SOMS.Commdb\YunDa.SOMS.Commdb.csproj", "{76D765C8-89D0-4BD8-AC00-117605809EFE}"
EndProject
@ -114,7 +117,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yunda.SOMS.OperationsMainSi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestCPU", "test\TestCPU\TestCPU.csproj", "{7D90211D-07EA-436E-8147-9D3296CEF400}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTest", "test\ConsoleTest\ConsoleTest.csproj", "{3BE9DBEE-1FE7-44C7-93DA-7F213D43C44E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTest", "test\ConsoleTest\ConsoleTest.csproj", "{3BE9DBEE-1FE7-44C7-93DA-7F213D43C44E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YunDa.SOMS.ProDB", "src\YunDa.Domain\ProtectionDeviceSqlite\YunDa.SOMS.ProDB\YunDa.SOMS.ProDB\YunDa.SOMS.ProDB.csproj", "{1C7AC379-5A1C-4266-B469-83F529979EFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -849,6 +854,24 @@ Global
{3BE9DBEE-1FE7-44C7-93DA-7F213D43C44E}.Template|x64.Build.0 = Debug|Any CPU
{3BE9DBEE-1FE7-44C7-93DA-7F213D43C44E}.Template|x86.ActiveCfg = Debug|Any CPU
{3BE9DBEE-1FE7-44C7-93DA-7F213D43C44E}.Template|x86.Build.0 = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Debug|x64.ActiveCfg = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Debug|x64.Build.0 = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Debug|x86.ActiveCfg = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Debug|x86.Build.0 = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Release|Any CPU.Build.0 = Release|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Release|x64.ActiveCfg = Release|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Release|x64.Build.0 = Release|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Release|x86.ActiveCfg = Release|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Release|x86.Build.0 = Release|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Template|Any CPU.ActiveCfg = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Template|Any CPU.Build.0 = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Template|x64.ActiveCfg = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Template|x64.Build.0 = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Template|x86.ActiveCfg = Debug|Any CPU
{1C7AC379-5A1C-4266-B469-83F529979EFE}.Template|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -901,9 +924,10 @@ Global
{505F0B5A-4AEB-499C-8937-19FE950B0354} = {A49CD7CD-52BA-48F3-83D5-D6CA072F8849}
{7D90211D-07EA-436E-8147-9D3296CEF400} = {F10AA149-2626-486E-85BB-9CD5365F3016}
{3BE9DBEE-1FE7-44C7-93DA-7F213D43C44E} = {F10AA149-2626-486E-85BB-9CD5365F3016}
{1C7AC379-5A1C-4266-B469-83F529979EFE} = {9D1CDEF4-094D-4906-8D8B-7A9109CD84BE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
VisualSVNWorkingCopyRoot = .
SolutionGuid = {B516B1E8-1CEC-4BCC-BA92-93CB32845E37}
VisualSVNWorkingCopyRoot = .
EndGlobalSection
EndGlobal

View File

@ -21,10 +21,12 @@ using YunDa.ISAS.DataTransferObject;
using YunDa.ISAS.Entities.GeneralInformation;
using YunDa.ISAS.Redis.Repositories;
using YunDa.ISMS.BASE.Entities.Models;
using YunDa.SOMS.DataTransferObject.CommonDto;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.HistoryData;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.SearchCondition;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionSettingDto;
using YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport;
using YunDa.SOMS.Entities.GeneralInformation;
namespace YunDa.ISAS.Application.GeneralInformation
@ -45,7 +47,7 @@ namespace YunDa.ISAS.Application.GeneralInformation
private readonly IRepository<ImProtectDevice,string> _imProtectDeviceRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
IRedisRepository<int[], string> _deviceBoardStatesRedis;
IRedisRepository<DeviceBoardStates, string> _deviceBoardStatesRedis;
string deviceIORedisKey = "deviceIO";
IRedisRepository<IOState, string> _deviceIOsRedis;
@ -69,7 +71,7 @@ namespace YunDa.ISAS.Application.GeneralInformation
IRepository<BoardCardInfo, Guid> boardCardInfoRepository,
IRepository<BoardCardHistory, Guid> boardCardHistoryRepository,
IRepository<ManufacturerInfo, Guid> manufacturerInfoRepository,
IRedisRepository<int[], string> deviceBoardStatesRedis,
IRedisRepository<DeviceBoardStates, string> deviceBoardStatesRedis,
IRedisRepository<IOState, string> deviceIOsRedis,
IRepository<ProtectionDeviceType, Guid> protectionDeviceTypeRepository,
ISessionAppService sessionAppService
@ -331,27 +333,7 @@ namespace YunDa.ISAS.Application.GeneralInformation
RequestResult<string> rst = new RequestResult<string>();
return rst;
}
List<string> iopositions = new List<string>
{
"运行",
"告警",
"跳闸",
"重合闸",
"重合闸就绪",
"备自投",
"备自投就绪",
"分位",
"合位",
"检修",
"重合闸动作",
"IO插件1",
"IO插件2",
"IO插件3",
"IO插件4",
"电源插件IO5",
"液晶"
};
string deviceBoardStatesRedisKey = "deviceBoardStates";
/// <summary>
/// 获取板卡状态
@ -380,39 +362,8 @@ namespace YunDa.ISAS.Application.GeneralInformation
{
var state = await _deviceBoardStatesRedis.HashSetGetAllAsync(deviceBoardStatesRedisKey, protectionDeviceInfo.DeviceAddress.ToString());
if (state != null && state.Length == 8)
{
List <DeviceRunState> datas = new();
for (int i = 0; i < iopositions.Count; i++)
{
if (i == 0)
{
datas.Add(new DeviceRunState
{
Name =iopositions[0] ,
State = state[0]
});
}
else if(i<11)
{
datas.Add(new DeviceRunState
{
Name = iopositions[i],
State = -1
});
}
else
{
datas.Add(new DeviceRunState
{
Name = iopositions[i],
State = state[i-9]
});
}
}
rst.ResultData = datas;
rst.Flag = true;
}
rst.ResultData = state.States.Select(t=>new DeviceRunState { Name = t.Name,State = t.Value}).ToList();
rst.Flag = true;
}
}
catch (Exception ex)

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using YunDa.ISAS.Application.Core;
using YunDa.ISAS.DataTransferObject;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
@ -16,5 +17,12 @@ namespace YunDa.ISAS.Application.GeneralInformation
/// <param name="equipmentInfoId"></param>
/// <returns></returns>
RequestResult<List<BoardCardHistoryOutput>> FindHistoryDataByEquipmentInfoId(Guid? equipmentInfoId);
/// <summary>
/// 查询板卡在线信息
/// </summary>
/// <param name="equipmentId"></param>
/// <param name="deviceId"></param>
/// <returns></returns>
Task<RequestResult<List<DeviceRunState>>> GetBoardStateInfo(Guid equipmentId, Guid deviceId);
}
}

View File

@ -6,6 +6,7 @@ using YunDa.ISAS.DataTransferObject.CommonDto;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.HistoryData;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.SearchCondition;
using YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport;
namespace YunDa.ISAS.Application.GeneralInformation
{
@ -30,5 +31,12 @@ namespace YunDa.ISAS.Application.GeneralInformation
/// <param name="stationId"></param>
/// <returns></returns>
RequestResult<List<SelectModelOutput>> FindProtectionDeviceForSelect(Guid stationId);
/// <summary>
/// 获取装置事件类型
/// </summary>
/// <param name="deviceAddr"></param>
/// <param name="eventCode"></param>
/// <returns></returns>
RequestResult<EquipmentInfoAbnormalComponent> GetDeviceEventType(int deviceAddr, int eventCode);
}
}

View File

@ -893,7 +893,7 @@ namespace YunDa.ISAS.Application.GeneralInformation
return rst;
}
/// <summary>
/// 获取装置时间类型
/// 获取装置事件类型
/// </summary>
/// <param name="deviceAddr"></param>
/// <param name="eventCode"></param>
@ -928,7 +928,7 @@ namespace YunDa.ISAS.Application.GeneralInformation
catch (Exception ex)
{
rst.Message = ex.Message;
Log4Helper.Error(this.GetType(), "线路管理服务", ex);
Log4Helper.Error(this.GetType(), "获取装置事件类型", ex);
}
return rst;
}

View File

@ -0,0 +1,60 @@
using Abp.Application.Services.Dto;
using MessagePack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YunDa.SOMS.DataTransferObject.CommonDto
{
[MessagePackObject(keyAsPropertyName: true)]
public class NameValueProperty : NameValueProperty<string>
{
public NameValueProperty()
{
}
public NameValueProperty(string name, string value)
{
Name = name;
Value = value;
}
}
[MessagePackObject(keyAsPropertyName: true)]
public class NameValueProperty<T>
{
public string Name { get; set; }
public T Value { get; set; }
public NameValueProperty()
{
}
public NameValueProperty(string name, T value)
{
Name = name;
Value = value;
}
}
[MessagePackObject(keyAsPropertyName: true)]
public class NameIntValueProperty
{
public string Name { get; set; }
public int Value { get; set; }
public NameIntValueProperty()
{
}
public NameIntValueProperty(string name, int value)
{
Name = name;
Value = value;
}
}
}

View File

@ -8,7 +8,17 @@ namespace YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationRepo
{
public class BCodeAndNTP
{
/// <summary>
/// 设备Id
/// </summary>
public Guid EquipmentInfoId { get; set; }
/// <summary>
/// B码是否成功
/// </summary>
public bool BCode { get; set; }
/// <summary>
/// NTP是否成功
/// </summary>
public bool NTP { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using MessagePack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using YunDa.SOMS.DataTransferObject.CommonDto;
namespace YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport
{
[MessagePackObject(keyAsPropertyName: true)]
public class DeviceBoardStates
{
public Guid EquipmentInfoId { get; set; }
public string EquipmentInfoName { get; set; }
public List<NameIntValueProperty> States { get; set; }
[MessagePackFormatter(typeof(DateTimeAsUnixTimeFormatter))]
public DateTime Time { get; set; }
}
}

View File

@ -15625,6 +15625,21 @@
设备名称。
</summary>
</member>
<member name="P:YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport.BCodeAndNTP.EquipmentInfoId">
<summary>
设备Id
</summary>
</member>
<member name="P:YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport.BCodeAndNTP.BCode">
<summary>
B码是否成功
</summary>
</member>
<member name="P:YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport.BCodeAndNTP.NTP">
<summary>
NTP是否成功
</summary>
</member>
<member name="T:YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport.DeviceCPUMonitoring">
<summary>
装置监视数据

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbADbinfo
{
public int? Id { get; set; }
public int? RecordIndex { get; set; }
public string? Crcprogram { get; set; }
public int? VerInfo { get; set; }
public int? Status { get; set; }
public string? UpdateWhat { get; set; }
public string? UpdateWho { get; set; }
public string? DatetimeUpdateWhen { get; set; }
public int? DeviceTypeCode { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbActionFlag
{
public int? DeviceTypeCode { get; set; }
public int? ActionFlag { get; set; }
public string? ActionDesc { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbContactDi
{
public int? DeviceTypeCode { get; set; }
public int? Bit { get; set; }
public string? Title { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbContactDo
{
public int? DeviceTypeCode { get; set; }
public int? Bit { get; set; }
public string? Title { get; set; }
}

View File

@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbCpufpga
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? Ver { get; set; }
public int? SendDelay { get; set; }
public int? OutTimerSource { get; set; }
public int? Ft3dataBaudRate { get; set; }
public int? Ft3delayTime { get; set; }
public int? Ft3volRatio { get; set; }
public int? MultiplierCh1 { get; set; }
public int? ZeroDriftCh1 { get; set; }
public int? MultiplierCh2 { get; set; }
public int? ZeroDriftCh2 { get; set; }
public int? MultiplierCh3 { get; set; }
public int? ZeroDriftCh3 { get; set; }
public int? MultiplierCh4 { get; set; }
public int? ZeroDriftCh4 { get; set; }
public int? MultiplierCh5 { get; set; }
public int? ZeroDriftCh5 { get; set; }
public int? MultiplierCh6 { get; set; }
public int? ZeroDriftCh6 { get; set; }
public int? MultiplierCh7 { get; set; }
public int? ZeroDriftCh7 { get; set; }
public int? MultiplierCh8 { get; set; }
public int? ZeroDriftCh8 { get; set; }
public int? MultiplierCh9 { get; set; }
public int? ZeroDriftCh9 { get; set; }
public int? MultiplierCh10 { get; set; }
public int? ZeroDriftCh10 { get; set; }
public int? MultiplierCh11 { get; set; }
public int? ZeroDriftCh11 { get; set; }
public int? MultiplierCh12 { get; set; }
public int? ZeroDriftCh12 { get; set; }
public int? MultiplierCh13 { get; set; }
public int? ZeroDriftCh13 { get; set; }
public int? MultiplierCh14 { get; set; }
public int? ZeroDriftCh14 { get; set; }
public int? MultiplierCh15 { get; set; }
public int? ZeroDriftCh15 { get; set; }
public int? MultiplierCh16 { get; set; }
public int? ZeroDriftCh16 { get; set; }
public int? MappingCh1 { get; set; }
public int? MappingCh2 { get; set; }
public int? MappingCh3 { get; set; }
public int? MappingCh4 { get; set; }
public int? MappingCh5 { get; set; }
public int? MappingCh6 { get; set; }
public int? MappingCh7 { get; set; }
public int? MappingCh8 { get; set; }
public int? MappingCh9 { get; set; }
public int? MappingCh10 { get; set; }
public int? MappingCh11 { get; set; }
public int? MappingCh12 { get; set; }
public string? MappingCh13 { get; set; }
public int? MappingCh14 { get; set; }
public int? MappingCh15 { get; set; }
public int? MappingCh16 { get; set; }
public int? MappingCh17 { get; set; }
public int? MappingCh18 { get; set; }
public int? MappingCh19 { get; set; }
public int? MappingCh20 { get; set; }
public int? MappingCh21 { get; set; }
public int? MappingCh22 { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDevCat
{
public int? Id { get; set; }
public int? DeviceCat { get; set; }
public string? Desc { get; set; }
}

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDeviceType
{
public int? DeviceTypeCode { get; set; }
public string? DeviceName { get; set; }
public int? DeviceCategory { get; set; }
public int? In2 { get; set; }
public int? Un2 { get; set; }
public string? BoolDkjltable { get; set; }
public string? BoolQlxltable { get; set; }
public string? ShortName { get; set; }
public string? Pname { get; set; }
public string? Io1type { get; set; }
public string? Io2type { get; set; }
public string? Io3type { get; set; }
public string? Io4type { get; set; }
public int? RefDeviceEvent { get; set; }
public string? BoolHaveTouTui { get; set; }
public int? TouTuiChl { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDzDkjl
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public string? SqlGroup { get; set; }
public string? Dzname { get; set; }
public string? ValMin { get; set; }
public string? ValMax { get; set; }
public string? Uint2 { get; set; }
public string? Uint1 { get; set; }
public int? DztypeCode { get; set; }
public int? EnumId { get; set; }
public string? DefaultVal { get; set; }
public double? Scale2 { get; set; }
public double? Scale1 { get; set; }
public int? RelCt2 { get; set; }
public int? RelCt1 { get; set; }
public int? RelPt2 { get; set; }
public int? RelPt1 { get; set; }
public int? Ptctindex { get; set; }
public string? BoolVisable { get; set; }
public string? BoolModify { get; set; }
public string? Lcdname { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDzKzz
{
public int? DeviceTypeCode { get; set; }
public int? SqlGroup { get; set; }
public int? SqlIndex { get; set; }
public string? YabanName { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDzSconf
{
public double? Id { get; set; }
public double? DeviceTypeCode { get; set; }
public double? SqlIndex { get; set; }
public string? SqlGroup { get; set; }
public string? Dzname { get; set; }
public string? ValMin { get; set; }
public string? ValMax { get; set; }
public string? Uint2 { get; set; }
public string? Uint1 { get; set; }
public double? DztypeCode { get; set; }
public double? EnumId { get; set; }
public decimal? DefaultVal { get; set; }
public double? Scale2 { get; set; }
public double? Scale1 { get; set; }
public string? RelCt2 { get; set; }
public string? RelCt1 { get; set; }
public string? RelPt2 { get; set; }
public string? RelPt1 { get; set; }
public string? Ptctindex { get; set; }
public string? BoolVisable { get; set; }
public string? BoolModify { get; set; }
public string? Lcdname { get; set; }
public string? LcdnameBt { get; set; }
public string? Lcden { get; set; }
public string? Lcdenbt { get; set; }
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDzSy
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public string? SqlGroup { get; set; }
public string? Dzname { get; set; }
public string? ValMin { get; set; }
public string? ValMax { get; set; }
public string? Uint2 { get; set; }
public string? Uint1 { get; set; }
public int? DztypeCode { get; set; }
public int? EnumId { get; set; }
public string? DefaultVal { get; set; }
public double? Scale2 { get; set; }
public double? Scale1 { get; set; }
public int? RelCt2 { get; set; }
public int? RelCt1 { get; set; }
public int? RelPt2 { get; set; }
public int? RelPt1 { get; set; }
public int? Ptctindex { get; set; }
public string? BoolVisable { get; set; }
public string? BoolModify { get; set; }
public string? Lcdname { get; set; }
public string? LcdnameBt { get; set; }
public string? Lcden { get; set; }
public string? Lcdenbt { get; set; }
}

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDzUser
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public string? SqlGroup { get; set; }
public string? Dzname { get; set; }
public string? ValMin { get; set; }
public string? ValMax { get; set; }
public string? Uint2 { get; set; }
public string? Uint1 { get; set; }
public int? DztypeCode { get; set; }
public int? EnumId { get; set; }
public string? DefaultVal { get; set; }
public double? Scale2 { get; set; }
public double? Scale1 { get; set; }
public int? RelCt2 { get; set; }
public int? RelCt1 { get; set; }
public int? RelPt2 { get; set; }
public int? RelPt1 { get; set; }
public int? Ptctindex { get; set; }
public string? BoolVisable { get; set; }
public string? BoolModify { get; set; }
public string? Lcdname { get; set; }
public string? LcdnameBt { get; set; }
public string? Lcden { get; set; }
public string? Lcdenbt { get; set; }
public int? Coeffi { get; set; }
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDzYxset
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public string? SqlGroup { get; set; }
public string? Dzname { get; set; }
public double? ValMin { get; set; }
public double? ValMax { get; set; }
public string? Uint1 { get; set; }
public string? Uint2 { get; set; }
public int? DztypeCode { get; set; }
public int? EnumId { get; set; }
public string? DefaultVal { get; set; }
public int? Scale1 { get; set; }
public int? Scale2 { get; set; }
public int? RelativePt { get; set; }
public int? RelativeCt { get; set; }
public string? BoolVisable { get; set; }
public string? BoolModify { get; set; }
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDzenum
{
public int? DzenumId { get; set; }
public string? DzenmuIddesc { get; set; }
public int? DzenumValue { get; set; }
public string? DzenumName { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbDztype
{
public int? DztypeCode { get; set; }
public string? DztypeName { get; set; }
public int? Dzlength { get; set; }
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbEventBh
{
public double? DeviceTypeCode { get; set; }
public double? EventCode { get; set; }
public string? Event { get; set; }
public string? Lcdevent { get; set; }
public int? DeviceCat { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbEventZj
{
public int? DeciceTypeCode { get; set; }
public int? SelfCheckCode { get; set; }
public string? Description { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbFpgatype
{
public int? TypeId { get; set; }
public string? TypeDesc { get; set; }
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbGckg
{
public int? SqlIndex { get; set; }
public string? Name { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbGcmodel
{
public int? SqlIndex { get; set; }
public string? ModelName { get; set; }
public string? ModelValue { get; set; }
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbGooseCd
{
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Channel { get; set; }
public string? ChannelName { get; set; }
public int? YxIndex { get; set; }
public int? Board { get; set; }
public int? Type { get; set; }
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbGooseKc
{
public int? DeviceTypeCode { get; set; }
public string? Kcduanzi { get; set; }
public int? SqlIndex { get; set; }
public string? Kcname { get; set; }
public string? InVarName { get; set; }
public string? Board { get; set; }
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbGooseKr
{
public int? DeviceTypeCode { get; set; }
public string? Krduanzi { get; set; }
public int? SqlIndex { get; set; }
public string? Krtype { get; set; }
public string? Krname { get; set; }
public string? InVarName { get; set; }
public string? Bit { get; set; }
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbKc
{
public int? DeviceTypeCode { get; set; }
public string? Kcduanzi { get; set; }
public int? SqlIndex { get; set; }
public string? Kcname { get; set; }
public string? Board { get; set; }
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbKctest
{
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Channel { get; set; }
public string? ChannelName { get; set; }
public int? YxIndex { get; set; }
public int? Board { get; set; }
public int? Type { get; set; }
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbKdadjust
{
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Channel { get; set; }
public string? ChannelName { get; set; }
public double? Value5A { get; set; }
public int? Ycindex { get; set; }
public int? Value1A { get; set; }
public int? Value5V { get; set; }
public int? Value10V { get; set; }
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbKr
{
public int? DeviceTypeCode { get; set; }
public string? Krduanzi { get; set; }
public int? CommIndex { get; set; }
public int? BoardIndex { get; set; }
public string? Krname { get; set; }
public int? DisplayIndex { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbKrtx
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public string? SetStr { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbKxzttd
{
public int? Id { get; set; }
public int? TongDaoHao { get; set; }
public string? TongDaoName { get; set; }
public string? TimeAllow { get; set; }
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbLanguage
{
public int? { get; set; }
public int? SqlIndex { get; set; }
public string? LanguageName1 { get; set; }
public string? LanguageName2 { get; set; }
public string? Code { get; set; }
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbLight
{
public int? { get; set; }
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Type { get; set; }
public string? Name { get; set; }
public int? Color { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbTable
{
public int? { get; set; }
public string? { get; set; }
public string? { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbUpdateLog
{
public int? Id { get; set; }
public string? Editor { get; set; }
public string? DatetimeUpdDate { get; set; }
public string? UpdDesc { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbUser
{
public int? Id { get; set; }
public string? UserName { get; set; }
public string? SqlGroup { get; set; }
public string? Password { get; set; }
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbWaveDefine
{
public int? SqlIndex { get; set; }
public int? DeviceTypeCode { get; set; }
public int? ChannelId { get; set; }
public string? ChannelName { get; set; }
public string? Unit1 { get; set; }
public string? Unit2 { get; set; }
public string? ChannelNameB { get; set; }
public string? ChannelType { get; set; }
public string? Lcden { get; set; }
public string? Lcdebbt { get; set; }
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbXieboDlzl
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? Line { get; set; }
public int? Col { get; set; }
public string? XieBoName { get; set; }
public string? XieBoFuhao { get; set; }
public int? Type { get; set; }
public string? Unit { get; set; }
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbYabanTest
{
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Channel { get; set; }
public string? ChannelName { get; set; }
public int? YxIndex { get; set; }
public int? Board { get; set; }
public int? Type { get; set; }
public string? Lcden { get; set; }
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbYc
{
public int? Id { get; set; }
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Jzchannel { get; set; }
public string? Duanzi { get; set; }
public string? InVarName { get; set; }
public int? Jzvalue { get; set; }
public int? Jzvalue1A { get; set; }
public int? Jzvalue5A { get; set; }
public string? Ycname { get; set; }
public int? Coeff { get; set; }
public string? Unit { get; set; }
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbYctype
{
public int? Yctype { get; set; }
public string? Ycname { get; set; }
public string? Yccategory { get; set; }
public string? Uint1 { get; set; }
public string? Uint2 { get; set; }
public int? Coeff1 { get; set; }
public int? Coeff2 { get; set; }
public string? YcnameB { get; set; }
public string? YccategoryB { get; set; }
public int? DeviceCat { get; set; }
public string? EnumStr { get; set; }
public int? DeviceTypeCode { get; set; }
public string? Lcden { get; set; }
public string? Lcdenb { get; set; }
public string? Type { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbYcunit
{
public int? SqlIndex { get; set; }
public string? SiuintValue { get; set; }
public string? Siuint { get; set; }
public string? Name { get; set; }
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbYk
{
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Inf { get; set; }
public string? CtrlType { get; set; }
public string? ObjectName { get; set; }
public string? Type { get; set; }
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbYx
{
public int? DeviceTypeCode { get; set; }
public int? SqlIndex { get; set; }
public int? Inf { get; set; }
public string? ObjectName { get; set; }
public string? CloseText { get; set; }
public string? OpenText { get; set; }
public int? Type { get; set; }
public string? BoolVisable { get; set; }
public string? BoolIsBsinfo { get; set; }
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbZtlj
{
public int? { get; set; }
public int? SqlIndex { get; set; }
public string? Kgid { get; set; }
public string? Kgconfig { get; set; }
public string? Kgname { get; set; }
public int? Kgpos { get; set; }
public int? Kgtype { get; set; }
public string? Desc { get; set; }
public int? PosOnly { get; set; }
public int? TypeOnly { get; set; }
public int? DeviceTypeCode { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbZyb
{
public int? DeviceTypeCode { get; set; }
public double? SqlIndex { get; set; }
public string? ChannelName { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace YunDa.SOMS.ProDB.Models;
public partial class TbZyl
{
public double? DeviceTypeCode { get; set; }
public double? SqlIndex { get; set; }
public double? LiansuoChannel { get; set; }
public string? LiansuoDesc { get; set; }
}

View File

@ -0,0 +1,10 @@
namespace YunDa.SOMS.ProDB
{
internal class Program
{
static void Main(string[] args)
{
//Console.WriteLine("Hello, World!");
}
}
}

View File

@ -0,0 +1,709 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using YunDa.SOMS.ProDB.Models;
namespace YunDa.SOMS.ProDB;
public partial class ProtdbContext : DbContext
{
private readonly string _databasePath;
public ProtdbContext(string databasePath)
{
_databasePath = databasePath;
}
public ProtdbContext(DbContextOptions<ProtdbContext> options)
: base(options)
{
}
public virtual DbSet<TbADbinfo> TbADbinfos { get; set; }
public virtual DbSet<TbActionFlag> TbActionFlags { get; set; }
public virtual DbSet<TbContactDi> TbContactDis { get; set; }
public virtual DbSet<TbContactDo> TbContactDos { get; set; }
public virtual DbSet<TbCpufpga> TbCpufpgas { get; set; }
public virtual DbSet<TbDevCat> TbDevCats { get; set; }
public virtual DbSet<TbDeviceType> TbDeviceTypes { get; set; }
public virtual DbSet<TbDzDkjl> TbDzDkjls { get; set; }
public virtual DbSet<TbDzKzz> TbDzKzzs { get; set; }
public virtual DbSet<TbDzSconf> TbDzSconfs { get; set; }
public virtual DbSet<TbDzSy> TbDzSys { get; set; }
public virtual DbSet<TbDzUser> TbDzUsers { get; set; }
public virtual DbSet<TbDzYxset> TbDzYxsets { get; set; }
public virtual DbSet<TbDzenum> TbDzenums { get; set; }
public virtual DbSet<TbDztype> TbDztypes { get; set; }
public virtual DbSet<TbEventBh> TbEventBhs { get; set; }
public virtual DbSet<TbEventZj> TbEventZjs { get; set; }
public virtual DbSet<TbFpgatype> TbFpgatypes { get; set; }
public virtual DbSet<TbGckg> TbGckgs { get; set; }
public virtual DbSet<TbGcmodel> TbGcmodels { get; set; }
public virtual DbSet<TbGooseCd> TbGooseCds { get; set; }
public virtual DbSet<TbGooseKc> TbGooseKcs { get; set; }
public virtual DbSet<TbGooseKr> TbGooseKrs { get; set; }
public virtual DbSet<TbKc> TbKcs { get; set; }
public virtual DbSet<TbKctest> TbKctests { get; set; }
public virtual DbSet<TbKdadjust> TbKdadjusts { get; set; }
public virtual DbSet<TbKr> TbKrs { get; set; }
public virtual DbSet<TbKrtx> TbKrtxes { get; set; }
public virtual DbSet<TbKxzttd> TbKxzttds { get; set; }
public virtual DbSet<TbLanguage> TbLanguages { get; set; }
public virtual DbSet<TbLight> TbLights { get; set; }
public virtual DbSet<TbTable> TbTables { get; set; }
public virtual DbSet<TbUpdateLog> TbUpdateLogs { get; set; }
public virtual DbSet<TbUser> TbUsers { get; set; }
public virtual DbSet<TbWaveDefine> TbWaveDefines { get; set; }
public virtual DbSet<TbXieboDlzl> TbXieboDlzls { get; set; }
public virtual DbSet<TbYabanTest> TbYabanTests { get; set; }
public virtual DbSet<TbYc> TbYcs { get; set; }
public virtual DbSet<TbYctype> TbYctypes { get; set; }
public virtual DbSet<TbYcunit> TbYcunits { get; set; }
public virtual DbSet<TbYk> TbYks { get; set; }
public virtual DbSet<TbYx> TbYxes { get; set; }
public virtual DbSet<TbZtlj> TbZtljs { get; set; }
public virtual DbSet<TbZyb> TbZybs { get; set; }
public virtual DbSet<TbZyl> TbZyls { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data Source={_databasePath}");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<TbADbinfo>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_A_DBinfo");
entity.Property(e => e.Crcprogram).HasColumnName("CRCProgram");
entity.Property(e => e.DatetimeUpdateWhen).HasColumnName("datetime_UpdateWhen");
entity.Property(e => e.Id).HasColumnName("ID");
});
modelBuilder.Entity<TbActionFlag>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_ActionFlag");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
});
modelBuilder.Entity<TbContactDi>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_Contact_DI");
});
modelBuilder.Entity<TbContactDo>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_Contact_DO");
});
modelBuilder.Entity<TbCpufpga>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_CPUFPGA");
entity.Property(e => e.Ft3dataBaudRate).HasColumnName("FT3DataBaudRate");
entity.Property(e => e.Ft3delayTime).HasColumnName("FT3DelayTime");
entity.Property(e => e.Ft3volRatio).HasColumnName("FT3VolRatio");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.MappingCh1).HasColumnName("MappingCH1");
entity.Property(e => e.MappingCh10).HasColumnName("MappingCH10");
entity.Property(e => e.MappingCh11).HasColumnName("MappingCH11");
entity.Property(e => e.MappingCh12).HasColumnName("MappingCH12");
entity.Property(e => e.MappingCh13).HasColumnName("MappingCH13");
entity.Property(e => e.MappingCh14).HasColumnName("MappingCH14");
entity.Property(e => e.MappingCh15).HasColumnName("MappingCH15");
entity.Property(e => e.MappingCh16).HasColumnName("MappingCH16");
entity.Property(e => e.MappingCh17).HasColumnName("MappingCH17");
entity.Property(e => e.MappingCh18).HasColumnName("MappingCH18");
entity.Property(e => e.MappingCh19).HasColumnName("MappingCH19");
entity.Property(e => e.MappingCh2).HasColumnName("MappingCH2");
entity.Property(e => e.MappingCh20).HasColumnName("MappingCH20");
entity.Property(e => e.MappingCh21).HasColumnName("MappingCH21");
entity.Property(e => e.MappingCh22).HasColumnName("MappingCH22");
entity.Property(e => e.MappingCh3).HasColumnName("MappingCH3");
entity.Property(e => e.MappingCh4).HasColumnName("MappingCH4");
entity.Property(e => e.MappingCh5).HasColumnName("MappingCH5");
entity.Property(e => e.MappingCh6).HasColumnName("MappingCH6");
entity.Property(e => e.MappingCh7).HasColumnName("MappingCH7");
entity.Property(e => e.MappingCh8).HasColumnName("MappingCH8");
entity.Property(e => e.MappingCh9).HasColumnName("MappingCH9");
entity.Property(e => e.MultiplierCh1).HasColumnName("MultiplierCH1");
entity.Property(e => e.MultiplierCh10).HasColumnName("MultiplierCH10");
entity.Property(e => e.MultiplierCh11).HasColumnName("MultiplierCH11");
entity.Property(e => e.MultiplierCh12).HasColumnName("MultiplierCH12");
entity.Property(e => e.MultiplierCh13).HasColumnName("MultiplierCH13");
entity.Property(e => e.MultiplierCh14).HasColumnName("MultiplierCH14");
entity.Property(e => e.MultiplierCh15).HasColumnName("MultiplierCH15");
entity.Property(e => e.MultiplierCh16).HasColumnName("MultiplierCH16");
entity.Property(e => e.MultiplierCh2).HasColumnName("MultiplierCH2");
entity.Property(e => e.MultiplierCh3).HasColumnName("MultiplierCH3");
entity.Property(e => e.MultiplierCh4).HasColumnName("MultiplierCH4");
entity.Property(e => e.MultiplierCh5).HasColumnName("MultiplierCH5");
entity.Property(e => e.MultiplierCh6).HasColumnName("MultiplierCH6");
entity.Property(e => e.MultiplierCh7).HasColumnName("MultiplierCH7");
entity.Property(e => e.MultiplierCh8).HasColumnName("MultiplierCH8");
entity.Property(e => e.MultiplierCh9).HasColumnName("MultiplierCH9");
entity.Property(e => e.ZeroDriftCh1).HasColumnName("ZeroDriftCH1");
entity.Property(e => e.ZeroDriftCh10).HasColumnName("ZeroDriftCH10");
entity.Property(e => e.ZeroDriftCh11).HasColumnName("ZeroDriftCH11");
entity.Property(e => e.ZeroDriftCh12).HasColumnName("ZeroDriftCH12");
entity.Property(e => e.ZeroDriftCh13).HasColumnName("ZeroDriftCH13");
entity.Property(e => e.ZeroDriftCh14).HasColumnName("ZeroDriftCH14");
entity.Property(e => e.ZeroDriftCh15).HasColumnName("ZeroDriftCH15");
entity.Property(e => e.ZeroDriftCh16).HasColumnName("ZeroDriftCH16");
entity.Property(e => e.ZeroDriftCh2).HasColumnName("ZeroDriftCH2");
entity.Property(e => e.ZeroDriftCh3).HasColumnName("ZeroDriftCH3");
entity.Property(e => e.ZeroDriftCh4).HasColumnName("ZeroDriftCH4");
entity.Property(e => e.ZeroDriftCh5).HasColumnName("ZeroDriftCH5");
entity.Property(e => e.ZeroDriftCh6).HasColumnName("ZeroDriftCH6");
entity.Property(e => e.ZeroDriftCh7).HasColumnName("ZeroDriftCH7");
entity.Property(e => e.ZeroDriftCh8).HasColumnName("ZeroDriftCH8");
entity.Property(e => e.ZeroDriftCh9).HasColumnName("ZeroDriftCH9");
});
modelBuilder.Entity<TbDevCat>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DevCat");
entity.Property(e => e.Id).HasColumnName("ID");
});
modelBuilder.Entity<TbDeviceType>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DeviceType");
entity.Property(e => e.BoolDkjltable).HasColumnName("bool_DKJLTable");
entity.Property(e => e.BoolHaveTouTui).HasColumnName("bool_HaveTouTui");
entity.Property(e => e.BoolQlxltable).HasColumnName("bool_QLXLTable");
entity.Property(e => e.Io1type).HasColumnName("IO1Type");
entity.Property(e => e.Io2type).HasColumnName("IO2Type");
entity.Property(e => e.Io3type).HasColumnName("IO3Type");
entity.Property(e => e.Io4type).HasColumnName("IO4Type");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.Pname).HasColumnName("PName");
});
modelBuilder.Entity<TbDzDkjl>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZ_Dkjl");
entity.Property(e => e.BoolModify).HasColumnName("bool_Modify");
entity.Property(e => e.BoolVisable).HasColumnName("bool_Visable");
entity.Property(e => e.Dzname).HasColumnName("DZName");
entity.Property(e => e.DztypeCode).HasColumnName("DZTypeCode");
entity.Property(e => e.EnumId).HasColumnName("EnumID");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.Lcdname).HasColumnName("LCDName");
entity.Property(e => e.Ptctindex).HasColumnName("PTCTIndex");
entity.Property(e => e.RelCt1).HasColumnName("RelCT1");
entity.Property(e => e.RelCt2).HasColumnName("RelCT2");
entity.Property(e => e.RelPt1).HasColumnName("RelPT1");
entity.Property(e => e.RelPt2).HasColumnName("RelPT2");
entity.Property(e => e.SqlGroup).HasColumnName("sql_Group");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbDzKzz>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZ_Kzz");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.SqlGroup).HasColumnName("sql_Group");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbDzSconf>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZ_SConf");
entity.Property(e => e.BoolModify).HasColumnName("bool_Modify");
entity.Property(e => e.BoolVisable).HasColumnName("bool_Visable");
entity.Property(e => e.Dzname).HasColumnName("DZName");
entity.Property(e => e.DztypeCode).HasColumnName("DZTypeCode");
entity.Property(e => e.EnumId).HasColumnName("EnumID");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.Lcdenbt).HasColumnName("LCDENBT");
entity.Property(e => e.Lcdname).HasColumnName("LCDName");
entity.Property(e => e.LcdnameBt).HasColumnName("LCDNameBT");
entity.Property(e => e.Ptctindex).HasColumnName("PTCTIndex");
entity.Property(e => e.RelCt1).HasColumnName("RelCT1");
entity.Property(e => e.RelCt2).HasColumnName("RelCT2");
entity.Property(e => e.RelPt1).HasColumnName("RelPT1");
entity.Property(e => e.RelPt2).HasColumnName("RelPT2");
entity.Property(e => e.SqlGroup).HasColumnName("sql_Group");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbDzSy>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZ_Sys");
entity.Property(e => e.BoolModify).HasColumnName("bool_Modify");
entity.Property(e => e.BoolVisable).HasColumnName("bool_Visable");
entity.Property(e => e.Dzname).HasColumnName("DZName");
entity.Property(e => e.DztypeCode).HasColumnName("DZTypeCode");
entity.Property(e => e.EnumId).HasColumnName("EnumID");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.Lcdenbt).HasColumnName("LCDENBT");
entity.Property(e => e.Lcdname).HasColumnName("LCDName");
entity.Property(e => e.LcdnameBt).HasColumnName("LCDNameBT");
entity.Property(e => e.Ptctindex).HasColumnName("PTCTIndex");
entity.Property(e => e.RelCt1).HasColumnName("RelCT1");
entity.Property(e => e.RelCt2).HasColumnName("RelCT2");
entity.Property(e => e.RelPt1).HasColumnName("RelPT1");
entity.Property(e => e.RelPt2).HasColumnName("RelPT2");
entity.Property(e => e.SqlGroup).HasColumnName("sql_Group");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbDzUser>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZ_User");
entity.Property(e => e.BoolModify).HasColumnName("bool_Modify");
entity.Property(e => e.BoolVisable).HasColumnName("bool_Visable");
entity.Property(e => e.Dzname).HasColumnName("DZName");
entity.Property(e => e.DztypeCode).HasColumnName("DZTypeCode");
entity.Property(e => e.EnumId).HasColumnName("EnumID");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.Lcdenbt).HasColumnName("LCDENBT");
entity.Property(e => e.Lcdname).HasColumnName("LCDName");
entity.Property(e => e.LcdnameBt).HasColumnName("LCDNameBT");
entity.Property(e => e.Ptctindex).HasColumnName("PTCTIndex");
entity.Property(e => e.RelCt1).HasColumnName("RelCT1");
entity.Property(e => e.RelCt2).HasColumnName("RelCT2");
entity.Property(e => e.RelPt1).HasColumnName("RelPT1");
entity.Property(e => e.RelPt2).HasColumnName("RelPT2");
entity.Property(e => e.SqlGroup).HasColumnName("sql_Group");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbDzYxset>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZ_YXSet");
entity.Property(e => e.BoolModify).HasColumnName("bool_Modify");
entity.Property(e => e.BoolVisable).HasColumnName("bool_Visable");
entity.Property(e => e.Dzname).HasColumnName("DZName");
entity.Property(e => e.DztypeCode).HasColumnName("DZTypeCode");
entity.Property(e => e.EnumId).HasColumnName("EnumID");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.RelativeCt).HasColumnName("RelativeCT");
entity.Property(e => e.RelativePt).HasColumnName("RelativePT");
entity.Property(e => e.SqlGroup).HasColumnName("sql_Group");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbDzenum>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZEnum");
entity.Property(e => e.DzenmuIddesc).HasColumnName("DZEnmuIDDesc");
entity.Property(e => e.DzenumId).HasColumnName("DZEnumID");
entity.Property(e => e.DzenumName).HasColumnName("DZEnumName");
entity.Property(e => e.DzenumValue).HasColumnName("DZEnumValue");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
});
modelBuilder.Entity<TbDztype>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_DZType");
entity.Property(e => e.Dzlength).HasColumnName("DZlength");
entity.Property(e => e.DztypeCode).HasColumnName("DZTypeCode");
entity.Property(e => e.DztypeName).HasColumnName("DZTypeName");
});
modelBuilder.Entity<TbEventBh>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_Event_BH");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.Lcdevent).HasColumnName("LCDEvent");
});
modelBuilder.Entity<TbEventZj>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_Event_ZJ");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
});
modelBuilder.Entity<TbFpgatype>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_FPGAType");
entity.Property(e => e.TypeId).HasColumnName("TypeID");
});
modelBuilder.Entity<TbGckg>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_GCKG");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbGcmodel>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_GCModel");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbGooseCd>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_GOOSE_CD");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbGooseKc>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_GOOSE_KC");
entity.Property(e => e.Kcduanzi).HasColumnName("KCDuanzi");
entity.Property(e => e.Kcname).HasColumnName("KCname");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbGooseKr>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_GOOSE_KR");
entity.Property(e => e.Krduanzi).HasColumnName("KRDuanzi");
entity.Property(e => e.Krname).HasColumnName("KRName");
entity.Property(e => e.Krtype).HasColumnName("KRType");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbKc>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_KC");
entity.Property(e => e.Kcduanzi).HasColumnName("KCDuanzi");
entity.Property(e => e.Kcname).HasColumnName("KCname");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbKctest>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_KCTest");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbKdadjust>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_KDAdjust");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
entity.Property(e => e.Ycindex).HasColumnName("YCIndex");
});
modelBuilder.Entity<TbKr>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_KR");
entity.Property(e => e.Krduanzi).HasColumnName("KRDuanzi");
entity.Property(e => e.Krname).HasColumnName("KRName");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
});
modelBuilder.Entity<TbKrtx>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_KRTX");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbKxzttd>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_KXZTTD");
entity.Property(e => e.Id).HasColumnName("ID");
});
modelBuilder.Entity<TbLanguage>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_Language");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbLight>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_Lights");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbTable>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_tables");
});
modelBuilder.Entity<TbUpdateLog>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_UpdateLog");
entity.Property(e => e.DatetimeUpdDate).HasColumnName("datetime_UpdDate");
entity.Property(e => e.Id).HasColumnName("ID");
});
modelBuilder.Entity<TbUser>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_User");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Password).HasColumnName("password");
entity.Property(e => e.SqlGroup).HasColumnName("sql_group");
entity.Property(e => e.UserName).HasColumnName("userName");
});
modelBuilder.Entity<TbWaveDefine>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_WaveDefine");
entity.Property(e => e.ChannelId).HasColumnName("ChannelID");
entity.Property(e => e.Lcdebbt).HasColumnName("LCDEBBT");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbXieboDlzl>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_xiebo_DLZL");
entity.Property(e => e.Id).HasColumnName("ID");
});
modelBuilder.Entity<TbYabanTest>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_YabanTest");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbYc>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_YC");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Jzchannel).HasColumnName("JZChannel");
entity.Property(e => e.Jzvalue).HasColumnName("JZValue");
entity.Property(e => e.Jzvalue1A).HasColumnName("JZValue1A");
entity.Property(e => e.Jzvalue5A).HasColumnName("JZValue5A");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
entity.Property(e => e.Ycname).HasColumnName("YCName");
});
modelBuilder.Entity<TbYctype>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_YCType");
entity.Property(e => e.Lcden).HasColumnName("LCDEN");
entity.Property(e => e.Lcdenb).HasColumnName("LCDENB");
entity.Property(e => e.Yccategory).HasColumnName("YCCategory");
entity.Property(e => e.YccategoryB).HasColumnName("YCCategoryB");
entity.Property(e => e.Ycname).HasColumnName("YCName");
entity.Property(e => e.YcnameB).HasColumnName("YCNameB");
entity.Property(e => e.Yctype).HasColumnName("YCType");
});
modelBuilder.Entity<TbYcunit>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_YCUnit");
entity.Property(e => e.Siuint).HasColumnName("SIUint");
entity.Property(e => e.SiuintValue).HasColumnName("SIUintValue");
entity.Property(e => e.SqlIndex).HasColumnName("sql_index");
});
modelBuilder.Entity<TbYk>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_YK");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbYx>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_YX");
entity.Property(e => e.BoolIsBsinfo).HasColumnName("bool_isBSInfo");
entity.Property(e => e.BoolVisable).HasColumnName("bool_Visable");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbZtlj>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_ZTLJ");
entity.Property(e => e.Kgconfig).HasColumnName("KGConfig");
entity.Property(e => e.Kgid).HasColumnName("KGID");
entity.Property(e => e.Kgname).HasColumnName("KGName");
entity.Property(e => e.Kgpos).HasColumnName("KGPos");
entity.Property(e => e.Kgtype).HasColumnName("KGType");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbZyb>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_ZYBS");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
modelBuilder.Entity<TbZyl>(entity =>
{
entity
.HasNoKey()
.ToTable("tb_ZYLS");
entity.Property(e => e.SqlIndex).HasColumnName("sql_Index");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
</ItemGroup>
</Project>

View File

@ -13,6 +13,7 @@
<ItemGroup>
<Folder Include="Geneirc\" />
<Folder Include="ProtectionDevice\" />
<Folder Include="CommonUtilities\" />
</ItemGroup>
<ItemGroup>

View File

@ -18,6 +18,7 @@ using YunDa.ISAS.Redis.Entities.PatternRecongnition;
using YunDa.ISAS.Redis.Entities.SortDefines;
using YunDa.ISAS.Redis.Factory;
using YunDa.ISAS.Redis.Repositories;
using YunDa.SOMS.DataTransferObject.CommonDto;
using YunDa.SOMS.DataTransferObject.EquipmentLiveData;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionSettingDto;
@ -62,6 +63,7 @@ namespace YunDa.ISAS.Redis
IocManager.Register<IRedisRepository<HashSet<object>, string>, RedisRepository<HashSet<object>, string>>();
IocManager.Register<IRedisRepository<Dictionary<object, object>, string>, RedisRepository<Dictionary<object, object>, string>>();
IocManager.Register<IRedisRepository<Dictionary<string, string>, string>, RedisRepository<Dictionary<string, string>, string>>();
IocManager.Register<IRedisRepository<Dictionary<string, object>, string>, RedisRepository<Dictionary<string, object>, string>>();
IocManager.Register<IRedisRepository<string, string>, RedisRepository<string, string>>();
IocManager.Register<IRedisRepository<int, string>, RedisRepository<int, string>>();
@ -98,8 +100,11 @@ namespace YunDa.ISAS.Redis
IocManager.Register<IRedisRepository<EquipmentInfoRemainingLifeAssessment, string>, RedisRepository<EquipmentInfoRemainingLifeAssessment, string>>();
IocManager.Register<IRedisRepository<DeviceCPUMonitoring, string>, RedisRepository<DeviceCPUMonitoring, string>>();
IocManager.Register<IRedisRepository<BCodeAndNTP, string>, RedisRepository<BCodeAndNTP, string>>();
IocManager.Register<IRedisRepository<List<NameIntValueProperty>, string>, RedisRepository<List<NameIntValueProperty>, string>>();
IocManager.Register<IRedisRepository<List<NameValueProperty>, string>, RedisRepository<List<NameValueProperty>, string>>();
IocManager.Register<IRedisRepository<DeviceBoardStates, string>, RedisRepository<DeviceBoardStates, string>>();
}
}
}

View File

@ -67,26 +67,18 @@ namespace Yunda.ISAS.DataMonitoringServer
protected override void OnStartup(StartupEventArgs e)
{
try
{
SplashScreen ss = new SplashScreen(@"./Images/splash_screen.png");
ss.Show(true);
_bootstrapper.Initialize();
SplashScreen ss = new SplashScreen(@"./Images/splash_screen.png");
ss.Show(true);
_bootstrapper.Initialize();
_bootstrapper.IocManager.Resolve<MonitoringDataService>();
_bootstrapper.IocManager.Resolve<TimeWorkService>();
_dataWindow = _bootstrapper.IocManager.Resolve<DataWindow>();
//_webApiServer = _bootstrapper.IocManager.Resolve<WebApiServer>();
//_webApiServer = _bootstrapper.IocManager.Resolve<TelecomDataCenter>();
_dataWindow.Show();
ss.Close(new TimeSpan(0, 0, 0, 0));
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
base.OnStartup(e);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
_bootstrapper.IocManager.Resolve<MonitoringDataService>();
_bootstrapper.IocManager.Resolve<TimeWorkService>();
_dataWindow = _bootstrapper.IocManager.Resolve<DataWindow>();
_dataWindow.Show();
ss.Close(new TimeSpan(0, 0, 0, 0));
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
base.OnStartup(e);
}
protected override void OnExit(ExitEventArgs e)

View File

@ -114,11 +114,11 @@ namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis.DataCollection
while (true)
{
await SendDeviceSlefCheckInfo();
await Task.Delay(3000);
await Task.Delay(1000);
await SendSecondaryCircuitDiagnosticsInfo();
await Task.Delay(3000);
await Task.Delay(1000);
await SendEquipmentInfoRemainingLifeAssessmentInfo();
await Task.Delay(3000);
await Task.Delay(1000);
}
});
@ -375,7 +375,6 @@ namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis.DataCollection
}
else
{
Console.WriteLine("装置温度值超出范围, 设置为默认值 60°C");
data.SurfaceTemperature = 60; // 设置为默认温度 60°C
}
}
@ -392,7 +391,6 @@ namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis.DataCollection
{
Random random = new Random();
data.CPU5V1 = (float)(random.NextDouble() * (5.02 - 4.98) + 4.98);
Console.WriteLine($"CPU5V电压1值超出范围, 设置为随机值: {data.CPU5V1}");
}
}
// 校验 5V 电压2
@ -408,7 +406,6 @@ namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis.DataCollection
{
Random random = new Random();
data.CPU5V2 = (float)(random.NextDouble() * (5.02 - 4.98) + 4.98);
Console.WriteLine($"CPU5V电压2值超出范围, 设置为随机值: {data.CPU5V2}");
}
}
// 校验 5V 电压3
@ -426,7 +423,6 @@ namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis.DataCollection
// 设置为随机电压值(假设随机值在 4.78 到 4.82 之间)
Random random = new Random();
data.CPU5V3 = (float)(random.NextDouble() * (5.02 - 4.98) + 5.02);
Console.WriteLine($"CPU5V电压3值超出范围, 设置为随机值: {data.CPU5V3}");
}
}

View File

@ -110,7 +110,9 @@ namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis
if (settingModel.DataSourceCategoryName =="综自")
{
MonitoringEventBus.LogHandler("启动装置定值接口", "装置定值");
PortProcessManager.KillProcessByPort(7110);
PortProcessManager.KillProcessByPort(2403);
await _protectionDeviceDataCenter.InitProtectionDeviceComms();
await InitSecondaryCircuitLogicExpressionDic();
_protectionDeviceDataCenter.InitDevices();
@ -128,10 +130,12 @@ namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis
public void DataServiceStop()
{
_dataCollectionTask.CollectionStop(); //数据采集停止
_dotNettyTcpServer.StopSeverAsync();
_dotNettyTcpServer.StopServerAsync();
if (_settingModel.DataSourceCategoryName == "综自")
{
_protectionDeviceDataCenter.StopAllProcesses();
PortProcessManager.KillProcessByPort(7110);
PortProcessManager.KillProcessByPort(2403);
}
}

View File

@ -8,6 +8,7 @@ using YunDa.ISAS.Redis.Entities.CameraAuthCategory;
using YunDa.ISAS.Redis.Entities.DataMonitorCategory;
using YunDa.ISAS.Redis.Entities.LinkageCategory;
using YunDa.ISAS.Redis.Repositories;
using YunDa.SOMS.DataTransferObject.CommonDto;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
using YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport;
@ -20,6 +21,8 @@ namespace Yunda.ISAS.DataMonitoringServer.DataCenter
public IRedisRepository<AlarmListRedis, string> AlarmListRedis { get; }
public IRedisRepository<EnvironmentTempValue, string> EnvironmentTempValueRedis { get; }
public IRedisRepository<EquipmentDataModel, string> EquipmentDataModelDicRedis { get; }
public IRedisRepository<List<NameIntValueProperty>, string> _deviceBoardStatesRedis;
private readonly WPF.ViewModel.Content _settingModel;
//public string TelemeteringModelInflectionInflectionListRediskey = "telemeteringModelInflectionList";
public string TelemeteringInflectionInflectionZZChannelRediskey = "telemeteringInflection_ZZ_Channel";

View File

@ -73,7 +73,7 @@ namespace Yunda.SOMS.DataMonitoringServer.FTPHandle
// 尝试下载文件到本地
if (client.DownloadFile(localFilePath, remoteFilePath) == FtpStatus.Success)
{
MonitoringEventBus.LogHandler($"Successfully downloaded {fileName} from FTP.", "FTP信息");
//MonitoringEventBus.LogHandler($"Successfully downloaded {fileName} from FTP.", "FTP信息");
// 下载成功,删除失败时间户记录
if (failedDownloadTimestamps.ContainsKey(key))
{
@ -137,7 +137,7 @@ namespace Yunda.SOMS.DataMonitoringServer.FTPHandle
// 检查是否在上次失败之后的1小时内
if (failedDownloadTimestamps.ContainsKey(key) && DateTime.Now - failedDownloadTimestamps[key] < TimeSpan.FromHours(1))
{
MonitoringEventBus.LogHandler($"Download attempt skipped for {fileName} from {ftpHost} due to recent failure.", "FTP信息");
//MonitoringEventBus.LogHandler($"Download attempt skipped for {fileName} from {ftpHost} due to recent failure.", "FTP信息");
return null;
}
@ -153,7 +153,7 @@ namespace Yunda.SOMS.DataMonitoringServer.FTPHandle
{
if (client.DownloadStream(memoryStream, remoteFilePath))
{
MonitoringEventBus.LogHandler($"Successfully downloaded {fileName} from FTP.", "FTP信息");
//MonitoringEventBus.LogHandler($"Successfully downloaded {fileName} from FTP.", "FTP信息");
// 下载成功,删除失败时间记录
if (failedDownloadTimestamps.ContainsKey(key))
{
@ -166,7 +166,7 @@ namespace Yunda.SOMS.DataMonitoringServer.FTPHandle
// 下载失败,记录失败的时间
failedDownloadTimestamps[key] = DateTime.Now;
string msg = $"Download failed for {fileName} from FTP.";
MonitoringEventBus.LogHandler(msg, "FTP信息");
//MonitoringEventBus.LogHandler(msg, "FTP信息");
return null; // 下载失败返回null
}
}

View File

@ -34,37 +34,44 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
_bcodeAndNTPRedis = bcodeAndNTPRedis;
_dotNettyTcpServer.MessageReceived += OnMessageReceived; // 订阅事件
}
private async void OnMessageReceived(byte address, byte[] message, byte functionType)
{
try
{
// 检查是否匹配指定的功能码
if (functionType != 7 && functionType != 6)
{
return; // 如果不是功能码 7 或 6直接返回
}
var device = ProtectionDeviceDataCenter._devices.FirstOrDefault(t => t.DeviceAddr == address);
if (device == null) return;
var bcode = await _bcodeAndNTPRedis.HashSetGetOneAsync(nameof(BCodeAndNTP), address.ToString()) ?? new BCodeAndNTP();
switch (functionType)
bcode.EquipmentInfoId = device.EquipmentInfoId;
// 根据功能码处理逻辑
if (functionType == 7)
{
case 7: // B码对时状态
bcode.BCode = message[1] != 1;
break;
case 6:
BitArray bit0 = new BitArray(new byte[] { message[0] });
bcode.NTP = bit0[3];
break;
default:
return;
// 处理功能码 7 的逻辑B码对时状态
bcode.BCode = message[1] != 1;
}
else if (functionType == 6)
{
// 处理功能码 6 的逻辑NTP 状态
BitArray bit0 = new BitArray(new byte[] { message[0] });
bcode.NTP = bit0[3];
}
// 更新数据到 Redis
await _bcodeAndNTPRedis.HashSetUpdateOneAsync(nameof(BCodeAndNTP), address.ToString(), bcode);
string channel = "bcodeAndNTPChannel";
await _bcodeAndNTPRedis.PublishAsync(channel, bcode);
}
catch (Exception ex)
{
Log4Helper.Error(this.GetType(), "B码对时状态", ex);
}
}
}
}

View File

@ -45,7 +45,6 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
_protectionDeviceIOInfoHandle = protectionDeviceIOInfoHandle;
_dotNettyTcpServer = dotNettyTcpServer;
_protectionDeviceRunInfoHandle = protectionDeviceRunInfoHandle;
_dotNettyTcpServer.deviceBoardStatesAction += _dotNettyTcpServer_deviceBoardStatesAction;
_deviceBoardStatesRedis = deviceBoardStatesRedis;
_protectionDeviceSelfCheckHandle = protectionDeviceSelfCheckHandle;
}
@ -60,17 +59,8 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
Log4Helper.Error(this.GetType(), "初始化装置IO错误", ex);
}
}
/// <summary>
/// 将装置状态写入到内存数据库中
/// </summary>
/// <param name="deviceBoardStates"></param>
private void _dotNettyTcpServer_deviceBoardStatesAction(Dictionary<byte, int[]> deviceBoardStates)
{
if (deviceBoardStates.Count>0)
{
_deviceBoardStatesRedis.HashSetUpdateManyAsync(deviceBoardStatesRedisKey, deviceBoardStates.Keys.Select(t => t.ToString()).ToList(), deviceBoardStates.Values.ToList());
}
}
public List<ProtectionDeviceCommInfoOutput> ProtectionDeviceComms { get; set; }
public async Task InitProtectionDeviceComms()
@ -180,6 +170,10 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
{
try
{
if (ipAddress == "127.0.0.1"|| ipAddress == "localhost")
{
return false;
}
using (Ping ping = new Ping())
{
// 发送 Ping 请求,设置超时时间为 1000 毫秒 (1秒)

View File

@ -17,6 +17,11 @@ using Yunda.ISAS.DataMonitoringServer.DataCenter;
using YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport;
using System.Windows.Interop;
using FluentFTP;
using System.Collections;
using System.Collections.Concurrent;
using Yunda.SOMS.DataMonitoringServer.SQLiteData;
using Abp;
using YunDa.SOMS.DataTransferObject.CommonDto;
namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
{
@ -26,10 +31,12 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
FtpFile _ftpFile;
DotNettyTcpServer _dotNettyTcpServer;
private readonly RedisDataRepository _redisDataRepository;
private readonly IRedisRepository<DeviceBoardStates, string> _deviceBoardStatesRedis;
public ProtectionDeviceRunInfoHandle(
FtpFile ftpFile,
DotNettyTcpServer dotNettyTcpServer
, WebApiRequest webApiRequest,
DotNettyTcpServer dotNettyTcpServer,
IRedisRepository<DeviceBoardStates, string> redisRepository,
WebApiRequest webApiRequest,
RedisDataRepository redisDataRepository
)
{
@ -38,8 +45,12 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
_dotNettyTcpServer = dotNettyTcpServer;
_redisDataRepository = redisDataRepository;
_dotNettyTcpServer.MessageReceived += OnMessageReceived; // 订阅事件
_deviceBoardStatesRedis = redisRepository;
}
//Dictionary<byte, DeviceInfo> _deviceRunStates = new Dictionary<byte, DeviceInfo>();
//private ConcurrentDictionary<byte, int> _communicationStateCounts = new();
int _commCount = 0;
private void OnMessageReceived(byte address, byte[] message, byte functionType)
{
@ -47,18 +58,19 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
{
if (functionType == 6) //通信状态
{
if (_commCount == 0)
var device = ProtectionDeviceDataCenter._devices.FirstOrDefault(t => t.DeviceAddr == address);
if (device != null)
{
var device = ProtectionDeviceDataCenter._devices.FirstOrDefault(t => t.DeviceAddr == address);
if (device != null)
UpdateDeviceBoardState(address, message, device);
if (_commCount == 0)
{
SendEquipmentInfoRemainingLifeAssessment(device);
SendEquipmentInfoRemainingLifeAssessment(device);
var bytes = _ftpFile.GetFileFromFtpToMem(device.GatewayIP1, "/nor/root/status/", "status.txt");
if (bytes!=null)
if (bytes != null)
{
var data = ParseDeviceStatusFromBytes(bytes);
if (data!=null)
if (data != null)
{
data.ProtectionDeviceId = device.ProtectionDeviceId;
data.EquipmentInfoId = device.EquipmentInfoId;
@ -68,8 +80,8 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
}
}
}
}
_commCount++;
if (_commCount == 10)
{
@ -97,86 +109,6 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
}
}
/// <summary>
/// 格式化FTP数据
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
private DeviceStatus ParseDeviceStatus(string filePath)
{
var deviceStatus = new DeviceStatus();
try
{
var networkInterfaces = new List<NetworkInterfaceStatus>();
string[] lines = File.ReadAllLines(filePath);
NetworkInterfaceStatus currentInterface = null;
foreach (var line in lines)
{
var parts = line.Split(':', 2);
if (parts.Length < 2) continue;
string key = parts[0].Trim();
string value = parts[1].Trim();
switch (key)
{
case "使用内存":
deviceStatus.UsedMemory = value;
break;
case "空闲内存":
deviceStatus.FreeMemory = value;
break;
case "总磁盘":
deviceStatus.TotalDisk = value;
break;
case "使用磁盘":
deviceStatus.UsedDisk = value;
break;
case "104连接状态":
deviceStatus.ConnectionStatus104 = int.Parse(value);
break;
case "液晶操作密码":
deviceStatus.LcdOperationPassword = value;
break;
default:
if (key.StartsWith("网口"))
{
string[] netParts = key.Split(new[] { "网口", "IP", "状态", "速率", "累计时间", "起始时间", "发生帧数", "发送错误帧数", "接收帧数", "接收错误帧数" }, StringSplitOptions.RemoveEmptyEntries);
if (netParts.Length > 0)
{
string interfaceName = netParts[0];
if (currentInterface == null || currentInterface.InterfaceName != interfaceName)
{
currentInterface = new NetworkInterfaceStatus { InterfaceName = interfaceName };
networkInterfaces.Add(currentInterface);
}
if (key.EndsWith("IP")) currentInterface.IpAddress = value;
if (key.EndsWith("状态")) currentInterface.Status = value;
if (key.EndsWith("速率")) currentInterface.Speed = value;
if (key.EndsWith("累计时间")) currentInterface.CumulativeTime = int.Parse(value.Replace("s", "").Trim());
if (key.EndsWith("起始时间")) currentInterface.StartTime = value;
if (key.EndsWith("发生帧数")) currentInterface.SentFrames = int.Parse(value);
if (key.EndsWith("发送错误帧数")) currentInterface.SentErrorFrames = int.Parse(value);
if (key.EndsWith("接收帧数")) currentInterface.ReceivedFrames = int.Parse(value);
if (key.EndsWith("接收错误帧数")) currentInterface.ReceivedErrorFrames = int.Parse(value);
}
}
break;
}
}
deviceStatus.NetworkInterfaces = networkInterfaces;
}
catch (Exception ex)
{
MonitoringEventBus.LogHandler(ex.Message, "格式化FTP数据");
}
return deviceStatus;
}
/// <summary>
/// 格式化FTP数据
/// </summary>
@ -257,6 +189,56 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
}
return deviceStatus;
}
private void UpdateDeviceBoardState(byte address, byte[] data, ProtectionDeviceCommInfoOutput device)
{
if (!_deviceBoardStates.TryGetValue(address, out var boardStates))
{
boardStates = iopositions.Select(item => new NameIntValueProperty(item.Name, item.Value)).ToList();
_deviceBoardStates[address] = boardStates;
}
boardStates[0].Value = new BitArray(new byte[] { data[0] })[0] ? 0 : 1;//运行状态
boardStates[1].Value = new BitArray(new byte[] { data[0] })[1] ? 0 : 1;//报警状态
boardStates[7].Value = new BitArray(new byte[] { data[1] })[0] ? 0 : 1; // 液晶状态
BitArray bit2 = new BitArray(new byte[] { data[2] });
boardStates[2].Value = bit2[0] ? 0 : 1;
boardStates[3].Value = bit2[1] ? 0 : 1;
boardStates[4].Value = bit2[2] ? 0 : 1;
boardStates[5].Value = bit2[3] ? 0 : 1;
boardStates[6].Value = bit2[4] ? 0 : 1;
DeviceBoardStates deviceBoardStates = new DeviceBoardStates()
{
EquipmentInfoId = device.EquipmentInfoId,
EquipmentInfoName = device.EquipmentInfoName,
States = boardStates,
Time = DateTime.Now,
};
_deviceBoardStatesRedis.HashSetUpdateOneAsync(deviceBoardStatesRedisKey, address.ToString(), deviceBoardStates);
_deviceBoardStatesRedis.PublishAsync(deviceBoardStatesRedisChannelKey, deviceBoardStates);
}
string deviceBoardStatesRedisKey = "deviceBoardStates";
string deviceBoardStatesRedisChannelKey = "deviceBoardStatesChannel";
ConcurrentDictionary<byte, List<NameIntValueProperty>> _deviceBoardStates = new();
List<NameIntValueProperty> iopositions = new List<NameIntValueProperty>
{
new NameIntValueProperty("运行", 0),
new NameIntValueProperty("告警", 0),
new NameIntValueProperty("IO插件1", 0),
new NameIntValueProperty("IO插件2", 0),
new NameIntValueProperty("IO插件3", 0),
new NameIntValueProperty("IO插件4", 0),
new NameIntValueProperty("电源插件IO5", 0),
new NameIntValueProperty("液晶", 0)
};
}
// 定义设备信息类
class DeviceInfo
{
public bool Status { get; set; } // 设备状态(运行或离线)
public DateTime LastUpdate { get; set; } // 最后更新时间
public int OfflineCount { get; set; } // 连续离线计数
}
}

View File

@ -1,16 +1,18 @@
using Abp.Dependency;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using ToolLibrary.LogHelper;
using Yunda.ISAS.DataMonitoringServer.DataAnalysis;
using Yunda.ISAS.DataMonitoringServer.DataCenter;
using Yunda.SOMS.DataMonitoringServer.FTPHandle;
using Yunda.SOMS.DataMonitoringServer.SQLiteData;
using Yunda.SOMS.DataMonitoringServer.TcpSocket.Server;
using YunDa.ISAS.Entities.System;
using YunDa.SOMS.Commdb.Models;
using YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport;
namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
@ -20,46 +22,93 @@ namespace Yunda.SOMS.DataMonitoringServer.ProtectionDeviceHandle
WebApiRequest _webApiRequest;
DotNettyTcpServer _dotNettyTcpServer;
private readonly RedisDataRepository _redisDataRepository;
FtpFile _ftpFile;
public ProtectionDeviceSelfCheckHandle(WebApiRequest webApiRequest,
FtpFile ftpFile,
DotNettyTcpServer dotNettyTcpServer,
RedisDataRepository redisDataRepository)
{
_ftpFile = ftpFile;
_webApiRequest = webApiRequest;
_dotNettyTcpServer = dotNettyTcpServer;
_redisDataRepository = redisDataRepository;
_dotNettyTcpServer.MessageReceived += OnMessageReceived; // 订阅事件
}
private ConcurrentDictionary<byte, string> _onlineDevices = new ConcurrentDictionary<byte, string>();
public bool AddIfNotExists(byte element,string path)
{
// 尝试添加元素,若不存在则添加,若存在则返回 false
return _onlineDevices.TryAdd(element, path);
}
private void OnMessageReceived(byte address, byte[] message, byte functionType)
{
try
{
if (functionType == 4) //通信状态
if (functionType == 4) //自检信息
{
var device = ProtectionDeviceDataCenter._devices.FirstOrDefault(t => t.DeviceAddr == address);
if (device != null)
{
if (message.Length > 0)
{
if (message[0] != 0)
if (message[12] != 0)
{
var abnormalComponent = _webApiRequest.GetDeviceAbnormalComponent(address, message[0]);
if (abnormalComponent != null)
if (_onlineDevices.TryGetValue(address,out string sqlPath))
{
abnormalComponent.EquipmentInfoId = device.EquipmentInfoId;
Task.Run(async () =>
if (string.IsNullOrWhiteSpace( sqlPath))
{
string redisChannel = _redisDataRepository.DeviceSelfTestChannelRediskey;
await _redisDataRepository.AbnormalComponentRedis.PublishAsync(redisChannel, abnormalComponent);
});
ProtdbHandle protdbHandle = new ProtdbHandle();
int zjCode = message[12];
var zjInfo = protdbHandle.GetTbEventZj(sqlPath, zjCode);
if (zjInfo!=null)
{
var abnormalComponent = _webApiRequest.GetDeviceAbnormalComponent(address, message[0]);
if (abnormalComponent != null)
{
//Todo:未来接口 做逻辑关系判定
abnormalComponent.EquipmentInfoId = device.EquipmentInfoId;
// 定义正则表达式模式
string pattern = @"(IO插件\d|I/O插件|电源插件)";
// 检查字符串是否包含目标值
MatchCollection matches = Regex.Matches(zjInfo.Description, pattern);
if (matches.Count > 0)
{
abnormalComponent.ComponentName = matches[0].Value;
// 替换匹配的部分为空
string result = Regex.Replace(zjInfo.Description, pattern, "");
Console.WriteLine("替换后的字符串: " + result);
abnormalComponent.AbnormalReason = result;
}
else
{
abnormalComponent.ComponentName = "CPU插件/软件系统";
abnormalComponent.AbnormalReason = zjInfo.Description;
}
Task.Run(async () =>
{
string redisChannel = _redisDataRepository.DeviceSelfTestChannelRediskey;
await _redisDataRepository.AbnormalComponentRedis.PublishAsync(redisChannel, abnormalComponent);
});
}
}
}
}
}
}
}
}
if (!_onlineDevices.TryGetValue(address,out string path))
{
//新连接的装置
var protectionDevice = ProtectionDeviceDataCenter._devices.FirstOrDefault(t => t.DeviceAddr == address);
var localfile = _ftpFile.GetFileFromFtp(protectionDevice.GatewayIP1, "/nor/root/protect/cfg/", "protdb.sql3", address.ToString());
_onlineDevices[address] = localfile;
}
}
catch (Exception ex)
{

View File

@ -87,8 +87,5 @@ namespace Yunda.SOMS.DataMonitoringServer.SQLiteData
}
return (index, iodic);
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using ToolLibrary.LogHelper;
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
using YunDa.SOMS.ProDB;
using YunDa.SOMS.ProDB.Models;
namespace Yunda.SOMS.DataMonitoringServer.SQLiteData
{
public class ProtdbHandle
{
public TbEventZj GetTbEventZj(string sqlPath,int code)
{
var fileName = Path.GetFileName(sqlPath);
try
{
using (var context = new ProtdbContext(sqlPath))
{
// 查询数据
var tbEventZj = context.TbEventZjs.FirstOrDefault(t=>t.SelfCheckCode == code);
return tbEventZj;
}
}
catch (Exception ex)
{
Log4Helper.Error(this.GetType(), "获取装置参数时发生错误", ex);
}
return default;
}
}
}

View File

@ -10,6 +10,7 @@ using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using Yunda.ISAS.DataMonitoringServer.DataAnalysis;
using Yunda.SOMS.DataMonitoringServer.FTPHandle;
namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
{
@ -17,129 +18,17 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
public class DotNettyServerHandler : SimpleChannelInboundHandler<IByteBuffer>
{
// 定义设备信息类
private class DeviceInfo
{
public bool Status { get; set; } // 设备状态(运行或离线)
public DateTime LastUpdate { get; set; } // 最后更新时间
public int OfflineCount { get; set; } // 连续离线计数
}
private IChannelHandlerContext _context;
// 定义事件,事件处理程序包含消息和功能描述
private readonly ConcurrentDictionary<byte, IChannelHandlerContext> _connections;
private readonly Action<byte, byte[], byte> _onMessageReceived;
private readonly Action<byte> _onDeviceConnection;
Dictionary<byte, DeviceInfo> _deviceRunStates = new Dictionary<byte, DeviceInfo>();
Dictionary<byte, int[]> _deviceBoardStates = new Dictionary<byte, int[]>(); //0-离线 1-在线
public DotNettyServerHandler(ConcurrentDictionary<byte, IChannelHandlerContext> connections,
Action<byte, byte[], byte> onMessageReceived, Action<Dictionary<byte, int[]>> deviceBoardStatesAction)
Action<byte, byte[], byte> onMessageReceived)
{
_connections = connections;
_onMessageReceived = onMessageReceived;
//_onDeviceConnection = onDeviceConnection;
Task.Factory.StartNew(async () =>
{
while (true)
{
try
{
CheckAndUpdateDeviceStates();
//LogDeviceStates();
if (_deviceBoardStates.Count > 0)
{
deviceBoardStatesAction(_deviceBoardStates);
}
await Task.Delay(5000);
}
catch (Exception ex)
{
MonitoringEventBus.LogHandler($"客户端连接错误:{ex.StackTrace}", "定值错误信息");
}
}
}, TaskCreationOptions.LongRunning);
}
async void CheckAndUpdateDeviceStates()
{
try
{
foreach (var entry in _deviceRunStates)
{
var deviceAddress = entry.Key;
var device = entry.Value;
if (!_deviceBoardStates.ContainsKey(deviceAddress))
{
_deviceBoardStates.Add(deviceAddress, new int[8]);
}
if (device == null)
{
continue;
}
// 检查是否连续发送“离线”状态
if (device.OfflineCount >= 5)
{
if (_deviceBoardStates[deviceAddress][0] !=0)
{
_deviceBoardStates[deviceAddress][0] = 0;
MonitoringEventBus.LogHandler($"[{DateTime.Now}] {deviceAddress} 判定为离线(连续离线状态)", "定值错误信息");
if (_connections.TryGetValue(deviceAddress, out IChannelHandlerContext ctx))
{
if (ctx.Channel.Active)
{
try
{
await ctx.DisconnectAsync();
await ctx.CloseAsync();
}
catch (Exception ex)
{
}
_connections.TryRemove(deviceAddress, out IChannelHandlerContext channelHandlerContext);
}
}
}
continue;
}
// 检查是否超过10秒未更新
if ((DateTime.Now - device.LastUpdate).TotalSeconds > 10)
{
if (_connections.ContainsKey(deviceAddress))
{
_deviceBoardStates[deviceAddress][0] = 0;
MonitoringEventBus.LogHandler($"[{DateTime.Now}] {deviceAddress} 判定为离线超过10秒未更新", "定值错误信息");
if (_connections.TryGetValue(deviceAddress,out IChannelHandlerContext ctx))
{
if (ctx.Channel.Active)
{
try
{
await ctx.DisconnectAsync();
await ctx.CloseAsync();
}
catch (Exception ex)
{
}
_connections.TryRemove(deviceAddress, out IChannelHandlerContext channelHandlerContext);
}
}
}
continue;
}
_deviceBoardStates[deviceAddress][0] = 1;
}
}
catch (Exception ex)
{
MonitoringEventBus.LogHandler($"{ex.StackTrace}", "103客户端错误信息");
}
}
public override void ChannelActive(IChannelHandlerContext context)
{
@ -192,14 +81,12 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
// 数据不足,等待更多数据
return;
}
byte[] data = new byte[dataLength];
msg.ReadBytes(data);
string clientIp = ctx.Channel.RemoteAddress.ToString();
string description = FunctionCodeDescriptions.GetDescription(functionType);
MonitoringEventBus.LogHandler($"装置地址 {address} 功能码:{functionType} 数据长度:{dataLength}", "103客户端消息");
//MonitoringEventBus.LogHandler($"装置地址 {address} 功能码:{functionType} 数据长度:{dataLength}", "103客户端消息");
Task.Run(() => _onMessageReceived?.Invoke(address, data, functionType));
HandleFunctionCodeAsync(functionType, address, controlWord, data, ctx);
}
@ -210,7 +97,7 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
}
private async Task HandleFunctionCodeAsync(byte functionType, byte address, byte controlWord, byte[] data, IChannelHandlerContext ctx)
{
{
switch (functionType)
{
case 0:
@ -250,77 +137,57 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
Debug.WriteLine($"确认开入开出信息: {Encoding.ASCII.GetString(data)}");
// 可以添加发送确认报文的逻辑
}
private ConcurrentDictionary<byte,int> _communicationStateCounts = new ();
private async Task UpdateDeviceCommunicationStateAsync(byte address, byte[] data, IChannelHandlerContext ctx)
{
await Task.Run(async () =>
{
try
{
// 更新连接上下文
if (_connections.ContainsKey(address))
{
_connections[address] = ctx;
}
else
{
_connections.TryAdd(address, ctx);
}
if (_communicationStateCounts.ContainsKey(address))
{
_communicationStateCounts[address]++;
if (_communicationStateCounts[address] == 86400)
{
_communicationStateCounts.TryRemove(address,out _);
}
}
else
{
_communicationStateCounts.TryAdd(address, 0);
for (byte i = 1; i < 6; i++)
{
await SendCustomMessageAsync(ctx, address, 0, 5, i);
}
await SendCustomMessageAsync(ctx, address, 0, 1, 0);
await SendCustomMessageAsync(ctx, address, 0, 2, 0);
await SendCustomMessageAsync(ctx, address, 0, 3, 0);
await SendCustomMessageAsync(ctx, address, 0, 4, 0);
await SendCustomMessageAsync(ctx, address, 0, 7, 0);
}
// 更新设备状态
BitArray bit0 = new BitArray(new byte[] { data[0] });
if (!_deviceRunStates.ContainsKey(address))
{
_deviceRunStates[address] = new DeviceInfo { Status = bit0[7], LastUpdate = DateTime.Now, OfflineCount = 0 };
}
var device = _deviceRunStates[address];
device.Status = bit0[0];
device.LastUpdate = DateTime.Now;
device.OfflineCount = bit0[0] ? 0 : device.OfflineCount + 1;
// 更新设备板状态
if (!_deviceBoardStates.ContainsKey(address))
{
_deviceBoardStates[address] = new int[8];
}
_deviceBoardStates[address][7] = new BitArray(new byte[] { data[1] })[0] ? 0 : 1; // 液晶状态
BitArray bit2 = new BitArray(new byte[] { data[2] });
_deviceBoardStates[address][2] = bit2[0] ? 0 : 1;
_deviceBoardStates[address][3] = bit2[1] ? 0 : 1;
_deviceBoardStates[address][4] = bit2[2] ? 0 : 1;
_deviceBoardStates[address][5] = bit2[3] ? 0 : 1;
_deviceBoardStates[address][6] = bit2[4] ? 0 : 1;
UpdateConnectionContext(address, ctx);
await UpdateCommunicationStateCountAsync(address, ctx);
}
catch (Exception ex)
{
MonitoringEventBus.LogHandler($"Error: {ex.StackTrace}", "103客户端发送消息");
}
});
}
private void UpdateConnectionContext(byte address, IChannelHandlerContext ctx)
{
_connections[address] = ctx;
}
private async Task UpdateCommunicationStateCountAsync(byte address, IChannelHandlerContext ctx)
{
if (_connections.TryGetValue(address, out _))
{
//_communicationStateCounts[address]++;
//已经存在的装置地址
}
else
{
//新加入的装置的地址
await SendInitMsgToDeviceAsync(ctx, address);
}
}
private async Task SendInitMsgToDeviceAsync(IChannelHandlerContext ctx, byte address)
{
for (byte i = 1; i < 6; i++)
{
await SendCustomMessageAsync(ctx, address, 0, 5, i);
}
await SendCustomMessageAsync(ctx, address, 0, 1, 0);
await SendCustomMessageAsync(ctx, address, 0, 2, 0);
await SendCustomMessageAsync(ctx, address, 0, 3, 0);
await SendCustomMessageAsync(ctx, address, 0, 4, 0);
await SendCustomMessageAsync(ctx, address, 0, 7, 0);
}
public override async void ExceptionCaught(IChannelHandlerContext context, Exception ex)
{
try

View File

@ -25,23 +25,24 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
// 定义 MessageReceived 事件
public event Action< byte, byte[], byte> MessageReceived; // 装置地址,功能码,消息
public event Action<Dictionary<byte, int[]>> deviceBoardStatesAction;
//public event Action<Dictionary<byte, int[]>> deviceBoardStatesAction;
public DotNettyTcpServer()
{
//_dotNettyServerHandler = dotNettyServerHandler;
}
MultithreadEventLoopGroup bossGroup ;
MultithreadEventLoopGroup workerGroup ;
int maxFrameLength = 65536; // 设置最大帧长度
int lengthFieldOffset = 1; // 长度字段的偏移量,从启动字符之后开始
int lengthFieldLength = 2; // 长度字段的字节长度
int lengthAdjustment = -3; // 长度调整,将读取的长度减去启动字符和长度字段的字节数
int initialBytesToStrip = 0; // 保留所有字节
public async Task RunServerAsync(/*Action<string> recvMsgAc*/)
{
private MultithreadEventLoopGroup bossGroup;
private MultithreadEventLoopGroup workerGroup;
private IChannel boundChannel;
bossGroup = new MultithreadEventLoopGroup(1);
workerGroup = new MultithreadEventLoopGroup();
public async Task RunServerAsync()
{
bossGroup = new MultithreadEventLoopGroup(1);
workerGroup = new MultithreadEventLoopGroup();
try
{
GCSettings.LatencyMode = GCLatencyMode.LowLatency;
@ -58,35 +59,50 @@ namespace Yunda.SOMS.DataMonitoringServer.TcpSocket.Server
lengthAdjustment,
initialBytesToStrip
));
channel.Pipeline.AddLast(new DotNettyServerHandler(connections, MessageReceived, deviceBoardStatesAction));
channel.Pipeline.AddLast(new DotNettyServerHandler(connections, MessageReceived));
channel.Pipeline.AddLast("hexDumpHandler", new HexDumpHandler());
}));
IChannel boundChannel = await bootstrap.BindAsync(7110);
boundChannel = await bootstrap.BindAsync(7110);
MonitoringEventBus.LogHandler("服务器启动并监听端口 7110...", "获取信息");
}
finally
{
//await Task.WhenAll(
// bossGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)),
// workerGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)));
}
}
public async void StopSeverAsync()
{
try
{
await Task.WhenAll(
bossGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)),
workerGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)));
}
catch (Exception ex)
{
MonitoringEventBus.LogHandler("服务器关闭并监听端口 7110...", "获取信息");
MonitoringEventBus.LogHandler($"服务器启动失败: {ex.Message}", "错误");
throw;
}
}
public async Task StopServerAsync()
{
try
{
if (boundChannel != null)
{
await boundChannel.CloseAsync();
boundChannel = null;
}
if (bossGroup != null)
{
await bossGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1));
bossGroup = null;
}
if (workerGroup != null)
{
await workerGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1));
workerGroup = null;
}
MonitoringEventBus.LogHandler("服务器已成功关闭并停止监听端口 7110...", "获取信息");
}
catch (Exception ex)
{
MonitoringEventBus.LogHandler($"服务器关闭失败: {ex.Message}", "错误");
}
}
public async void SendMessageByIp(byte address, byte controlWord, byte functionCode , byte message)
{
if (connections.TryGetValue(address, out IChannelHandlerContext context))

View File

@ -114,6 +114,7 @@
<ProjectReference Include="..\..\YunDa.Application\YunDa.ISAS.ExternalInteraction.DataTransferObject\YunDa.SOMS.ExternalInteraction.DataTransferObject.csproj" />
<ProjectReference Include="..\..\YunDa.Domain\ProtectionDeviceSqlite\YunDa.SOMS.Commdb\YunDa.SOMS.Commdb.csproj" />
<ProjectReference Include="..\..\YunDa.Domain\ProtectionDeviceSqlite\YunDa.SOMS.IODB\YunDa.SOMS.IODB.csproj" />
<ProjectReference Include="..\..\YunDa.Domain\ProtectionDeviceSqlite\YunDa.SOMS.ProDB\YunDa.SOMS.ProDB\YunDa.SOMS.ProDB.csproj" />
<ProjectReference Include="..\..\YunDa.Domain\YunDa.ISAS.MongoDB\YunDa.SOMS.MongoDB.csproj" />
<ProjectReference Include="..\..\YunDa.Domain\YunDa.ISAS.Redis\YunDa.SOMS.Redis.csproj" />
<ProjectReference Include="..\..\YunDa.Util\DotNettyHelper\DotNettyHelper.csproj" />

View File

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.NetworkInformation;
using System.Security.Cryptography;
namespace ToolLibrary
{
@ -11,15 +14,17 @@ namespace ToolLibrary
/// </summary>
/// <param name="port">指定的端口号</param>
/// <returns>占用端口的进程 PID失败时返回 -1</returns>
public static int GetProcessIdByPort(int port)
public static List<int> GetProcessIdsByPort(int port)
{
List<int> pids = new List<int>();
try
{
// 使用 netstat 命令获取端口信息
var startInfo = new ProcessStartInfo
{
FileName = "netstat",
Arguments = $"-ano | findstr :{port}", // 查找指定端口的占用情况
FileName = "cmd.exe",
Arguments = $"/c netstat -ano | findstr :{port}",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
@ -31,12 +36,19 @@ namespace ToolLibrary
string output = reader.ReadToEnd();
if (!string.IsNullOrEmpty(output))
{
// 输出格式: TCP 0.0.0.0:2403 0.0.0.0:0 LISTENING 1234
var columns = output.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (columns.Length > 4)
var lines = output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
int pid = int.Parse(columns[columns.Length - 1]); // 获取 PID
return pid;
// 输出格式: TCP 0.0.0.0:2403 0.0.0.0:0 LISTENING 1234
var columns = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (columns.Length > 4)
{
if (int.TryParse(columns[columns.Length - 1], out int pid))
{
pids.Add(pid); // 将 PID 添加到列表中
}
}
}
}
}
@ -46,9 +58,10 @@ namespace ToolLibrary
Console.WriteLine("查询端口进程失败: " + ex.Message);
}
return -1; // 返回无效的 PID
return pids.Distinct().ToList(); // 返回所有 PID
}
/// <summary>
/// 根据 PID 杀死指定的进程
/// </summary>
@ -77,10 +90,19 @@ namespace ToolLibrary
/// <returns>是否成功杀死进程</returns>
public static bool KillProcessByPort(int port)
{
int pid = GetProcessIdByPort(port);
if (pid > 0)
var pids = GetProcessIdsByPort(port);
if (pids!=null)
{
return KillProcessById(pid);
int selfpid = Process.GetCurrentProcess().Id;
foreach (var pid in pids)
{
if (pid!= selfpid)
{
KillProcessById(pid);
}
}
return true;
}
else
{