change - 界面调整

master
wenjy 2 months ago
parent 64c93747b7
commit 9218e2c611

@ -95,13 +95,13 @@ namespace SlnMesnac.Business.@base
{
cabinetInfos = _ibase_Cabinet_InfoServices.Query(x=>x.isChecked == 1 && x.isFlag == 1).ToList();
if (equipAddr == 1) //左侧原点,正序巡检
if (equipAddr > 20) //20 号柜子之后倒叙巡检
{
cabinetInfos.OrderBy(x => x.cabinetCode);
cabinetInfos.OrderByDescending(x => x.cabinetCode);
}
else //右侧原点,倒序巡检
{
cabinetInfos.OrderByDescending(x => x.cabinetCode);
cabinetInfos.OrderBy(x => x.cabinetCode);
}
}

@ -35,7 +35,7 @@
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<Button Content="首 页" x:Name="Index" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="10,0,10,0"/>
<Button Content="电柜信息" x:Name="CabinetInfo" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=CabinetInfo}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="代码生成" x:Name="Generate" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Generate}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<!--<Button Content="代码生成" x:Name="Generate" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Generate}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>-->
<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>

@ -133,76 +133,146 @@
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="#FFFFFF" CornerRadius="5" Margin="0,0,0,10">
<Canvas x:Name="canvasTrack" >
<Canvas x:Name="canvasTrack" Margin="100,20,0,0">
<!-- 轨道 -->
<Rectangle Width="880" Height="100" Fill="Transparent" Stroke="Black" StrokeThickness="2" RadiusX="50" RadiusY="50"
Canvas.Left="70" Canvas.Top="50"/>
<!--<Rectangle Width="880" Height="100" Fill="Transparent" Stroke="Black" StrokeThickness="2" RadiusX="50" RadiusY="50"
Canvas.Left="10" Canvas.Top="50"/>
<!-- 站点 -->
<Rectangle x:Name="station1" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="105" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
--><!-- 站点 --><!--
<Rectangle x:Name="station1" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="5" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="1"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station2" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="175" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station2" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="55" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="2"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station3" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="245" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station3" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="105" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="3"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station4" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="315" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station4" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="155" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="4"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station5" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="385" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station5" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="205" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="5"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station6" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="455" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station6" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="255" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="6"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station7" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="525" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station7" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="305" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="7"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station8" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="595" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station8" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="355" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="8"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station9" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="665" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle x:Name="station9" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="405" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="9"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station10" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
<Rectangle x:Name="station10" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="455" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="10"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station11" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="505" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="11"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station12" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="555" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="12"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station13" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="605" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="13"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station14" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="655" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="14"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station15" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="705" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="15"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station16" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="755" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="16"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station17" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="805" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="17"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station18" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="855" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="18"/>
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station19" Width="35" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="905" Canvas.Top="25" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="19"/>
</Rectangle.ToolTip>
</Rectangle>-->
<!--<Rectangle x:Name="station10" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="105" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="10"/>
@ -216,6 +286,13 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
</Rectangle.ToolTip>
</Rectangle>
<Rectangle x:Name="station12" Width="50" Height="20" Fill="Gray" RadiusX="5" RadiusY="5"
Canvas.Left="245" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<Rectangle.ToolTip>
<TextBlock Text="12"/>
</Rectangle.ToolTip>
</Rectangle>-->
</Canvas>
@ -301,7 +378,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="实时位置" Foreground="Gray" FontSize="16" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="1" >
<TextBlock Text="A05-1" Foreground="Black" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RealPlcAddress}" Foreground="Black" FontSize="24" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
</Grid>
</Border>

@ -1,4 +1,5 @@
using SlnMesnac.WPF.ViewModel;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
@ -23,6 +24,8 @@ namespace SlnMesnac.WPF.Page
this.DataContext = indexControlViewModel;
indexControlViewModel.RefreshHighlightStationEvent += HighlightStation;
GenerateTrackAndStations();
}
#region 云台控制
@ -215,6 +218,86 @@ namespace SlnMesnac.WPF.Page
indexControlViewModel.Logout();
}
public void GenerateTrackAndStations()
{
// 生成轨道
Rectangle track = new Rectangle
{
Width = 950,
Height = 100,
Fill = Brushes.Transparent,
Stroke = Brushes.Black,
StrokeThickness = 2,
RadiusX = 50,
RadiusY = 50
};
Canvas.SetLeft(track, 10);
Canvas.SetTop(track, 50);
canvasTrack.Children.Add(track);
// 生成站点
for (int i = 0; i < 19; i++)
{
var stationNumber = GetStationNumber(i, true);
Rectangle station = new Rectangle
{
Width = 35,
Height = 20,
Fill = Brushes.Gray,
RadiusX = 5,
RadiusY = 5,
Stroke = Brushes.Transparent,
StrokeThickness = 1,
Name = $"station{stationNumber}",
};
// 设置位置
Canvas.SetLeft(station, 20 + i * 50); // 50 是两个矩形之间的间距
Canvas.SetTop(station, 25);
// 设置 ToolTip
ToolTip toolTip = new ToolTip();
TextBlock textBlock = new TextBlock { Text = stationNumber.ToString() };
toolTip.Content = textBlock;
station.ToolTip = toolTip;
station.Name = $"station{stationNumber}";
// 将矩形添加到 Canvas 中
canvasTrack.Children.Add(station);
}
for (int i = 0; i < 15; i++)
{
var stationNumber = GetStationNumber(i,false);
Rectangle station = new Rectangle
{
Width = 35,
Height = 20,
Fill = Brushes.Gray,
RadiusX = 5,
RadiusY = 5,
Stroke = Brushes.Transparent,
StrokeThickness = 1,
Name = $"station{stationNumber}"
};
// 设置位置
Canvas.SetLeft(station, 120 + i * 50); // 50 是两个矩形之间的间距
Canvas.SetTop(station, 155);
// 设置 ToolTip
ToolTip toolTip = new ToolTip();
TextBlock textBlock = new TextBlock { Text = stationNumber.ToString() };
toolTip.Content = textBlock;
station.ToolTip = toolTip;
station.Name = $"station{stationNumber}";
// 将矩形添加到 Canvas 中
canvasTrack.Children.Add(station);
}
}
private void HighlightStation(int stationNumber)
{
@ -224,12 +307,19 @@ namespace SlnMesnac.WPF.Page
// 根据输入的站点编号高亮对应的站点
if(canvasTrack!= null)
{
Rectangle station = (Rectangle)canvasTrack.FindName($"station{stationNumber}");
if (station != null)
foreach(Rectangle station in canvasTrack.Children)
{
if(station.Name == $"station{stationNumber}")
{
station.Fill = Brushes.GreenYellow;
}
}
//Rectangle station = (Rectangle)canvasTrack.FindName($"station{stationNumber}");
//if (station != null)
//{
// station.Fill = Brushes.GreenYellow;
//}
}
});
@ -237,16 +327,42 @@ namespace SlnMesnac.WPF.Page
private void ResetStationColors()
{
// 重置所有站点的颜色
for (int i = 1; i <= 18; i++)
foreach (Rectangle station in canvasTrack.Children)
{
Rectangle station = (Rectangle)canvasTrack.FindName($"station{i}");
if (station != null)
if (station.Name.Contains("station"))
{
station.Fill = Brushes.Gray;
}
}
}
private int GetStationNumber(int i,bool isFlag)
{
int number = 0;
if (isFlag)
{
List<int> list = new List<int>()
{
26,27,28,29,30,31,32,33,34,1,2,3,4,5,6,7,8,9,10
};
number = list[i];
}
else
{
List<int> list = new List<int>()
{
25,24,23,22,21,20,19,18,17,16,15,14,13,12,11
};
number = list[i];
}
return number;
}
}
}

@ -89,6 +89,13 @@ namespace SlnMesnac.WPF.ViewModel
set => SetProperty(ref _gimbalAutoRunText, value);
}
private int _realPlcAddress = 0;
public int RealPlcAddress
{
get => _realPlcAddress;
set => SetProperty(ref _realPlcAddress, value);
}
public RealTemperatureInfo _realTemperature;
public RealTemperatureInfo RealTemperature
{
@ -655,6 +662,7 @@ namespace SlnMesnac.WPF.ViewModel
if (trackMotorAddress != lastTrackMotorAddress)
{
RealPlcAddress = trackMotorAddress;
RefreshHighlightStationEvent?.Invoke(trackMotorAddress);
}
Task.Delay(1000).Wait();

@ -2,6 +2,7 @@
using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SlnMesnac.Plc;
using SlnMesnac.WPF.Page;
using SlnMesnac.WPF.Page.CabinetInfo;
using SlnMesnac.WPF.Page.Generate;
@ -89,7 +90,29 @@ namespace SlnMesnac.WPF.ViewModel
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x));
RefreshPlcStatus();
}
public void RefreshPlcStatus()
{
try
{
PlcAbsractFactory _plc = App.ServiceProvider.GetService<PlcAbsractFactory>();
if (_plc != null)
{
PlcStatus = 1;
}
else
{
PlcStatus = 2;
}
}
catch (Exception)
{
PlcStatus = 2;
}
}
/// <summary>

@ -8,10 +8,10 @@
},
"AllowedHosts": "*",
"AppConfig": {
"logPath": "F:\\桌面\\赛轮智慧热电项目\\日志信息",
"visibleRangePath": "F:\\桌面\\赛轮智慧热电项目\\日志信息\\可见光图像",
"infraredImagePath": "F:\\桌面\\赛轮智慧热电项目\\日志信息\\红外热成像",
"videoFilePath": "F:\\桌面\\赛轮智慧热电项目\\日志信息\\巡检录像",
"logPath": "D:\\巡检机器人控制系统\\日志信息",
"visibleRangePath": "D:\\智慧热电监控平台\\uploadPath\\日志信息\\可见光图像",
"infraredImagePath": "D:\\智慧热电监控平台\\uploadPath\\日志信息\\红外热成像",
"videoFilePath": "D:\\智慧热电监控平台\\uploadPath\\日志信息\\巡检录像",
"cameraIp": "192.168.2.64",
"cameraPort": 8000,
"cameraUserName": "admin",
@ -21,7 +21,7 @@
{
"configId": "iot",
"dbType": 0,
"connStr": "Data Source=175.27.215.92;Port=3306;Initial Catalog=iot_smarthotspot;uid=root;pwd=haiwei@123;Charset=utf8mb4;SslMode=none"
"connStr": "Data Source=127.0.0.1;Port=3306;Initial Catalog=iot_smarthotspot;uid=root;pwd=haiwei@123;Charset=utf8mb4;SslMode=none"
}
],
"PlcConfig": [
@ -29,11 +29,11 @@
"configId": 1,
"plcType": "SiemensPlc",
"plcIp": "127.0.0.1",
//"plcIp": "192.168.2.1",
"plcPort": 102,
"plcKey": "iot",
"isFlage": "true"
}
],
"redisConfig": "175.27.215.92:6379,password=redis@2023"
]
}
}

Loading…
Cancel
Save