|
|
|
|
using Custom.Communication.Framework.MyPlc;
|
|
|
|
|
using Custom.Utils.Framework;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Production_Oil.Common;
|
|
|
|
|
using Production_Oil.Services;
|
|
|
|
|
using Production_Oil.ViewModel;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Production_Oil
|
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
InitSystemConfigIni();
|
|
|
|
|
|
|
|
|
|
var filePath = AppDomain.CurrentDomain.BaseDirectory + "Config/PointsSetting.json";
|
|
|
|
|
var content = JsonHelper.ReadJsonFile(filePath);
|
|
|
|
|
if (string.IsNullOrEmpty(content))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("读取到的Json内容为空!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var stationsInfo = JsonConvert.DeserializeObject<StationsInfo>(content);
|
|
|
|
|
if (stationsInfo != null && stationsInfo.Stations != null && stationsInfo.Stations.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < stationsInfo.Stations.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
var plcConnectState = OmronHelper.GetOmronCipNet(stationsInfo.Stations[i].PlcIP, stationsInfo.Stations[i].PlcPort);
|
|
|
|
|
if (!plcConnectState)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"[{stationsInfo.Stations[i].PlcIP}]PLC连接失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DoSomething doSomething = new DoSomething();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取系统INI配置文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void InitSystemConfigIni()
|
|
|
|
|
{
|
|
|
|
|
var iniFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemConfig.ini");
|
|
|
|
|
var dbServerIp = IniHelper.Read("DdataBaseConfig", "DbServerIp", "127.0.0.1", iniFilePath);
|
|
|
|
|
var port = IniHelper.Read("DdataBaseConfig", "Port", "5432", iniFilePath);
|
|
|
|
|
var database = IniHelper.Read("DdataBaseConfig", "Database", "", iniFilePath);
|
|
|
|
|
var userId = IniHelper.Read("DdataBaseConfig", "UserId", "postgres", iniFilePath);
|
|
|
|
|
var password = IniHelper.Read("DdataBaseConfig", "Password", "", iniFilePath);
|
|
|
|
|
var schema = IniHelper.Read("DdataBaseConfig", "Schema", "public", iniFilePath);
|
|
|
|
|
var strIsEncrypt = IniHelper.Read("DdataBaseConfig", "DbPwdIsEncrypt", "false", iniFilePath);
|
|
|
|
|
_ = bool.TryParse(strIsEncrypt, out bool isEncrypt);
|
|
|
|
|
|
|
|
|
|
DbContext.GetConStr(dbServerIp, port, database, userId, password, isEncrypt, schema);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|