Commit 60bd1e2b 张东亮

1

1 个父辈 738ee324
......@@ -19,7 +19,7 @@ namespace DeviceLibrary
public static bool IsLoadOk = true;
public static bool IsConfigMode = false;
public static bool InoutDebugMode = false;
public delegate void LoadFinish(bool state,string msg);
public delegate void LoadFinish(bool state, string msg);
public static event LoadFinish LoadFinishEvent;
public static event EventHandler<bool> UserPauseSet;
......@@ -31,20 +31,27 @@ namespace DeviceLibrary
public static List<HumitureController> humitureControllers = new List<HumitureController>();
public static double averageHumidity()
{
return humitureControllers.FindAll(s => s.LastData.Humidity > 0).Average(x => x.LastData.Humidity);
var ss = humitureControllers.FindAll(s => s.LastData.Humidity > 0);
if (ss != null && ss.Count > 0)
return ss.Average(x => x.LastData.Humidity);
return 0;
}
public static double averageTemp()
{
return humitureControllers.FindAll(s => s.LastData.Temperate > 0).Average(x => x.LastData.Temperate);
var ss = humitureControllers.FindAll(s => s.LastData.Temperate > 0);
if (ss != null && ss.Count > 0)
return ss.Average(x => x.LastData.Temperate);
return 0;
}
public static HIKCamera CameraA=new HIKCamera();
public static HIKCamera CameraB= new HIKCamera();
public static void Init() {
public static HIKCamera CameraA = new HIKCamera();
public static HIKCamera CameraB = new HIKCamera();
public static void Init()
{
string msg = "";
try
{
mainMachine = null;
mainMachine = null;
string configFile = Path.Combine(baseDir, "config\\Config.csv");
Config = new Robot_Config(0, "", configFile);
Config = (Robot_Config)CSVConfigReader.LoadConfig(Config);
......@@ -56,7 +63,8 @@ namespace DeviceLibrary
LogUtil.info("加载位置文件:" + positionConfigFile);
CSVPositionReader<ACStorePosition>.ReloadCSVFile(positionConfigFile);
}
else {
else
{
IsLoadOk = false;
msg += "找不到库位配置文件\n";
}
......@@ -70,16 +78,17 @@ namespace DeviceLibrary
msg += "IO板卡初始化失败\n";
}
var hports = Setting_Init.Device_Humiture_Port.Val.Split(',');
foreach(var p in hports)
{
foreach (var p in hports)
{
var hc = new HumitureController();
if (!hc.Init(p))
{
LogUtil.info("尝试打开端口:" + p+" 失败");
LogUtil.info("尝试打开端口:" + p + " 失败");
IsLoadOk = false;
msg += "温湿度传感器初始化失败,端口:" + $"{p}\n";
}
else {
else
{
LogUtil.info("尝试打开端口:" + p + " 成功");
humitureControllers.Add(hc);
}
......@@ -102,22 +111,25 @@ namespace DeviceLibrary
if (!CameraB.LoadCameraConfig("CameraB", out errmsg))
{
//IsLoadOk = false;
msg += errmsg+"\r\n";
msg += errmsg + "\r\n";
}
//IOManager.IOMove(IO_Type.Device_Led, IO_VALUE.HIGH);
//IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LoadFinishEvent?.Invoke(IsConfigMode ? IsConfigMode : IsLoadOk, msg);
}
catch (Exception ex) {
catch (Exception ex)
{
LoadFinishEvent?.Invoke(false, ex.Message);
LogUtil.error(ex.Message+ex.StackTrace);
LogUtil.error(ex.Message + ex.StackTrace);
return;
}
}
public static void LoadDebug() {
public static void LoadDebug()
{
LoadFinishEvent?.Invoke(true, "打开调试模式");
}
public static void Start() {
public static void Start()
{
//Init();
if (!IsLoadOk)
{
......@@ -130,20 +142,21 @@ namespace DeviceLibrary
isRunning = true;
GC.KeepAlive(mainThread);
Task.Run(()=> {
Task.Run(() =>
{
AxisBean.List.ForEach((x) => { AxisManager.AlarmClear(x.Config.DeviceName, x.Config.GetAxisValue()); });
Task.Delay(1000).Wait();
if (mainMachine.DeviceCheck())
mainMachine.BeginHomeReset(true);
});
}
public static void Stop()
{
LogUtil.info("开始停止系统.");
mainMachine.Stop();
mainMachine.UserPause = false;
//IOManager.CloseAllConnection();
......@@ -160,14 +173,15 @@ namespace DeviceLibrary
}
public static void UserPause(bool userpause)
{
UserPause("", userpause,false);
UserPause("", userpause, false);
}
public static void UserPause(string msg="",bool userpause=true,bool upload=true) {
public static void UserPause(string msg = "", bool userpause = true, bool upload = true)
{
if (userpause)
{
if(string.IsNullOrEmpty(msg))
if (string.IsNullOrEmpty(msg))
{
if(upload)
if (upload)
{
Msg.add("用户暂停", MsgLevel.critical);
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!