|
|
@@ -1,7 +1,9 @@
|
|
|
using AutoMapper;
|
|
|
using Edge.Core.Configuration;
|
|
|
+using Edge.Core.Core.database;
|
|
|
using Edge.Core.Database;
|
|
|
using Edge.Core.Database.Configuration.Models;
|
|
|
+using Edge.Core.Domain.FccMachineInfo.Output;
|
|
|
using Edge.Core.Parser.BinaryParser;
|
|
|
using Edge.Core.Processor.Communicator;
|
|
|
using Edge.Core.Processor.Dispatcher.Attributes;
|
|
|
@@ -34,37 +36,80 @@ namespace Edge.Core.Processor.Dispatcher
|
|
|
|
|
|
protected virtual IEnumerable<ProcessorMetaConfig> LoadProcessorMetaConfigs()
|
|
|
{
|
|
|
- string json = @"[
|
|
|
- {
|
|
|
- ""Id"": 16,
|
|
|
- ""Name"": ""HengshanPaymentTerminal.HengshanPayTerminal.Hengs_938d2e2bd48b45ba_8"",
|
|
|
- ""Description"": """",
|
|
|
- ""Type"": 0,
|
|
|
- ""Parts"": [
|
|
|
- {
|
|
|
- ""Id"": 38,
|
|
|
- ""Type"": 1,
|
|
|
- ""FullTypeString"": ""HengshanPaymentTerminal.HengshanPayTermHandler, HengshanPaymentTerminal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",
|
|
|
- ""ParametersJsonArrayStr"": ""[{\""pumpIds\"":\""1,2,3,4\"",\""pumpSubAddresses\"":[{\""PumpId\"":1,\""SubAddress\"":1},{\""PumpId\"":2,\""SubAddress\"":2},{\""PumpId\"":3,\""SubAddress\"":3},{\""PumpId\"":4,\""SubAddress\"":4}],\""pumpNozzleLogicIds\"":[{\""PumpId\"":1,\""LogicIds\"":\""1\""},{\""PumpId\"":2,\""LogicIds\"":\""1\""},{\""PumpId\"":3,\""LogicIds\"":\""1\""},{\""PumpId\"":4,\""LogicIds\"":\""1\""}],\""pumpSiteNozzleNos\"":[{\""PumpId\"":1,\""SiteNozzleNos\"":\""1\""},{\""PumpId\"":2,\""SiteNozzleNos\"":\""2\""},{\""PumpId\"":3,\""SiteNozzleNos\"":\""3\""},{\""PumpId\"":4,\""SiteNozzleNos\"":\""4\""}],\""nozzleLogicIds\"":[{\""NozzleNo\"":1,\""LogicId\"":1},{\""NozzleNo\"":2,\""LogicId\"":1},{\""NozzleNo\"":3,\""LogicId\"":1},{\""NozzleNo\"":4,\""LogicId\"":1}]}]""
|
|
|
- },
|
|
|
+ List<ProcessorMetaConfig> processorMetaConfigs = new List<ProcessorMetaConfig>();
|
|
|
+ MysqlDbContext mysqlDbContext = services.GetRequiredService<MysqlDbContext>();
|
|
|
+ List<Domain.FccMachineInfo.FccMachineInfo> fccMachineInfos = mysqlDbContext.FccMachineInfos.ToList();
|
|
|
+ foreach (var item in fccMachineInfos)
|
|
|
{
|
|
|
- ""Id"": 40,
|
|
|
- ""Type"": 0,
|
|
|
- ""FullTypeString"": ""Edge.Core.Processor.GenericDeviceProcessor`2, Edge.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",
|
|
|
- ""ParametersJsonArrayStr"": ""[]""
|
|
|
- },
|
|
|
- {
|
|
|
- ""Id"": 41,
|
|
|
- ""Type"": 5,
|
|
|
- ""FullTypeString"": ""Edge.Core.Processor.Communicator.TcpServerCommunicator`1, Edge.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",
|
|
|
- ""ParametersJsonArrayStr"": ""[23456, 30, \""enabled\"", \""enabled\"", \""2\""]""
|
|
|
+ int port = item.Port;
|
|
|
+ ProcessorMetaConfig processorMetaConfig = new ProcessorMetaConfig();
|
|
|
+ processorMetaConfig.Id = 16;
|
|
|
+ processorMetaConfig.Name = "HengshanPaymentTerminal.HengshanPayTerminal.Hengs_938d2e2bd48b45ba_8";
|
|
|
+ processorMetaConfig.Description = "";
|
|
|
+ processorMetaConfig.Type = ProcessorTypeEnum.DeviceProcessor;
|
|
|
+
|
|
|
+ ProcessorMetaPartsConfig hengshanPayTermHandler = new ProcessorMetaPartsConfig();
|
|
|
+ hengshanPayTermHandler.Id = 38;
|
|
|
+ hengshanPayTermHandler.Type = ProcessorMetaPartsTypeEnum.DeviceHandler;
|
|
|
+ hengshanPayTermHandler.FullTypeString = "HengshanPaymentTerminal.HengshanPayTermHandler, HengshanPaymentTerminal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
|
|
|
+ hengshanPayTermHandler.ParametersJsonArrayStr = @"[{""pumpIds"":""1,2,3,4"",""pumpSubAddresses"":[{""PumpId"":1,""SubAddress"":1},{""PumpId"":2,""SubAddress"":2},{""PumpId"":3,""SubAddress"":3},{""PumpId"":4,""SubAddress"":4}],""pumpNozzleLogicIds"":[{""PumpId"":1,""LogicIds"":""1""},{""PumpId"":2,""LogicIds"":""1""},{""PumpId"":3,""LogicIds"":""1""},{""PumpId"":4,""LogicIds"":""1""}],""pumpSiteNozzleNos"":[{""PumpId"":1,""SiteNozzleNos"":""1""},{""PumpId"":2,""SiteNozzleNos"":""2""},{""PumpId"":3,""SiteNozzleNos"":""3""},{""PumpId"":4,""SiteNozzleNos"":""4""}],""nozzleLogicIds"":[{""NozzleNo"":1,""LogicId"":1},{""NozzleNo"":2,""LogicId"":1},{""NozzleNo"":3,""LogicId"":1},{""NozzleNo"":4,""LogicId"":1}]}]";
|
|
|
+
|
|
|
+ ProcessorMetaPartsConfig generDeviceProcessor = new ProcessorMetaPartsConfig();
|
|
|
+ generDeviceProcessor.Id = 40;
|
|
|
+ generDeviceProcessor.Type = ProcessorMetaPartsTypeEnum.DeviceProcessor;
|
|
|
+ generDeviceProcessor.FullTypeString = "Edge.Core.Processor.GenericDeviceProcessor`2, Edge.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
|
|
|
+ generDeviceProcessor.ParametersJsonArrayStr = "[]";
|
|
|
+
|
|
|
+ ProcessorMetaPartsConfig tcpServerCommunicator = new ProcessorMetaPartsConfig();
|
|
|
+ tcpServerCommunicator.Id = 41;
|
|
|
+ tcpServerCommunicator.Type = ProcessorMetaPartsTypeEnum.Communicator;
|
|
|
+ tcpServerCommunicator.FullTypeString = "Edge.Core.Processor.Communicator.TcpServerCommunicator`1, Edge.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
|
|
|
+ tcpServerCommunicator.ParametersJsonArrayStr = @"[" + port + @", 30, ""enabled"", ""enabled"", ""2""]";
|
|
|
+
|
|
|
+ List<ProcessorMetaPartsConfig> processorMetaPartsConfigs = new List<ProcessorMetaPartsConfig>();
|
|
|
+ processorMetaPartsConfigs.Add(hengshanPayTermHandler);
|
|
|
+ processorMetaPartsConfigs.Add(generDeviceProcessor);
|
|
|
+ processorMetaPartsConfigs.Add(tcpServerCommunicator);
|
|
|
+ processorMetaConfig.Parts = processorMetaPartsConfigs;
|
|
|
+
|
|
|
+ processorMetaConfig.Activated = true;
|
|
|
+
|
|
|
+
|
|
|
+ processorMetaConfigs.Add(processorMetaConfig);
|
|
|
}
|
|
|
- ],
|
|
|
- ""Activated"": true
|
|
|
- }
|
|
|
-]";
|
|
|
- IEnumerable<ProcessorMetaConfig> configs = JsonSerializer.Deserialize<IEnumerable<ProcessorMetaConfig>>(json);
|
|
|
- return configs;
|
|
|
+
|
|
|
+ return processorMetaConfigs;
|
|
|
+ // string json = @"[
|
|
|
+ // {
|
|
|
+ // ""Id"": 16,
|
|
|
+ // ""Name"": ""HengshanPaymentTerminal.HengshanPayTerminal.Hengs_938d2e2bd48b45ba_8"",
|
|
|
+ // ""Description"": """",
|
|
|
+ // ""Type"": 0,
|
|
|
+ // ""Parts"": [
|
|
|
+ // {
|
|
|
+ // ""Id"": 38,
|
|
|
+ // ""Type"": 1,
|
|
|
+ // ""FullTypeString"": ""HengshanPaymentTerminal.HengshanPayTermHandler, HengshanPaymentTerminal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",
|
|
|
+ // ""ParametersJsonArrayStr"": ""[{\""pumpIds\"":\""1,2,3,4\"",\""pumpSubAddresses\"":[{\""PumpId\"":1,\""SubAddress\"":1},{\""PumpId\"":2,\""SubAddress\"":2},{\""PumpId\"":3,\""SubAddress\"":3},{\""PumpId\"":4,\""SubAddress\"":4}],\""pumpNozzleLogicIds\"":[{\""PumpId\"":1,\""LogicIds\"":\""1\""},{\""PumpId\"":2,\""LogicIds\"":\""1\""},{\""PumpId\"":3,\""LogicIds\"":\""1\""},{\""PumpId\"":4,\""LogicIds\"":\""1\""}],\""pumpSiteNozzleNos\"":[{\""PumpId\"":1,\""SiteNozzleNos\"":\""1\""},{\""PumpId\"":2,\""SiteNozzleNos\"":\""2\""},{\""PumpId\"":3,\""SiteNozzleNos\"":\""3\""},{\""PumpId\"":4,\""SiteNozzleNos\"":\""4\""}],\""nozzleLogicIds\"":[{\""NozzleNo\"":1,\""LogicId\"":1},{\""NozzleNo\"":2,\""LogicId\"":1},{\""NozzleNo\"":3,\""LogicId\"":1},{\""NozzleNo\"":4,\""LogicId\"":1}]}]""
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // ""Id"": 40,
|
|
|
+ // ""Type"": 0,
|
|
|
+ // ""FullTypeString"": ""Edge.Core.Processor.GenericDeviceProcessor`2, Edge.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",
|
|
|
+ // ""ParametersJsonArrayStr"": ""[]""
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // ""Id"": 41,
|
|
|
+ // ""Type"": 5,
|
|
|
+ // ""FullTypeString"": ""Edge.Core.Processor.Communicator.TcpServerCommunicator`1, Edge.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",
|
|
|
+ // ""ParametersJsonArrayStr"": ""[23456, 30, \""enabled\"", \""enabled\"", \""2\""]""
|
|
|
+ // }
|
|
|
+ // ],
|
|
|
+ // ""Activated"": true
|
|
|
+ // }
|
|
|
+ //]";
|
|
|
+ // IEnumerable<ProcessorMetaConfig> configs = JsonSerializer.Deserialize<IEnumerable<ProcessorMetaConfig>>(json);
|
|
|
+ // return configs;
|
|
|
//using (var scope = this.services.CreateScope())
|
|
|
//{
|
|
|
//var dbContext = scope.ServiceProvider.GetRequiredService<SqliteDbContext>();
|