Commit 1bcdbd6d authored by 潘栩锋's avatar 潘栩锋 🚴

服务器添加快捷显示

parent f8f9d107
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<!--项目字符串-->
<ResourceDictionary Source="pack://application:,,,/MultiLayout;component/Themes/StringResources/zh/StringResource.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/StringResources/zh/StringResource.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:FLY.Thick.FilmCasting.UI.Server.Converters">
<conv:VisibilityConverter x:Key="visbilityconv" />
<conv:IO2BitBoolConverter x:Key="io2bconv"/>
</ResourceDictionary>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FLY.Thick.FilmCasting.UI.Server.Converters
{
public class IO2BitBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
string str = (string)parameter;
int bitno = int.Parse(str);
if (value is UInt16)
{
UInt16 io = (UInt16)value;
if (Misc.MyBase.CHECKBIT(io, bitno))
return false;
else
return true;
}
else if (value is UInt32)
{
UInt32 io = (UInt32)value;
if (Misc.MyBase.CHECKBIT(io, bitno))
return false;
else
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FLY.Thick.FilmCasting.UI.Server.Converters
{
public class VisibilityConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool enable = (bool)value;
string p = null;
if (parameter != null)
p = parameter as string;
if (p == "Collapsed")
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else if (p == "HiddenWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
else if (p == "CollapsedWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
using FLY.Thick.FilmCasting.Server;
using FLY.Thick.FilmCasting.Server.OBJProxy;
using FLY.Thick.FilmCasting.Server.WsProxy;
using FLY.Thick.FilmCasting.WebAPI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using WebSocketSharp.Server;
namespace FLY.Thick.FilmCasting.UI.Server
{
internal class Launcher
{
TDGage mGage;
OBJProxys mOBJProxy;
ThkWebApiServer thkWebApiServer;
/// <summary>
/// WebSocket 服务
/// </summary>
WebSocketServer wss;
WsProxys thkWsProxys;
//用于界面
public IUnityContainer container;
public Launcher()
{
container = new UnityContainer();
}
public async Task Init()
{
//更改路径
string rootDir = "Gage1";
if (!System.IO.Directory.Exists(rootDir))
System.IO.Directory.CreateDirectory(rootDir);
System.Environment.CurrentDirectory = rootDir;
mGage = new TDGage();
await mGage.Init();
mOBJProxy = new OBJProxys(0, mGage);
FObjBase.FObjSys.Currents[0].Start_Conn_Server(
Misc.StringConverter.ToIPEndPoint(mGage.sysParam.Addr));
FObjBase.PollModule.Current.Start();
thkWebApiServer = new ThkWebApiServer();
thkWebApiServer.Init(mGage);
thkWebApiServer.Start();
wss = new WebSocketServer($"ws://{mGage.sysParam.WsAddr}/");
thkWsProxys = new WsProxys(wss, mGage);
wss.Start();
//----------------------------------------------------------------------------
//注册容器
container.RegisterInstance(mGage);
container.RegisterInstance(thkWebApiServer);
container.RegisterInstance(mGage.sysParam);
container.RegisterInstance(mGage.flyAd);
container.RegisterInstance(wss);
container.RegisterInstance(mGage.errnoList);
container.RegisterInstance(mGage.warning);
}
}
}
using CommunityToolkit.Mvvm.Input;
using FLY.Thick.Base.Server;
using FLY.Thick.FilmCasting.Server;
using FLY.Thick.FilmCasting.WebAPI;
using FlyADBase;
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Unity;
using InitParam = FLY.Thick.FilmCasting.Server.InitParam;
using SysParam = FLY.Thick.FilmCasting.Server.SysParam;
namespace FLY.Thick.FilmCasting.UI.Server
......@@ -61,7 +56,7 @@ namespace FLY.Thick.FilmCasting.UI.Server
[InjectionMethod]
public void Init(
IUnityContainer container,
TDGage mGage,
TDGage mGage,
ThkWebApiServer thkWebApiServer)
{
this.container = container;
......@@ -100,73 +95,4 @@ namespace FLY.Thick.FilmCasting.UI.Server
}
}
public class ConnectionValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool? b = (bool?)value;
if (b == null)
return null;
else if (b == true)
return "连接成功";
else
return "连接断开";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class IO2BinConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!(value is UInt16))
return null;
int number = 16;
if (parameter is string)
{
if (int.TryParse((string)parameter, out number))
{
}
if (number > 16)
number = 16;
else if (number < 4)
number = 4;
}
UInt16 io = (UInt16)value;
string str = "";
for (int i = 0; i < 4; i++)
{
if (i * 4 >= number)
break;
byte b = (byte)((io >> (i * 4)) & 0x0f);
string str_b = System.Convert.ToString(b, 2);
if (string.IsNullOrEmpty(str))
{
str = str_b.PadLeft(4, '0');
}
else
{
str = str_b.PadLeft(4, '0') + " " + str;
}
}
return str;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return System.Convert.ToUInt16((string)value, 2);
}
#endregion
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="Brush.LedOn" Color="Yellow"/>
<SolidColorBrush x:Key="Brush.LenOff" Color="Gray"/>
<Style TargetType="Border" x:Key="Styles.Border.IO">
<Setter Property="Background" Value="{StaticResource Brush.LenOff}"/>
<Setter Property="Height" Value="12"/>
<Setter Property="Width" Value="10"/>
<Setter Property="Margin" Value="1,1"/>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Tag}" Value="True">
<Setter Property="Background" Value="{StaticResource Brush.LedOn}"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="TextBlock" x:Key="Styles.Text.IO">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="10"/>
</Style>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--字符串换行 必须添加 xml:space="preserve" -->
<!--字符串换行 换行符 &#10; -->
<!--PgLoading.xaml-->
<system:String x:Key="str.PgLoading.Loading">初始化中</system:String>
<!--PgMain.xaml-->
<system:String x:Key="str.PgMain.Header">流延平扫</system:String>
<system:String x:Key="str.PgMain.SubHeader">X射线测厚仪服务器</system:String>
<system:String x:Key="str.PgMain.Reboot">重启</system:String>
<system:String x:Key="str.PgMain.Thickness">测厚系统</system:String>
<system:String x:Key="str.PgMain.AllErrNOs">报警码列表</system:String>
<system:String x:Key="str.PgMain.FOBJService">FOBJ 服务</system:String>
<system:String x:Key="str.PgMain.ServiceAddr">服务地址</system:String>
<system:String x:Key="str.PgMain.WebAPIService">WebAPI 服务</system:String>
<system:String x:Key="str.PgMain.StateIsStopping">停止</system:String>
<system:String x:Key="str.PgMain.StateIsWorking">工作中</system:String>
<system:String x:Key="str.PgMain.OpenSwaggerUI">打开 swagger UI</system:String>
<system:String x:Key="str.PgMain.FlyAd">AD盒</system:String>
<system:String x:Key="str.PgMain.WsService">WebSocket 服务</system:String>
<system:String x:Key="str.PgMain.ModbusTcpService">ModbusTCP 服务</system:String>
<system:String x:Key="str.PgMain.ConnectedCnt">当前连接数</system:String>
<system:String x:Key="str.PgMain.Connected">连接成功</system:String>
<system:String x:Key="str.PgMain.Disconnected">连接断开</system:String>
<system:String x:Key="str.PgMain.Addr">地址</system:String>
<system:String x:Key="str.PgMain.BeResetTime">连接时间</system:String>
<system:String x:Key="str.PgMain.Times">次</system:String>
<system:String x:Key="str.PgMain.Now">系统时间</system:String>
<system:String x:Key="str.PgMain.Pulse">脉冲</system:String>
<system:String x:Key="str.PgMain.Setup">设置</system:String>
<system:String x:Key="str.PgMain.AddrSetting">地址设置</system:String>
<system:String x:Key="str.PgMain.BlowingScan">平扫测厚</system:String>
<system:String x:Key="str.PgMain.Debug">查看棍速</system:String>
<!--WdSetup.xaml-->
<system:String x:Key="str.WdSetup.Title">参数设置</system:String>
<system:String x:Key="str.WdSetup.FOBJAddr">FOBJ 服务地址</system:String>
<system:String x:Key="str.WdSetup.ModbusTcpAddr">ModbusTCP 服务地址</system:String>
<system:String x:Key="str.WdSetup.WebApiAddr">WebAPI 服务地址</system:String>
<system:String x:Key="str.WdSetup.WsAddr">WebSocket 服务地址</system:String>
<system:String x:Key="str.WdSetup.FlyAdAddr">AD盒 地址</system:String>
<system:String x:Key="str.WdSetup.Lanuage">语言</system:String>
<system:String x:Key="str.WdSetup.OK">确定</system:String>
<system:String x:Key="str.WdSetup.IsSureToReboot">程序必须重启才能执行新的参数, 是否重启?</system:String>
<!--PgAllErrNos.xaml-->
<system:String x:Key="str.PgAllErrNos.ErrCode">代码</system:String>
<system:String x:Key="str.PgAllErrNos.Description">描述</system:String>
<!--MainWindow.xaml-->
<system:String x:Key="str.MainWindow.Title" xml:space="preserve">枫莱尔 流延测厚仪服务器</system:String>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="StringResource.PgMain.xaml" />
<!--项目报警项 字符串-->
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base;component/Themes/StringResources/zh/StringResource.ERRNO.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
\ No newline at end of file
<UserControl x:Class="FLY.Thick.FilmCasting.UI.Server.UcAllErrNos"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.Thick.FilmCasting.UI.Server"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="greyDataGridRowStyle" TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="True">
<Setter Property="Background" Value="LightPink" />
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
<DataGrid ItemsSource="{Binding ErrNos}" AutoGenerateColumns="False" IsReadOnly="True" Margin="{StaticResource ControlMargin}"
AlternationCount ="2"
RowHeaderWidth="0"
RowStyle="{StaticResource greyDataGridRowStyle}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding ErrCode}" Header="{StaticResource str.PgAllErrNos.ErrCode}"/>
<DataGridTextColumn Binding="{Binding Description}" Header="{StaticResource str.PgAllErrNos.Description}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl>
using FLY.OBJComponents.Common;
using FLY.OBJComponents.Server;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
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 FLY.Thick.FilmCasting.UI.Server
{
/// <summary>
/// PgAllErrNos.xaml 的交互逻辑
/// </summary>
public partial class UcAllErrNos : UserControl
{
UcAllErrNosVm viewModel;
public UcAllErrNos()
{
InitializeComponent();
}
[Unity.InjectionMethod]
public void Init(List<ERRNO> errnos, WarningSystem2 warningSystem)
{
viewModel = new UcAllErrNosVm();
viewModel.Init(errnos, warningSystem);
this.DataContext = viewModel;
}
}
public class UcAllErrNosVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<ERRNOView> ErrNos { get; private set; }
WarningSystem2 warningSystem;
public void Init(List<ERRNO> errnos, WarningSystem2 warningSystem)
{
this.warningSystem = warningSystem;
ErrNos = new ObservableCollection<ERRNOView>(errnos.Select(errno => new ERRNOView() { ErrCode = errno.Code, Description = errno.Description }));
updateIsError();
warningSystem.PropertyChanged += WarningSystem_PropertyChanged;
}
private void WarningSystem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(warningSystem.ReasonList))
{
updateIsError();
}
}
void updateIsError()
{
if (warningSystem.ReasonList != null && warningSystem.ReasonList.Count() > 0)
{
for (int i = 0; i < ErrNos.Count(); i++)
{
var errNo = ErrNos[i];
if (warningSystem.ReasonList.Any(f => f.ErrCode == errNo.ErrCode))
errNo.IsError = true;
else
errNo.IsError = false;
}
}
else
{
for (int i = 0; i < ErrNos.Count(); i++)
{
var errNo = ErrNos[i];
errNo.IsError = false;
}
}
}
}
public class ERRNOView : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public int ErrCode { get; set; }
public string Description { get; set; }
public bool IsError { get; set; }
}
}
......@@ -81,8 +81,7 @@ namespace FLY.Thick.FilmCasting.WebAPI.Controllers
/// </summary>
public void Apply()
{
//TODO
//flyADService.Apply();
flyADService.Apply();
}
/// <summary>
/// 获取grid
......
using FLY.Thick.FilmCasting.Common;
using FObjBase.Reflect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Thick.FilmCasting.IService
{
/// <summary>
///
/// </summary>
public interface IThkGaugeService
{
/// <summary>
/// 动态区数据
/// </summary>
[PropertyPush]
FLY.Thick.Base.Common.DynArea DynArea { get; }
/// <summary>
/// 扫描
/// </summary>
void Scan();
/// <summary>
/// 停止
/// </summary>
void Stop();
/// <summary>
/// 归零
/// </summary>
void Home();
/// <summary>
/// 前进
/// </summary>
void Forward();
/// <summary>
/// 后退
/// </summary>
void Backward();
/// <summary>
/// 运行到targetPos
/// </summary>
void Runto(int targetpos);
/// <summary>
/// 一直前进
/// </summary>
void ForwUntilStop();
/// <summary>
/// 一直后退
/// </summary>
void BackwUntilStop();
}
}
......@@ -332,7 +332,7 @@ namespace FLY.Thick.FilmCasting.Server
{
warningSystem.Add(
ERRNOs.ERRNO_SCAN_FATAL.Code,
ERRNOs.ERRNO_SCAN_FATAL.Description, accessory: "AD连接断开");
ERRNOs.ERRNO_SCAN_FATAL.Description, accessory: "AD连接断开");
return;
}
//设置扫描范围
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Misc;
using System.Net;
using System.IO;
using System.ComponentModel;
using System.Xml.Serialization;
using FLY.Thick.Base.Common;
using Newtonsoft.Json;
namespace FLY.Thick.FilmCasting.Server
{
/// <summary>
///
/// </summary>
public class SysParam : INotifyPropertyChanged
{
#region 属性,成员变量的代理
/// <summary>
/// 本机obj服务地址
/// </summary>
public string Addr { get; set; } = "0.0.0.0:20006";
/// <summary>
/// 本机websocket服务地址
/// </summary>
public string WsAddr { get; set; } = "localhost:5540";
#endregion
private string param_path = "sysparam.json";
public SysParam()
{
}
public SysParam(string param_path)
{
if (!string.IsNullOrEmpty(param_path))
this.param_path = param_path;
if (!Load()) {
Save();
}
}
public bool Load()
{
try
{
if (File.Exists(param_path))
{
string json = File.ReadAllText(param_path);
JsonConvert.PopulateObject(json, this);
return true;
}
}
catch
{
//异常,没有json 解码失败
}
return false;
}
public bool Save()
{
try
{
File.WriteAllText(param_path, JsonConvert.SerializeObject(this, Formatting.Indented));
return true;
}
catch
{
//异常,没有json 编码失败
}
return false;
}
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment