diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index b7bd7a1..2684df2 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -59,7 +59,7 @@
-
+
diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs
index ee38436..759d43c 100644
--- a/DM_Weight/App.xaml.cs
+++ b/DM_Weight/App.xaml.cs
@@ -233,8 +233,10 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation();
//主设置页面
containerRegistry.RegisterForNavigation();
- //冰箱抽屉设置页面
+ //两个冰箱抽屉设置页面
containerRegistry.RegisterForNavigation();
+ //只有一个冰箱抽屉设置页面
+ containerRegistry.RegisterForNavigation();
#endregion
diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs
index e9dc7f7..4eb50ce 100644
--- a/DM_Weight/Port/PortUtil.cs
+++ b/DM_Weight/Port/PortUtil.cs
@@ -28,6 +28,7 @@ using PreviewDemo;
using System.Runtime.InteropServices;
using DM_Weight.Common;
using System.Net;
+using System.Text.RegularExpressions;
namespace DM_Weight.Port
{
@@ -963,6 +964,37 @@ namespace DM_Weight.Port
}
#endregion
+ #region 药盒操作
+ ///
+ /// 打开药盒
+ ///
+ ///
+ ///
+ public async Task OpenBox(int ColNo)
+ {
+ var vlock = 321;
+ decimal decolNO = (decimal)ColNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO % 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, 5,(byte)vlock, 0x00,0x00,0x00,0xee};
+ canBusSerial.Write(buffer, 0, 8);
+ await Task.Delay(TimeSpan.FromMilliseconds(20));
+ }
+ ///
+ /// 查询药盒状态
+ ///
+ ///
+ ///
+ public async Task GetBoxLockState(int ColNo)
+ {
+ decimal deColNo = (decimal)ColNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(deColNo / 3)).ToString(), 16);
+ byte[] buffer = new byte[] {0xaa,(byte)channel,2,0,0,0,0,0xee };
+ canBusSerial.Write(buffer, 0, 8);
+ return await GetBufferByPort(canBusSerial, 8);
+ }
+
+ #endregion
+
private string trim(string text)
{
//此处使用了转义字符如:\',\",\\,分别表示单引号,双引号,反斜杠
@@ -1095,6 +1127,18 @@ namespace DM_Weight.Port
+ #endregion
+
+ #region 标签显示屏
+ //清屏
+ public void ClearContentMethod(int drawerNo,int colNo)
+ {
+ decimal deColNo = colNo;
+ var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3);
+ var colNo2 = 321;
+ byte[] buffer = new byte[] { 0xaa };
+ canBusSerial.Write(buffer, 0, 8);
+ }
#endregion
#region 回收箱操作
@@ -1314,6 +1358,7 @@ namespace DM_Weight.Port
}
}
+ #endregion
///
/// 冰箱使能
///
@@ -1693,8 +1738,7 @@ namespace DM_Weight.Port
}
//FridgeOperate = false;
}
- #endregion
- #endregion
+ #endregion
}
}
diff --git a/DM_Weight/ViewModels/FridgeOnlyWindowViewModel.cs b/DM_Weight/ViewModels/FridgeOnlyWindowViewModel.cs
new file mode 100644
index 0000000..1fa7beb
--- /dev/null
+++ b/DM_Weight/ViewModels/FridgeOnlyWindowViewModel.cs
@@ -0,0 +1,224 @@
+using DM_Weight.Common;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.util;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace DM_Weight.ViewModels
+{
+ public class FridgeOnlyWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
+ {
+ //温度区间
+ private string _temperatureRange = CommonClass.ReadAppSetting("temperatureRange").ToString();
+ public string TemperatureRange
+ {
+ get => _temperatureRange;
+ set
+ {
+ SetProperty(ref _temperatureRange, value);
+ //更新配置文件中冰箱温度区间
+ CommonClass.SaveAppSetting("temperatureRange", _temperatureRange);
+ }
+ }
+ private float defaultValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
+ //温度值
+ private float _temperatureValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
+ public float TemperatureValue
+ {
+ get => _temperatureValue;
+ set => SetProperty(ref _temperatureValue, value);
+ }
+ ///
+ /// 根据冰箱温度控制保存按钮是否可点击
+ ///
+ private bool _isInvalid;
+ public bool IsInvalid
+ {
+ get => _isInvalid;
+ set
+ {
+ SetProperty(ref _isInvalid, value);
+ BtnIsEnable = !IsInvalid;
+ }
+ }
+ ///
+ /// 根据冰箱温度控制保存按钮是否可用
+ ///
+ private bool _btnIsEnable = true;
+ public bool BtnIsEnable
+ {
+ get => _btnIsEnable;
+ set => SetProperty(ref _btnIsEnable, value);
+ }
+ //冰箱状态:true关;false开
+ private bool _fridgeState;
+ public bool FridgeState
+ {
+ get => _fridgeState;
+ set => SetProperty(ref _fridgeState, value);
+ }
+ //报警状态:true关;false开
+ private bool _alarmState;
+ public bool AlarmState
+ {
+ get => _alarmState;
+ set => SetProperty(ref _alarmState, value);
+ }
+
+ private int _defaultLoginMode;//1开0关
+
+ private int _defaultAlarmMode;//1开0关
+
+ private float retTemperature = Convert.ToSingle(ConfigurationManager.AppSettings["temperatureValue"]);
+
+ private PortUtil _portUtil;
+ IEventAggregator _eventAggregator;
+ public FridgeOnlyWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
+ {
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ }
+ ///
+ /// 保存按钮
+ ///
+ public DelegateCommand SaveCommand { get => new DelegateCommand(SaveAction, () => !IsInvalid); }
+
+ public bool KeepAlive => false;
+
+ private async void SaveAction()
+ {
+ try
+ {
+ _portUtil.FridgeOperate = true;
+
+ //设置温度值验证不通过则直接返回不保存
+ //获取冰箱温度
+ //if (_fridgeState != _defaultLoginMode.Equals(1))
+ //{
+ // ConfigurationManager.RefreshSection("FridgeState");
+ //发送冰箱使能/失能指令
+ if (_fridgeState)
+ {
+ await _portUtil.FridgeOff(1);
+ Thread.Sleep(100);
+ CommonClass.SaveAppSetting("FridgeState", "0");
+ }
+ else
+ {
+ await _portUtil.FridegOpen(1);
+ Thread.Sleep(100);
+ CommonClass.SaveAppSetting("FridgeState", "1");
+ }
+ //发送警报使能/失能指令
+ if (_alarmState)
+ {
+ await _portUtil.FridgeAlarmOff(1);
+ Thread.Sleep(100);
+ CommonClass.SaveAppSetting("AlarmState", "0");
+ }
+ else
+ {
+ await _portUtil.FridgeAlarmOn(1);
+ Thread.Sleep(100);
+ CommonClass.SaveAppSetting("AlarmState", "1");
+ }
+ //设定冰箱1温度区间
+ string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
+ string[] newRange = TemperatureRange.Split('-');
+ if (range.Length >= 2)
+ {
+ bool bMix = float.TryParse(range[0], out float Min);
+ bool bMax = float.TryParse(range[1], out float Max);
+
+ if (bMix && bMax)
+ {
+ if (Min != Convert.ToSingle(newRange[0]))
+ {
+ //设定冰箱温度最小值
+ await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]), 1);
+ Thread.Sleep(100);
+ }
+ if (Max != Convert.ToSingle(newRange[1]))
+ {
+ Thread.Sleep(100);
+ //设定冰箱温度最大值
+ await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
+ Thread.Sleep(100);
+ }
+ }
+ }
+
+
+ _portUtil.FridgeOperate = false;
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = $"保存成功",
+ Type = MsgType.SUCCESS
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ catch (Exception ex)
+ {
+
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = $"保存异常{ex.ToString}",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ _portUtil.FridgeOperate = false;
+ }
+ }
+ //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
+ public int ReadAppSetting(string key)
+ {
+ string xPath = "/configuration/appSettings//add[@key='" + key + "']";
+ XmlDocument doc = new XmlDocument();
+ string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
+ doc.Load(exeFileName + ".dll.config");
+ XmlNode node = doc.SelectSingleNode(xPath);
+ return Convert.ToInt32(node.Attributes["value"].Value);
+ }
+
+ public void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback)
+ {
+ }
+
+ public void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ _fridgeState = ReadAppSetting("FridgeState").Equals(0);
+ _defaultLoginMode = ReadAppSetting("FridgeState");
+ _defaultAlarmMode = ReadAppSetting("AlarmState");
+ _alarmState = ReadAppSetting("AlarmState").Equals(0);
+
+ GetTemperature();
+ }
+
+ public bool IsNavigationTarget(NavigationContext navigationContext)
+ {
+ return true;
+ }
+
+ public void OnNavigatedFrom(NavigationContext navigationContext)
+ {
+
+ }
+ //获取冰箱温度值,如有更改则保存更改
+ private async Task GetTemperature()
+ {
+
+ //float retT = await _portUtil.GetFridgeTemperature();
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs
index e4099ca..efd9efd 100644
--- a/DM_Weight/ViewModels/HomeWindowViewModel.cs
+++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs
@@ -34,8 +34,8 @@ namespace DM_Weight.ViewModels
private readonly IDialogService _dialogService;
private UserList? _userList;
private UserList? _userList2;
-
-
+
+
///
/// 冰箱温度
///
@@ -46,8 +46,8 @@ namespace DM_Weight.ViewModels
///
/// 是否有冰箱抽屉
///
- private string hasFridge= ConfigurationManager.AppSettings["hasFridge"].ToString().Equals("1")? "Visible" : "Collapsed";
- public string HasFridge { get => hasFridge; set => SetProperty(ref hasFridge,value); }
+ private string hasFridge = ConfigurationManager.AppSettings["hasFridge"].ToString().Equals("1") ? "Visible" : "Collapsed";
+ public string HasFridge { get => hasFridge; set => SetProperty(ref hasFridge, value); }
private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
public bool MultiLogin
@@ -128,6 +128,17 @@ namespace DM_Weight.ViewModels
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
}
}
+ else if (value.PremissionPath.Equals("SettingMainWindow") || value.PremissionPath.Equals("SettingWindow"))
+ {
+ if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"])>0)
+ {
+ _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
+ }
+ else
+ {
+ _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
+ }
+ }
else
{
_regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
@@ -298,11 +309,15 @@ namespace DM_Weight.ViewModels
{
string retStr = string.Empty;
byte[] data = null;
- float retT = await _portUtil.GetFridgeTemperature(1);
+ float retT = await _portUtil.GetFridgeTemperature(1);
Thread.Sleep(80);
- float retTemp = await _portUtil.GetFridgeTemperature(2);
- Thread.Sleep(80);
- WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;{retTemp}℃";
+ WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;";
+ if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
+ {
+ float retTemp = await _portUtil.GetFridgeTemperature(2);
+ Thread.Sleep(80);
+ WD += $"{retTemp}℃";
+ }
}
}
///
@@ -443,7 +458,7 @@ namespace DM_Weight.ViewModels
{
//指定时间内无人操作鼠标键盘则停止录像
- if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord)
+ if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord)
{
_chkFunction.HIKStopDVRRecord();
}
diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
index 8057243..b64c3e7 100644
--- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
+++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
@@ -268,7 +268,7 @@ namespace DM_Weight.ViewModels
Id = 27,
PremissionName = "请领列表",
PremissionPath = "ApplyListWindow",
- };
+ };
PremissionDm jiayao8 = new PremissionDm
{
Id = 28,
@@ -354,7 +354,7 @@ namespace DM_Weight.ViewModels
Id = 44,
PremissionName = "药品列表",
PremissionPath = "DrugListWindow",
- };
+ };
PremissionDm kuguan5 = new PremissionDm
{
Id = 45,
@@ -396,18 +396,27 @@ namespace DM_Weight.ViewModels
PremissionName = "角色管理",
PremissionPath = "RoleManagerWindow",
};
- //PremissionDm sysset3 = new PremissionDm
- //{
- // Id = 53,
- // PremissionName = "设置",
- // PremissionPath = "SettingWindow",
- //};
- PremissionDm sysset3 = new PremissionDm
+ PremissionDm sysset3;
+ if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
{
- Id = 53,
- PremissionName = "设置",
- PremissionPath = "SettingMainWindow",
- };
+ //有冰箱,需要冰箱设置(两个冰箱)
+ sysset3 = new PremissionDm
+ {
+ Id = 53,
+ PremissionName = "设置",
+ PremissionPath = "SettingMainWindow",
+ };
+
+ }
+ else
+ {
+ sysset3 = new PremissionDm
+ {
+ Id = 53,
+ PremissionName = "设置",
+ PremissionPath = "SettingWindow",
+ };
+ }
syssetChild.Add(sysset1);
syssetChild.Add(sysset2);
syssetChild.Add(sysset3);
diff --git a/DM_Weight/ViewModels/SettingMainWindowViewModel.cs b/DM_Weight/ViewModels/SettingMainWindowViewModel.cs
index 7e3a4e1..871a80c 100644
--- a/DM_Weight/ViewModels/SettingMainWindowViewModel.cs
+++ b/DM_Weight/ViewModels/SettingMainWindowViewModel.cs
@@ -8,20 +8,21 @@ using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
- public class SettingMainWindowViewModel : BindableBase, INavigationAware,IRegionMemberLifetime
+ public class SettingMainWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{
//设置页面数据集
private ObservableCollection _settingPages;
public ObservableCollection SettingPages
{
get => _settingPages;
- set=>SetProperty(ref _settingPages, value);
+ set => SetProperty(ref _settingPages, value);
}
//默认加载页面
string defaultView = string.Empty;
@@ -30,7 +31,7 @@ namespace DM_Weight.ViewModels
public SettingMainWindowViewModel(IRegionManager regionManager)
{
- this._regionManager=regionManager;
+ this._regionManager = regionManager;
}
//选中事件
public DelegateCommand NavigateCommand { get => new DelegateCommand(navigateAction); }
@@ -39,7 +40,7 @@ namespace DM_Weight.ViewModels
private void navigateAction(string obj)
{
- if(obj==null||string.IsNullOrWhiteSpace(obj))
+ if (obj == null || string.IsNullOrWhiteSpace(obj))
{
return;
}
@@ -57,16 +58,23 @@ namespace DM_Weight.ViewModels
public void OnNavigatedTo(NavigationContext navigationContext)
{
- if(SettingPages is null|| SettingPages.Count<=0)
+ if (SettingPages is null || SettingPages.Count <= 0)
{
- SettingPages=new ObservableCollection(SqlSugarHelper.Db.Queryable().ToList());
- if(SettingPages.Count>0)
+ if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) <= 1)
{
- if(string.IsNullOrEmpty(defaultView))
+ SettingPages = new ObservableCollection(SqlSugarHelper.Db.Queryable().Where(p=>p.Id!="2").ToList());
+ }
+ else
+ {
+ SettingPages = new ObservableCollection(SqlSugarHelper.Db.Queryable().Where(p => p.Id != "3").ToList());
+ }
+ if (SettingPages.Count > 0)
+ {
+ if (string.IsNullOrEmpty(defaultView))
{
defaultView = SettingPages[0].ViewName;
}
- _regionManager.RequestNavigate(PrismManager.SettingViewRegionName,defaultView);
+ _regionManager.RequestNavigate(PrismManager.SettingViewRegionName, defaultView);
}
}
}
diff --git a/DM_Weight/Views/FridgeOnlyWindow.xaml b/DM_Weight/Views/FridgeOnlyWindow.xaml
new file mode 100644
index 0000000..d432c28
--- /dev/null
+++ b/DM_Weight/Views/FridgeOnlyWindow.xaml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/FridgeOnlyWindow.xaml.cs b/DM_Weight/Views/FridgeOnlyWindow.xaml.cs
new file mode 100644
index 0000000..4c80496
--- /dev/null
+++ b/DM_Weight/Views/FridgeOnlyWindow.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace DM_Weight.Views
+{
+ ///
+ /// FridgeOnlyWindow.xaml 的交互逻辑
+ ///
+ public partial class FridgeOnlyWindow : UserControl
+ {
+ public FridgeOnlyWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}