Program.cs
3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Windows.Forms;
namespace AGVControl_Steel
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
log4net.Config.XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Common.appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
Common.log = log4net.LogManager.GetLogger("AGVControl_Steel");
Common.log.Info("=====程序开始=====");
ReadConfig();
Common.control = new BLL.Control();
Common.mir = new Model.MiR_API { FleetIP = Common.appConfig.AppSettings.Settings["FLEET_IP"].Value, MissionList = Common.agvMissions };
Common.serverOpen = Common.WebService.Open(Common.appConfig.AppSettings.Settings["WebService"].Value);
Application.Run(new FrmMain());
Common.control.Stop();
Common.log.Info("=====程序结束=====\r\n");
}
private static void ReadConfig()
{
try
{
//AGV小车信息
Common.agvInfos = new System.Collections.Generic.List<Model.AgvInfo>();
string[] lines = System.IO.File.ReadAllLines(Common.PATH_AGV_NAME, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] str = lines[i].Split(',');
if (str.Length != 4) continue;
string isUse = "false";
if (Common.appConfig.AppSettings.Settings[str[0]] == null)
{
Common.appConfig.AppSettings.Settings.Add(str[0], "false");
Common.appConfig.Save();
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
}
else
{
isUse = Common.appConfig.AppSettings.Settings[str[0]].Value;
}
Model.AgvInfo info = new Model.AgvInfo
{
FleetID = str[0],
Name = str[1],
IP = str[2],
Authorization = str[3],
IsAuto = Convert.ToBoolean(isUse)
};
Common.agvInfos.Add(info);
}
Common.log.Info("读取配置文件 " + Common.PATH_AGV_NAME);
Common.agvMissions = new System.Collections.Generic.Dictionary<string, string>();
lines = System.IO.File.ReadAllLines(Common.PATH_AGV_MISSION, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] str = lines[i].Split(',');
if (str.Length != 2) continue;
Common.agvMissions.Add(str[0], str[1]);
}
Common.log.Info("读取配置文件 " + Common.PATH_AGV_MISSION);
}
catch (Exception ex)
{
Common.log.Error("ReadConfig()", ex);
}
}
}
}