[성현모] DeviceManager, Factory 리팩토링, DIO, Scanner 추가
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
using eCIAv2.Library.Devices;
|
||||
using eCIAv2.Library.Devices.DIIO;
|
||||
using eCIAv2.Library.Devices.Scanner;
|
||||
using eCIAv2.WindowsApp.ViewModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace eCIAv2.WindowsApp
|
||||
{
|
||||
@ -10,8 +14,6 @@ namespace eCIAv2.WindowsApp
|
||||
{
|
||||
InitializeComponent();
|
||||
_vm = vm;
|
||||
|
||||
var ss= _vm.LoadConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
using eCIAv2.WindowsApp.Services;
|
||||
using eCIAv2.Library.Config;
|
||||
using eCIAv2.Library.Devices;
|
||||
using eCIAv2.Library.Devices.DIIO;
|
||||
using eCIAv2.Library.Devices.Scanner;
|
||||
using eCIAv2.Library.Services;
|
||||
using eCIAv2.WindowsApp.ViewModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace eCIAv2.WindowsApp
|
||||
{
|
||||
@ -15,9 +20,9 @@ namespace eCIAv2.WindowsApp
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
//LogXnet
|
||||
string configDir = @$"{Application.StartupPath}Config";
|
||||
//raed log4net configs
|
||||
|
||||
//LogXnet
|
||||
if (LogXnet.ReadConfig(@$"{configDir}/LogXnetConfig.json") == true)
|
||||
{
|
||||
LogXnet.WriteLine("LogXnet Init Success");
|
||||
@ -27,22 +32,36 @@ namespace eCIAv2.WindowsApp
|
||||
Console.WriteLine("LogXnet Init Failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
AppHost = Host.CreateDefaultBuilder()
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
//device
|
||||
services.AddTransient<IScanner,Zebra>();
|
||||
services.AddTransient<IScanner,Cognex>();
|
||||
services.AddTransient<IDIO,NMF>();
|
||||
|
||||
//device factory
|
||||
services.AddSingleton<DeviceFactory>();
|
||||
//device manager
|
||||
services.AddSingleton<DeviceManager>();
|
||||
|
||||
// services
|
||||
services.AddSingleton<ConfigService>();
|
||||
|
||||
//viewmodels
|
||||
services.AddTransient<MainFromViewModel>();
|
||||
|
||||
// forms
|
||||
services.AddTransient<MainForm>();
|
||||
}).Build();
|
||||
|
||||
ApplicationConfiguration.Initialize();
|
||||
|
||||
var configService = AppHost.Services.GetRequiredService<ConfigService>();
|
||||
var config = configService.LoadConfig(@$"{configDir}/eCIAv2Config.json");
|
||||
|
||||
//config <20><><EFBFBD><EFBFBD> üũ
|
||||
if (config == null)
|
||||
return;
|
||||
|
||||
ApplicationConfiguration.Initialize();
|
||||
var form = AppHost.Services.GetRequiredService<MainForm>();
|
||||
Application.Run(form);
|
||||
}
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace eCIAv2.WindowsApp.Services
|
||||
{
|
||||
public class ConfigService
|
||||
{
|
||||
public string LoadConfig()
|
||||
{
|
||||
return "loadConfig";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,8 @@
|
||||
using eCIAv2.WindowsApp.Services;
|
||||
using eCIAv2.Library.Config;
|
||||
using eCIAv2.Library.Devices;
|
||||
using eCIAv2.Library.Devices.DIIO;
|
||||
using eCIAv2.Library.Devices.Scanner;
|
||||
using eCIAv2.Library.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,15 +14,18 @@ namespace eCIAv2.WindowsApp.ViewModels
|
||||
public class MainFromViewModel
|
||||
{
|
||||
private readonly ConfigService _configService;
|
||||
private readonly DeviceManager _deviceManager;
|
||||
|
||||
public MainFromViewModel(ConfigService configService)
|
||||
public MainFromViewModel(ConfigService configService, DeviceManager deviceManager)
|
||||
{
|
||||
_configService = configService;
|
||||
_deviceManager = deviceManager;
|
||||
}
|
||||
|
||||
public string LoadConfig()
|
||||
|
||||
public void TriggerCognex()
|
||||
{
|
||||
return _configService.LoadConfig();
|
||||
IScanner cognex = _deviceManager.GetDevice<IScanner>("Cognex1");
|
||||
var sss = cognex.Trigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,8 +30,4 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user