MotionDebugView.xaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <UserControl x:Class="TeamAAS.Motion.MotionDebugView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:loc="clr-namespace:TeamAAS.Localization;assembly=TeamAAS.Global"
  5. Background="Transparent">
  6. <UserControl.Resources>
  7. <Style x:Key="SectionCard" TargetType="Border">
  8. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  9. <Setter Property="CornerRadius" Value="6"/>
  10. <Setter Property="Padding" Value="12"/>
  11. <Setter Property="Margin" Value="0,0,0,10"/>
  12. </Style>
  13. <Style x:Key="SectionTitle" TargetType="TextBlock">
  14. <Setter Property="FontSize" Value="11"/>
  15. <Setter Property="FontWeight" Value="SemiBold"/>
  16. <Setter Property="Foreground" Value="{DynamicResource SecondaryTextBrush}"/>
  17. <Setter Property="Margin" Value="0,0,0,8"/>
  18. </Style>
  19. <Style x:Key="MetricLabel" TargetType="TextBlock">
  20. <Setter Property="FontSize" Value="11"/>
  21. <Setter Property="Foreground" Value="{DynamicResource SecondaryTextBrush}"/>
  22. </Style>
  23. <Style x:Key="MetricValue" TargetType="TextBlock">
  24. <Setter Property="FontFamily" Value="Consolas"/>
  25. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
  26. </Style>
  27. <Style x:Key="FieldLabel" TargetType="TextBlock">
  28. <Setter Property="FontSize" Value="12"/>
  29. <Setter Property="VerticalAlignment" Value="Center"/>
  30. <Setter Property="Margin" Value="0,0,8,0"/>
  31. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
  32. </Style>
  33. <Style x:Key="FieldBox" TargetType="TextBox">
  34. <Setter Property="MinWidth" Value="88"/>
  35. <Setter Property="Height" Value="28"/>
  36. <Setter Property="VerticalContentAlignment" Value="Center"/>
  37. <Setter Property="Padding" Value="6,2"/>
  38. </Style>
  39. <Style x:Key="StatusTile" TargetType="Border">
  40. <Setter Property="CornerRadius" Value="6"/>
  41. <Setter Property="Padding" Value="10,12"/>
  42. <Setter Property="Margin" Value="0,0,8,0"/>
  43. <Setter Property="MinHeight" Value="72"/>
  44. </Style>
  45. <Style x:Key="IoBitButton" TargetType="ToggleButton">
  46. <Setter Property="Foreground" Value="White"/>
  47. <Setter Property="BorderThickness" Value="0"/>
  48. <Setter Property="Cursor" Value="Hand"/>
  49. <Setter Property="Template">
  50. <Setter.Value>
  51. <ControlTemplate TargetType="ToggleButton">
  52. <Border Background="{TemplateBinding Background}" CornerRadius="4"
  53. Padding="2" Opacity="{TemplateBinding Opacity}">
  54. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
  55. </Border>
  56. </ControlTemplate>
  57. </Setter.Value>
  58. </Setter>
  59. </Style>
  60. </UserControl.Resources>
  61. <DockPanel Margin="4">
  62. <DockPanel DockPanel.Dock="Top" Margin="4,2,4,10">
  63. <TextBlock DockPanel.Dock="Left" Text="{loc:Translate '运动调试'}"
  64. FontSize="15" FontWeight="Bold" VerticalAlignment="Center"
  65. Foreground="{DynamicResource PrimaryTextBrush}"/>
  66. <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
  67. <TextBlock Text="{loc:Translate '当前轴'}" Style="{StaticResource FieldLabel}"/>
  68. <ComboBox x:Name="CmbAxis" Width="160" Height="28"
  69. SelectionChanged="CmbAxis_SelectionChanged">
  70. <ComboBox.ItemTemplate>
  71. <DataTemplate>
  72. <TextBlock>
  73. <TextBlock.Text>
  74. <MultiBinding StringFormat="{}{0} (轴{1})">
  75. <Binding Path="Name"/>
  76. <Binding Path="AxisNo"/>
  77. </MultiBinding>
  78. </TextBlock.Text>
  79. </TextBlock>
  80. </DataTemplate>
  81. </ComboBox.ItemTemplate>
  82. </ComboBox>
  83. </StackPanel>
  84. </DockPanel>
  85. <Border DockPanel.Dock="Top" Style="{StaticResource SectionCard}" Padding="12,8" Margin="0,0,0,10">
  86. <DockPanel>
  87. <StackPanel DockPanel.Dock="Left" Orientation="Horizontal" VerticalAlignment="Center">
  88. <Ellipse x:Name="DotConn" Width="9" Height="9" Fill="#9E9E9E" Margin="0,0,8,0"/>
  89. <TextBlock Text="{loc:Translate '状态'}" FontSize="12"
  90. Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,6,0"/>
  91. <TextBlock x:Name="TxtStatus" FontSize="12" FontWeight="Bold"
  92. Foreground="{DynamicResource PrimaryTextBrush}" Text="---"/>
  93. </StackPanel>
  94. <TextBlock x:Name="TxtMessage" FontSize="12" TextWrapping="Wrap"
  95. VerticalAlignment="Center" Margin="16,0,0,0"
  96. Foreground="{DynamicResource SecondaryTextBrush}"/>
  97. </DockPanel>
  98. </Border>
  99. <TabControl x:Name="TabsMain">
  100. <TabItem Header="{loc:Translate '轴'}">
  101. <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Padding="4,8,4,4">
  102. <Grid>
  103. <Grid.ColumnDefinitions>
  104. <ColumnDefinition Width="1.1*"/>
  105. <ColumnDefinition Width="16"/>
  106. <ColumnDefinition Width="1.2*"/>
  107. </Grid.ColumnDefinitions>
  108. <!-- 左侧:实时状态 -->
  109. <StackPanel Grid.Column="0">
  110. <Border x:Name="BannerSafety" CornerRadius="6" Padding="16,18" Margin="0,0,0,10"
  111. Background="#B71C1C" Visibility="Collapsed">
  112. <StackPanel>
  113. <TextBlock x:Name="TxtSafetyHeadline" Text="急停有效"
  114. FontSize="26" FontWeight="Bold" Foreground="White"/>
  115. <TextBlock x:Name="TxtSafetyHint"
  116. Text="所有轴已下使能,手动/自动使能与运动均被禁止。"
  117. FontSize="14" FontWeight="SemiBold" Foreground="#FFECB3"
  118. Margin="0,8,0,0" TextWrapping="Wrap"/>
  119. </StackPanel>
  120. </Border>
  121. <Border x:Name="BannerState" CornerRadius="6" Padding="14,16" Margin="0,0,0,10" Background="#616161">
  122. <StackPanel>
  123. <TextBlock x:Name="TxtAxisTitle" Text="---" FontSize="12" Foreground="#E0E0E0" Margin="0,0,0,6"/>
  124. <TextBlock x:Name="TxtStateHeadline" Text="未选择轴" FontSize="22" FontWeight="Bold" Foreground="White"/>
  125. <TextBlock x:Name="TxtStateHint" Text="请选择轴并连接控制卡" FontSize="12" Foreground="#F5F5F5" Margin="0,6,0,0" TextWrapping="Wrap"/>
  126. </StackPanel>
  127. </Border>
  128. <UniformGrid Columns="3" Margin="0,0,0,10">
  129. <Border x:Name="TileEnable" Style="{StaticResource StatusTile}" Margin="0,0,6,0" Background="#757575">
  130. <StackPanel VerticalAlignment="Center">
  131. <TextBlock Text="{loc:Translate '使能'}" FontSize="11" Foreground="#EEEEEE"/>
  132. <TextBlock x:Name="TxtEnable" Text="未使能" FontSize="16" FontWeight="Bold" Foreground="White" Margin="0,4,0,0"/>
  133. </StackPanel>
  134. </Border>
  135. <Border x:Name="TileMoving" Style="{StaticResource StatusTile}" Margin="3,0,3,0" Background="#757575">
  136. <StackPanel VerticalAlignment="Center">
  137. <TextBlock Text="{loc:Translate '运动'}" FontSize="11" Foreground="#EEEEEE"/>
  138. <TextBlock x:Name="TxtMoving" Text="静止" FontSize="16" FontWeight="Bold" Foreground="White" Margin="0,4,0,0"/>
  139. </StackPanel>
  140. </Border>
  141. <Border x:Name="TileHomed" Style="{StaticResource StatusTile}" Margin="6,0,0,0" Background="#757575">
  142. <StackPanel VerticalAlignment="Center">
  143. <TextBlock Text="{loc:Translate '回零'}" FontSize="11" Foreground="#EEEEEE"/>
  144. <TextBlock x:Name="TxtHomed" Text="未回零" FontSize="16" FontWeight="Bold" Foreground="White" Margin="0,4,0,0"/>
  145. </StackPanel>
  146. </Border>
  147. </UniformGrid>
  148. <Border Style="{StaticResource SectionCard}">
  149. <StackPanel>
  150. <TextBlock Text="{loc:Translate '位置 / 速度'}" Style="{StaticResource SectionTitle}"/>
  151. <TextBlock Text="{loc:Translate '实际位置'}" Style="{StaticResource MetricLabel}"/>
  152. <TextBlock x:Name="TxtPosActual" Text="---" FontSize="28" FontWeight="Bold"
  153. Style="{StaticResource MetricValue}" Margin="0,2,0,10"/>
  154. <Grid>
  155. <Grid.ColumnDefinitions>
  156. <ColumnDefinition Width="*"/>
  157. <ColumnDefinition Width="*"/>
  158. </Grid.ColumnDefinitions>
  159. <StackPanel Grid.Column="0">
  160. <TextBlock Text="{loc:Translate '指令位置'}" Style="{StaticResource MetricLabel}"/>
  161. <TextBlock x:Name="TxtPosCommand" Text="---" FontSize="16"
  162. Style="{StaticResource MetricValue}" Margin="0,2,0,0"/>
  163. </StackPanel>
  164. <StackPanel Grid.Column="1">
  165. <TextBlock Text="{loc:Translate '实际速度'}" Style="{StaticResource MetricLabel}"/>
  166. <TextBlock x:Name="TxtVelocity" Text="---" FontSize="16"
  167. Style="{StaticResource MetricValue}" Margin="0,2,0,0"/>
  168. </StackPanel>
  169. </Grid>
  170. </StackPanel>
  171. </Border>
  172. </StackPanel>
  173. <!-- 右侧:操作 -->
  174. <StackPanel x:Name="OpsRoot" Grid.Column="2" IsEnabled="False">
  175. <Border Style="{StaticResource SectionCard}">
  176. <StackPanel>
  177. <TextBlock Text="{loc:Translate '轴控制'}" Style="{StaticResource SectionTitle}"/>
  178. <WrapPanel>
  179. <Button x:Name="BtnEnable" Content="{loc:Translate '使能'}" Style="{DynamicResource ButtonPrimary}"
  180. Padding="16,6" Margin="0,0,8,8" Click="BtnEnable_Click"/>
  181. <Button x:Name="BtnDisable" Content="{loc:Translate '下使能'}" Style="{DynamicResource ButtonDefault}"
  182. Padding="16,6" Margin="0,0,8,8" Click="BtnDisable_Click"/>
  183. <Button x:Name="BtnStop" Content="{loc:Translate '停止'}" Style="{DynamicResource ButtonDefault}"
  184. Padding="16,6" Margin="0,0,8,8" Click="BtnStop_Click"/>
  185. <Button Content="{loc:Translate '急停'}" Style="{DynamicResource ButtonDanger}"
  186. Padding="16,6" Margin="0,0,0,8" Click="BtnEStop_Click"/>
  187. </WrapPanel>
  188. </StackPanel>
  189. </Border>
  190. <TextBlock x:Name="TxtNeedEnable" Text="{loc:Translate '当前未使能,请先点击「使能」后再点动或定位'}"
  191. FontSize="12" FontWeight="SemiBold" Foreground="#E53935" Margin="0,0,0,8"
  192. TextWrapping="Wrap" Visibility="Collapsed"/>
  193. <StackPanel x:Name="MotionOps">
  194. <Border Style="{StaticResource SectionCard}">
  195. <StackPanel>
  196. <DockPanel Margin="0,0,0,4">
  197. <TextBlock Text="{loc:Translate '点动'}" Style="{StaticResource SectionTitle}" Margin="0"/>
  198. <TextBlock DockPanel.Dock="Right" HorizontalAlignment="Right"
  199. Text="{loc:Translate '按住移动,松开停止'}"
  200. FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}"/>
  201. </DockPanel>
  202. <StackPanel Orientation="Horizontal" Margin="0,8,0,10">
  203. <TextBlock Text="{loc:Translate '速度'}" Style="{StaticResource FieldLabel}"/>
  204. <TextBox x:Name="TxtJogVel" Text="50" Style="{StaticResource FieldBox}"/>
  205. </StackPanel>
  206. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
  207. <Button Content="−" Tag="-" Style="{DynamicResource ButtonDefault}"
  208. Width="88" Height="48" FontSize="20" FontWeight="Bold" Margin="0,0,8,0"
  209. PreviewMouseLeftButtonDown="BtnJog_Down"
  210. PreviewMouseLeftButtonUp="BtnJog_Up"
  211. LostMouseCapture="BtnJog_LostCapture"/>
  212. <Button Content="+" Tag="+" Style="{DynamicResource ButtonPrimary}"
  213. Width="88" Height="48" FontSize="20" FontWeight="Bold"
  214. PreviewMouseLeftButtonDown="BtnJog_Down"
  215. PreviewMouseLeftButtonUp="BtnJog_Up"
  216. LostMouseCapture="BtnJog_LostCapture"/>
  217. </StackPanel>
  218. </StackPanel>
  219. </Border>
  220. <Border Style="{StaticResource SectionCard}">
  221. <StackPanel>
  222. <TextBlock Text="{loc:Translate '定位'}" Style="{StaticResource SectionTitle}"/>
  223. <Grid>
  224. <Grid.ColumnDefinitions>
  225. <ColumnDefinition Width="Auto"/>
  226. <ColumnDefinition Width="*"/>
  227. <ColumnDefinition Width="Auto"/>
  228. </Grid.ColumnDefinitions>
  229. <Grid.RowDefinitions>
  230. <RowDefinition Height="Auto"/>
  231. <RowDefinition Height="Auto"/>
  232. <RowDefinition Height="Auto"/>
  233. </Grid.RowDefinitions>
  234. <TextBlock Grid.Row="0" Grid.Column="0" Text="{loc:Translate '定位速度'}" Style="{StaticResource FieldLabel}" Margin="0,0,8,8"/>
  235. <TextBox x:Name="TxtMoveVel" Grid.Row="0" Grid.Column="1" Text="100" Style="{StaticResource FieldBox}" Margin="0,0,8,8"/>
  236. <TextBlock Grid.Row="1" Grid.Column="0" Text="{loc:Translate '目标位置'}" Style="{StaticResource FieldLabel}" Margin="0,0,8,8"/>
  237. <TextBox x:Name="TxtTargetPos" Grid.Row="1" Grid.Column="1" Text="0" Style="{StaticResource FieldBox}" Margin="0,0,8,8"/>
  238. <Button Grid.Row="1" Grid.Column="2" Content="{loc:Translate '绝对定位'}"
  239. Style="{DynamicResource ButtonPrimary}" Padding="16,6" Margin="0,0,0,8"
  240. Click="BtnMoveAbs_Click"/>
  241. <TextBlock Grid.Row="2" Grid.Column="0" Text="{loc:Translate '相对距离'}" Style="{StaticResource FieldLabel}" Margin="0,0,8,0"/>
  242. <TextBox x:Name="TxtRelativeDist" Grid.Row="2" Grid.Column="1" Text="10" Style="{StaticResource FieldBox}" Margin="0,0,8,0"/>
  243. <Button Grid.Row="2" Grid.Column="2" Content="{loc:Translate '相对定位'}"
  244. Style="{DynamicResource ButtonDefault}" Padding="16,6" Margin="0"
  245. Click="BtnMoveRel_Click"/>
  246. </Grid>
  247. <WrapPanel Margin="0,10,0,0">
  248. <Button Content="{loc:Translate '回零'}" Style="{DynamicResource ButtonDefault}"
  249. Padding="16,6" Margin="0,0,8,0" Click="BtnHome_Click"/>
  250. <Button Content="{loc:Translate '位置清零'}" Style="{DynamicResource ButtonDefault}"
  251. Padding="16,6" Click="BtnSetZero_Click"/>
  252. </WrapPanel>
  253. </StackPanel>
  254. </Border>
  255. </StackPanel>
  256. </StackPanel>
  257. </Grid>
  258. </ScrollViewer>
  259. </TabItem>
  260. <TabItem Header="{loc:Translate 'IO'}">
  261. <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Padding="4,8,4,4">
  262. <StackPanel x:Name="IoRoot" IsEnabled="False">
  263. <TextBlock x:Name="TxtIoHint"
  264. Text="{loc:Translate '本地端子与 EtherCAT 扩展点号相互独立。仿真卡可点击 DI 模拟输入;真实卡 DI 只读,DO 点击翻转。急停/停止点会标红或橙色。'}"
  265. TextWrapping="Wrap" FontSize="12" Margin="0,0,0,12"
  266. Foreground="{DynamicResource SecondaryTextBrush}"/>
  267. <Border Style="{StaticResource SectionCard}">
  268. <StackPanel>
  269. <TextBlock Text="{loc:Translate '本地 DI'}" Style="{StaticResource SectionTitle}"/>
  270. <WrapPanel x:Name="PanelLocalDi"/>
  271. </StackPanel>
  272. </Border>
  273. <Border Style="{StaticResource SectionCard}">
  274. <StackPanel>
  275. <TextBlock Text="{loc:Translate '本地 DO'}" Style="{StaticResource SectionTitle}"/>
  276. <WrapPanel x:Name="PanelLocalDo"/>
  277. </StackPanel>
  278. </Border>
  279. <Border Style="{StaticResource SectionCard}">
  280. <StackPanel>
  281. <TextBlock Text="{loc:Translate 'EtherCAT DI'}" Style="{StaticResource SectionTitle}"/>
  282. <WrapPanel x:Name="PanelEcatDi"/>
  283. </StackPanel>
  284. </Border>
  285. <Border Style="{StaticResource SectionCard}">
  286. <StackPanel>
  287. <TextBlock Text="{loc:Translate 'EtherCAT DO'}" Style="{StaticResource SectionTitle}"/>
  288. <WrapPanel x:Name="PanelEcatDo"/>
  289. </StackPanel>
  290. </Border>
  291. </StackPanel>
  292. </ScrollViewer>
  293. </TabItem>
  294. </TabControl>
  295. </DockPanel>
  296. </UserControl>