NXX 2 years ago
parent
commit
ab60c69b98
13 changed files with 177 additions and 92 deletions
  1. +17
    -1
      BPASmartClient.Device/BaseDevice.cs
  2. +48
    -4
      BPASmartClient.IoT/DataVClient.cs
  3. +4
    -4
      BPASmartClient.IoT/Model/IOT/IOTDevModel.cs
  4. +43
    -0
      BPASmartClient.IoT/Model/MaintainTable.cs
  5. +9
    -2
      BPASmartClient.Model/KeepDataBase.cs
  6. +0
    -29
      BPASmartClient.Model/ParSet.cs
  7. +5
    -14
      BPASmartClient.MorkS/Control_Morks.cs
  8. +1
    -0
      BPASmartClient.MorkS/Model/MorksPar.cs
  9. +1
    -0
      BPASmartClient.MorkS/View/Debug.xaml
  10. +5
    -2
      BPASmartClient.MorkS/ViewModel/DebugViewModel.cs
  11. +3
    -2
      BPASmartClient.ViewModel/MainViewModel.cs
  12. +3
    -2
      BPASmartClient/App.config
  13. +38
    -32
      BPASmartClient/MainWindow.xaml

+ 17
- 1
BPASmartClient.Device/BaseDevice.cs View File

@@ -130,7 +130,7 @@ namespace BPASmartClient.Device
peripherals.ForEach(p =>
{
p.DeviceId = this.DeviceId;
p.Init();
});
this.peripherals = peripherals;
@@ -196,6 +196,21 @@ namespace BPASmartClient.Device
InitTask();
}

private void ResetStatus()
{
this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList().ForEach(item =>
{
var res = item.FieldType.GetInterfaces();
if (res != null)
{
foreach (var faces in res)
{
if (faces.Name == "IStatus") InterfaceStatus = item.GetValue(this) as IStatus;
}
}
});
}

private void GetGvlStatus()
{
this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList().ForEach(item =>
@@ -284,6 +299,7 @@ namespace BPASmartClient.Device
ThreadManage.GetInstance().StopTask($"GvlStatusMonitor:{DeviceId}", new Action(() =>
{
ResetProgram();
ResetStatus();
InitTask();
}));
}));


+ 48
- 4
BPASmartClient.IoT/DataVClient.cs View File

@@ -35,14 +35,24 @@ namespace BPASmartClient.IoT
public DataVClient()
{
DataVApiAddress = InternetInfo.DataVApiAddress;
//DataVApiAddress = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString();
ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString();
DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString();
ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString();
DeviceSecret = System.Configuration.ConfigurationManager.AppSettings["DeviceSecret"].ToString();
StartupMode = System.Configuration.ConfigurationManager.AppSettings["StartupMode"].ToString();
BroadcastPubTopic = InternetInfo.BroadcastPubTopic;
//BroadcastPubTopic = System.Configuration.ConfigurationManager.AppSettings["BroadcastPubTopic"].ToString();
//MaintainTable maintainTable = new MaintainTable();
//maintainTable.Id = Guid.NewGuid().ToString();
//maintainTable.MaintainTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//maintainTable.MaintainType = "一般";
//maintainTable.MaintainVla = "MorkS";
//maintainTable.MaintainMessage = "xxxxx故障需要维修";
//maintainTable.DeviceId = "";
//maintainTable.ClientId = ClientId;
//maintainTable.devicename = DeviceDataV.deviceTable.devicename;
//maintainTables.Add(maintainTable);
}
#endregion

@@ -72,6 +82,10 @@ namespace BPASmartClient.IoT
/// key值
/// </summary>
public Dictionary<string, string> keyValues = new Dictionary<string, string>();
/// <summary>
/// 维保通知
/// </summary>
public List<MaintainTable> maintainTables = new List<MaintainTable>();
#endregion

#region API调用
@@ -97,6 +111,34 @@ namespace BPASmartClient.IoT
}
return alarmTable.KeyID;
}
/// <summary>
/// 增加维保信息
/// </summary>
/// <param name="maintainTable"></param>
/// <returns></returns>
public string HttpAddMaintain(MaintainTable maintainTable)
{
try
{
if (DeviceDataV != null && DeviceDataV.GetIsConnected() && DeviceDataV.deviceTable != null)
{
maintainTable.Id=Guid.NewGuid().ToString();
//maintainTable.MaintainTime = DateTime.Now.ToString();
//maintainTable.MaintainType = "一般";
//maintainTable.MaintainVla = "MorkS";
//maintainTable.MaintainMessage = "xxxxx故障需要维修";
//maintainTable.DeviceId = "";
maintainTable.ClientId = ClientId;
maintainTable.devicename = DeviceDataV.deviceTable.devicename;
maintainTables.Add(maintainTable);
}
}
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);
}
return maintainTable.KeyID;
}

/// <summary>
/// 增加日志信息
@@ -208,6 +250,10 @@ namespace BPASmartClient.IoT
});
if (dataVNode.Count > 0)
{
if (maintainTables.Count > 0)
{
iOTDevSXModel.Maintain = Tools.JsonConvertTools(maintainTables);
}
iOTDevSXModel.NodeStatus = Tools.JsonConvertTools(new { data = dataVNode });
DeviceDataV.IOT_Publish(DeviceDataV.PubTopic, iOTDevSXModel.Tojson());
}
@@ -254,7 +300,6 @@ namespace BPASmartClient.IoT
});
keyValues[GetPropertyValue(obj, "Time").ToString() + GetPropertyValue(obj, "Type").ToString() + GetPropertyValue(obj, "Text").ToString()] = id;
//MessageLog.GetInstance.AddDeviceAlarmLogShow(GetPropertyValue(obj, "Time").ToString() + GetPropertyValue(obj, "Type").ToString() + GetPropertyValue(obj, "Text").ToString(),id);

}

/// <summary>
@@ -277,7 +322,6 @@ namespace BPASmartClient.IoT
State = "n"
});
//MessageLog.GetInstance.DeleteDeviceAlarmLogShow(message, keyValues[message]);

}
}



+ 4
- 4
BPASmartClient.IoT/Model/IOT/IOTDevModel.cs View File

@@ -82,10 +82,10 @@ namespace DataVAPI.Tool.IOT
/// 节点状态
/// </summary>
public string NodeStatus { get; set; }
///// <summary>
///// 运行日志
///// </summary>
//public string SZXX { get; set; }
/// <summary>
/// 维修保护
/// </summary>
public string Maintain { get; set; }
///// <summary>
///// 运行告警
///// </summary>


+ 43
- 0
BPASmartClient.IoT/Model/MaintainTable.cs View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.IoT.Model
{
/// <summary>
/// 维保
/// </summary>
public class MaintainTable : BaseEntity
{
/// <summary>
/// 维修时间
/// </summary>
public string MaintainTime { get; set; }
/// <summary>
/// 维修类型:1 轻微 2:一般 3 严重
/// </summary>
public string MaintainType { get; set; }
/// <summary>
/// 维修消息
/// </summary>
public string MaintainMessage { get; set; }
/// <summary>
/// 维修值
/// </summary>
public string MaintainVla { get; set; }
/// <summary>
/// IP 地址
/// </summary>
public string IP { get; set; }
/// <summary>
/// 状态描述
/// </summary>
public string StatusMS { get; set; }
/// <summary>
/// 状态颜色
/// </summary>
public object StatusColor { get; set; }
}
}

+ 9
- 2
BPASmartClient.Model/KeepDataBase.cs View File

@@ -6,11 +6,11 @@ using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Collections.Concurrent;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.Model
{
public class KeepDataBase
public class KeepDataBase : ObservableObject
{
/// <summary>
/// 模拟订单数据的配置
@@ -22,5 +22,12 @@ namespace BPASmartClient.Model
/// </summary>
public ObservableCollection<OrderData> orderLists { get; set; } = new ObservableCollection<OrderData>();

/// <summary>
/// 是否验证上位机
/// </summary>
public bool IsVerify { get { return _mIsVerify; } set { _mIsVerify = value; OnPropertyChanged(); } }
private bool _mIsVerify;


}
}

+ 0
- 29
BPASmartClient.Model/ParSet.cs View File

@@ -1,29 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace BPASmartClient.Model
//{
// public class ParSet
// {
// public ushort Minute { get { return _mMinute; } set { _mMinute = value; } }
// private ushort _mMinute;

// public ushort Second { get { return _mSecond; } set { _mSecond = value; } }
// private ushort _mSecond;


// public bool IsShield { get { return _mIsShield; } set { _mIsShield = value; } }
// private bool _mIsShield;


// public string TextBlockContext { get { return _mTextBlockContext; } set { _mTextBlockContext = value; } }
// private string _mTextBlockContext;

// public string CheckBoxContext { get { return _mCheckBoxContext; } set { _mCheckBoxContext = value; } }
// private string _mCheckBoxContext;

// }
//}

+ 5
- 14
BPASmartClient.MorkS/Control_Morks.cs View File

@@ -240,18 +240,7 @@ namespace BPASmartClient.MorkS
mORKS.doOrderEvents.Add(order);
if (order.MorkOrder.GoodBatchings == null) return;
OrderCount++;

new OrderStatusChangedEvent()
{
DeviceId = DeviceId,
SubOrderId = order.MorkOrder.SuborderId,
Status = ORDER_STATUS.WAIT,
GoodName = order.MorkOrder.GoodsName,
SortNum = order.MorkOrder.SortNum.ToString(),
deviceClientType = DeviceType
}.Publish();


OrderChange(order.MorkOrder.SuborderId, ORDER_STATUS.WAIT);
DeviceProcessLogShow($"接收到{OrderCount}次订单");
foreach (var item in order.MorkOrder.GoodBatchings)
{
@@ -294,8 +283,10 @@ namespace BPASmartClient.MorkS
public override void MainTask()
{
mORKS.AllowRun = mORKS.InitComplete;
IsHealth = mORKS.Error && mORKS.InitComplete;
//IsHealth = true;
if (Json<KeepDataBase>.Data.IsVerify)
IsHealth = mORKS.Error && mORKS.InitComplete;
else
IsHealth = true;

if (mORKS.AllowRun)
{


+ 1
- 0
BPASmartClient.MorkS/Model/MorksPar.cs View File

@@ -5,6 +5,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.MorkS.Model
{


+ 1
- 0
BPASmartClient.MorkS/View/Debug.xaml View File

@@ -25,6 +25,7 @@
Width="150"
Margin="10,0,0,0"
HorizontalAlignment="Left"
Command="{Binding InitCommand}"
Content="初始化设备"
Style="{StaticResource ButtonStyle}" />
</Grid>


+ 5
- 2
BPASmartClient.MorkS/ViewModel/DebugViewModel.cs View File

@@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace BPASmartClient.MorkS.ViewModel
{
@@ -12,7 +13,9 @@ namespace BPASmartClient.MorkS.ViewModel
{
public DebugViewModel()
{
InitCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("InitDevice"); });
}

public RelayCommand InitCommand { get; set; }
}
}

+ 3
- 2
BPASmartClient.ViewModel/MainViewModel.cs View File

@@ -1,6 +1,7 @@
using BPASmartClient.Business;
using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
@@ -74,7 +75,7 @@ namespace BPASmartClient.ViewModel
};
dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
dispatcherTimer.Start();


}
@@ -82,7 +83,7 @@ namespace BPASmartClient.ViewModel

public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }

public bool IsVerty { get { return Json<KeepDataBase>.Data.IsVerify; } set { Json<KeepDataBase>.Data.IsVerify = value; OnPropertyChanged(); } }

}



+ 3
- 2
BPASmartClient/App.config View File

@@ -4,7 +4,8 @@

<!--通用配置-->
<add key="ClientId" value="43"/>
<add key="IsEnableTest" value="true"/>
<add key="IsEnableTest" value="false"/>
<add key="IsVerify" value="false"/>

<!--开发环境-->
<!--<add key="apollouri" value="http://10.2.1.21:28080/"/>
@@ -19,7 +20,7 @@
<!--阿里云上报启动方式:API 或者 LOCAL-->
<!--API :通过客户端ID,调用接口查询“设备连接信息”-->
<!--LOCAL:直接使用下方本地“设备连接信息”-->
<add key="StartupMode" value="LOCAL"/>
<add key="StartupMode" value="API"/>
<add key="ProductKey" value="grgpECHSL7q"/>
<add key="DeviceName" value="qsqdzklb"/>
<add key="DeviceSecret" value="e2b300892c3e21469c8dc6c7c5c4430d"/>


+ 38
- 32
BPASmartClient/MainWindow.xaml View File

@@ -49,7 +49,7 @@
Margin="20,0,0,0"
VerticalAlignment="Center"
Style="{DynamicResource imagetop_Title}" />
<Grid Grid.Column="1" >
<Grid Grid.Column="1">
<Menu x:Name="myMenu">
<MenuItem Header="功能列表">
<MenuItem
@@ -82,7 +82,7 @@
Header="阿里连接维护"
Tag="DataVView" />
<Separator />
<MenuItem
<MenuItem
Click="Debug_Click"
FontSize="12"
Header="调试界面"
@@ -221,30 +221,35 @@
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border右下}" />
<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border左下}" />
<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border右上}" />
<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border左上}" />
<Grid Margin="10">
<Border Width="600" Style="{DynamicResource borderFromTitle}" />
<StackPanel Orientation="Horizontal" >
<StackPanel Orientation="Horizontal">
<CheckBox
Content="开机启动" Margin="5,0,5,0"
IsChecked="{Binding AutoStart}" />
<Button
Margin="5,0,5,0"
Content="开机启动"
IsChecked="{Binding AutoStart}" />
<CheckBox
Margin="5,0,5,0"
Content="验证设备"
IsChecked="{Binding IsVerty}" />
<!--<Button
Name="init" Margin="5,0,5,0"
Grid.Row="0"
Width="90"
@@ -259,7 +264,7 @@
VerticalAlignment="Top"
Click="Button_Click"
Content="测试"
Cursor="Hand" />
Cursor="Hand" />-->
</StackPanel>

<TextBlock
@@ -270,30 +275,31 @@
日志监控界面
</TextBlock>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Name="login" Margin="5,0,5,0"
Grid.Row="0"
Width="45"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Click="Button_Login"
Content="登录"
Cursor="Hand"/>
Name="login"
Grid.Row="0"
Width="45"
Margin="5,0,5,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Click="Button_Login"
Content="登录"
Cursor="Hand" />
<Button
Name="logout"
Grid.Row="0"
Width="45"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Click="Button_LogOut"
Command="{Binding LogoutCommand}"
Content="注销"
Cursor="Hand" />
Name="logout"
Grid.Row="0"
Width="45"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Click="Button_LogOut"
Command="{Binding LogoutCommand}"
Content="注销"
Cursor="Hand" />
</StackPanel>
</Grid>
<!--#region 底部窗体栏-->
<ContentControl x:Name="contentRegion" Grid.Row="1" />
<!--#endregion-->


Loading…
Cancel
Save