Compare commits
6 Commits
c34aa59ed1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| add2bb0590 | |||
| 721d397671 | |||
| fd4caf028b | |||
| f33ba0127f | |||
| 5e28088303 | |||
| 44daa44b6d |
67
Database.cs
67
Database.cs
@@ -22,6 +22,7 @@ namespace FAtoPA
|
|||||||
CreateFSMTable();
|
CreateFSMTable();
|
||||||
CreateModbusTable();
|
CreateModbusTable();
|
||||||
CreateVXTable();
|
CreateVXTable();
|
||||||
|
CreateConditionTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CreateFSMTable()
|
private bool CreateFSMTable()
|
||||||
@@ -169,7 +170,7 @@ namespace FAtoPA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CreateModbusTable()
|
private bool CreateModbusTable()
|
||||||
{
|
{
|
||||||
//Debug.WriteLine("About to execute CreateModbusTable");
|
//Debug.WriteLine("About to execute CreateModbusTable");
|
||||||
using (var connection = new SQLiteConnection(connectionString))
|
using (var connection = new SQLiteConnection(connectionString))
|
||||||
@@ -312,6 +313,27 @@ namespace FAtoPA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CreateConditionTable()
|
||||||
|
{
|
||||||
|
using (var connection = new SQLiteConnection(connectionString))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
var conFMSCmd = connection.CreateCommand();
|
||||||
|
conFMSCmd.CommandText = "CREATE TABLE IF NOT EXISTS ConditionTable (No INTEGER AUTO INCREMENT, Condition TEXT, PASStatus TEXT)";
|
||||||
|
conFMSCmd.ExecuteNonQuery();
|
||||||
|
Debug.WriteLine("CreateConditionTable success");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Error CreateConditionTable, Exception : " + ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool CreateVXTable()
|
private bool CreateVXTable()
|
||||||
{
|
{
|
||||||
//Debug.WriteLine("About to execute CreateVXTable");
|
//Debug.WriteLine("About to execute CreateVXTable");
|
||||||
@@ -644,6 +666,49 @@ namespace FAtoPA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FSMConditionVX : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
private string _condition;
|
||||||
|
public string Condition
|
||||||
|
{
|
||||||
|
get => _condition;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_condition != value)
|
||||||
|
{
|
||||||
|
_condition = value;
|
||||||
|
OnPropertyChanged(nameof(Condition));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private short _status;
|
||||||
|
public short Status
|
||||||
|
{
|
||||||
|
get { return _status; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_status != value)
|
||||||
|
{
|
||||||
|
_status = value;
|
||||||
|
OnPropertyChanged(nameof(Status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FSMConditionVX(string condition,short status)
|
||||||
|
{
|
||||||
|
this._condition = condition;
|
||||||
|
this._status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
protected void OnPropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class VXData : INotifyPropertyChanged
|
class VXData : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private String _siid;
|
private String _siid;
|
||||||
|
|||||||
@@ -17,6 +17,21 @@
|
|||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<NuGetPackageImportStamp>
|
<NuGetPackageImportStamp>
|
||||||
</NuGetPackageImportStamp>
|
</NuGetPackageImportStamp>
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -170,7 +185,11 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="FSMModbusData.cs" />
|
||||||
<Compile Include="VX3K.cs" />
|
<Compile Include="VX3K.cs" />
|
||||||
|
<Compile Include="InputBox.xaml.cs">
|
||||||
|
<DependentUpon>InputBox.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@@ -188,6 +207,10 @@
|
|||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Page Include="InputBox.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="MappingData.cs" />
|
<Compile Include="MappingData.cs" />
|
||||||
@@ -219,6 +242,18 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
23
FSM.cs
23
FSM.cs
@@ -12,6 +12,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FAtoPA
|
namespace FAtoPA
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to handle Fire Alarm System Monitoring
|
||||||
|
/// </summary>
|
||||||
class FSM
|
class FSM
|
||||||
{
|
{
|
||||||
public static bool Started = false;
|
public static bool Started = false;
|
||||||
@@ -21,6 +24,11 @@ namespace FAtoPA
|
|||||||
public Dictionary<int, String> ItemTypeDictionary { get; }
|
public Dictionary<int, String> ItemTypeDictionary { get; }
|
||||||
public Dictionary<String, NodeData> AvailableNodes { get; }
|
public Dictionary<String, NodeData> AvailableNodes { get; }
|
||||||
private EventInterface _event;
|
private EventInterface _event;
|
||||||
|
/// <summary>
|
||||||
|
/// to count the incoming event, then update at _event;
|
||||||
|
/// </summary>
|
||||||
|
public static long eventcounter = 0;
|
||||||
|
|
||||||
public FSM(EventInterface callback)
|
public FSM(EventInterface callback)
|
||||||
{
|
{
|
||||||
_event = callback;
|
_event = callback;
|
||||||
@@ -75,6 +83,7 @@ namespace FAtoPA
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
eventcounter = 0;
|
||||||
controller = FSIController.GetInstance();
|
controller = FSIController.GetInstance();
|
||||||
// internal Listeners
|
// internal Listeners
|
||||||
controller.AddListener(new ConfigListener(ItemTypeDictionary, AvailableNodes, listenerlist));
|
controller.AddListener(new ConfigListener(ItemTypeDictionary, AvailableNodes, listenerlist));
|
||||||
@@ -150,6 +159,7 @@ namespace FAtoPA
|
|||||||
public void SetItemType(ItemType devItemType)
|
public void SetItemType(ItemType devItemType)
|
||||||
{
|
{
|
||||||
//Debug.WriteLine($"Item type {devItemType.FunctionalType} ({devItemType.Description})");
|
//Debug.WriteLine($"Item type {devItemType.FunctionalType} ({devItemType.Description})");
|
||||||
|
|
||||||
if (type_dictionary != null)
|
if (type_dictionary != null)
|
||||||
{
|
{
|
||||||
int type = int.Parse(devItemType.FunctionalType.ToString());
|
int type = int.Parse(devItemType.FunctionalType.ToString());
|
||||||
@@ -160,7 +170,10 @@ namespace FAtoPA
|
|||||||
}
|
}
|
||||||
else Debug.WriteLine($"type_dictionary already have key={type}");
|
else Debug.WriteLine($"type_dictionary already have key={type}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FSM.eventcounter++;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -191,7 +204,8 @@ namespace FAtoPA
|
|||||||
}
|
}
|
||||||
else Debug.WriteLine($"node_data already have SIID={SIID}");
|
else Debug.WriteLine($"node_data already have SIID={SIID}");
|
||||||
}
|
}
|
||||||
|
FSM.eventcounter++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -207,7 +221,8 @@ namespace FAtoPA
|
|||||||
if (node_data.ContainsKey(SIID)) node_data.Remove(SIID);
|
if (node_data.ContainsKey(SIID)) node_data.Remove(SIID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
FSM.eventcounter++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +275,8 @@ namespace FAtoPA
|
|||||||
} else Debug.WriteLine($"node_data doesn't contain SIID {SIID}");
|
} else Debug.WriteLine($"node_data doesn't contain SIID {SIID}");
|
||||||
|
|
||||||
} else Debug.WriteLine("node_data is null");
|
} else Debug.WriteLine("node_data is null");
|
||||||
|
|
||||||
|
FSM.eventcounter++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,6 +287,7 @@ namespace FAtoPA
|
|||||||
public void SetMPNetTime(DateTime mpNetTime)
|
public void SetMPNetTime(DateTime mpNetTime)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"Time is {mpNetTime}");
|
Debug.WriteLine($"Time is {mpNetTime}");
|
||||||
|
FSM.eventcounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
52
FSMModbusData.cs
Normal file
52
FSMModbusData.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FAtoPA.Net
|
||||||
|
{
|
||||||
|
internal class FSMModbusData : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
private string _logicalstate;
|
||||||
|
public String LogicalState
|
||||||
|
{
|
||||||
|
get { return _logicalstate; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_logicalstate != value)
|
||||||
|
{
|
||||||
|
|
||||||
|
_logicalstate = value;
|
||||||
|
OnPropertyChanged(nameof(LogicalState));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private short _register;
|
||||||
|
public short Register
|
||||||
|
{
|
||||||
|
get { return _register; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_register != value)
|
||||||
|
{
|
||||||
|
_register = value;
|
||||||
|
OnPropertyChanged(nameof(Register));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FSMModbusData(String logicalstate, short register)
|
||||||
|
{
|
||||||
|
LogicalState = logicalstate;
|
||||||
|
Register = register;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnPropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
43
InputBox.xaml
Normal file
43
InputBox.xaml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<Window x:Class="FAtoPA.Net.InputBox"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:FAtoPA.Net"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="FSM To Modbus Register" Height="200" Width="250">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid Grid.Row="0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Column="0" Content="Logical State :" VerticalContentAlignment="Center"/>
|
||||||
|
<Border Grid.Column="1" BorderBrush="Black" BorderThickness="0" Margin="5">
|
||||||
|
<Label x:Name="txtLogicalState" />
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Column="0" Content="Modbus Register :" VerticalContentAlignment="Center"/>
|
||||||
|
<ComboBox Grid.Column="1" x:Name="cbModbusRegister" Margin="5" />
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button Grid.Column="0" Content="Cancel" Margin="5" Click="Cancel_Click"/>
|
||||||
|
<Button Grid.Column="1" Content="OK" Margin="5" Click="OK_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
77
InputBox.xaml.cs
Normal file
77
InputBox.xaml.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
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.Shapes;
|
||||||
|
|
||||||
|
namespace FAtoPA.Net
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for Window1.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class InputBox : Window
|
||||||
|
{
|
||||||
|
private String _key;
|
||||||
|
public String FsmState { get => _key; }
|
||||||
|
private short _value;
|
||||||
|
public short ModbusRegister { get => _value; }
|
||||||
|
private List<short> ModbusRegisters;
|
||||||
|
|
||||||
|
|
||||||
|
public InputBox(string key, short value)
|
||||||
|
{
|
||||||
|
_key = key;
|
||||||
|
_value = value;
|
||||||
|
ModbusRegisters = new List<short>();
|
||||||
|
for (short i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
ModbusRegisters.Add(i);
|
||||||
|
}
|
||||||
|
InitializeComponent();
|
||||||
|
cbModbusRegister.ItemsSource = ModbusRegisters;
|
||||||
|
|
||||||
|
txtLogicalState.Content = key;
|
||||||
|
cbModbusRegister.SelectedIndex = ModbusRegisters.IndexOf(value);
|
||||||
|
|
||||||
|
|
||||||
|
DataContext = this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.DialogResult = false;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OK_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (cbModbusRegister.SelectedIndex != -1)
|
||||||
|
{
|
||||||
|
var selected = cbModbusRegister.SelectedItem;
|
||||||
|
if (selected != null)
|
||||||
|
{
|
||||||
|
short vv = (short)selected;
|
||||||
|
if (vv!= _value)
|
||||||
|
{
|
||||||
|
_value = vv;
|
||||||
|
this.DialogResult = true;
|
||||||
|
} else { this.DialogResult = false; }
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
MessageBox.Show("Please select a Modbus Register");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
412
MainWindow.xaml
412
MainWindow.xaml
@@ -9,9 +9,91 @@
|
|||||||
Closing="Window_Closing"
|
Closing="Window_Closing"
|
||||||
Title="MainWindow"
|
Title="MainWindow"
|
||||||
MinWidth="800"
|
MinWidth="800"
|
||||||
|
MaxWidth="1024"
|
||||||
MinHeight="480"
|
MinHeight="480"
|
||||||
WindowState="Maximized" >
|
MaxHeight="600"
|
||||||
<Grid>
|
WindowState="Maximized"
|
||||||
|
IsManipulationEnabled="True">
|
||||||
|
|
||||||
|
<Window.Resources>
|
||||||
|
|
||||||
|
<!-- Style for Rounded Buttons -->
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border
|
||||||
|
x:Name="Border"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="1"
|
||||||
|
CornerRadius="15"
|
||||||
|
|
||||||
|
Padding="5"
|
||||||
|
Margin="5">
|
||||||
|
<ContentPresenter
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<!-- Trigger for MouseOver -->
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="LightGray" />
|
||||||
|
</Trigger>
|
||||||
|
<!-- Trigger for Pressed -->
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="Gray" />
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush" Value="DarkGray" />
|
||||||
|
</Trigger>
|
||||||
|
<!-- Trigger for Disabled -->
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter TargetName="Border" Property="Opacity" Value="0.5" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Style for TabItem with Rounded Top Corners -->
|
||||||
|
<Style TargetType="TabItem">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="TabItem">
|
||||||
|
<Border
|
||||||
|
x:Name="Border"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="1 1 1 0"
|
||||||
|
CornerRadius="10,10,0,0"
|
||||||
|
Padding="12"
|
||||||
|
Margin="2 2 0 0">
|
||||||
|
<ContentPresenter
|
||||||
|
x:Name="HeaderContent"
|
||||||
|
ContentSource="Header"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<!-- Trigger for Selected -->
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="LightBlue" />
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush" Value="DarkBlue" />
|
||||||
|
</Trigger>
|
||||||
|
<!-- Trigger for MouseOver -->
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="LightGray" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="AreAnyTouchesCaptured" Value="True">
|
||||||
|
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid IsManipulationEnabled="True">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<StatusBar DockPanel.Dock="Bottom" Height="30">
|
<StatusBar DockPanel.Dock="Bottom" Height="30">
|
||||||
<StatusBar.ItemsPanel>
|
<StatusBar.ItemsPanel>
|
||||||
@@ -27,30 +109,29 @@
|
|||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</StatusBar.ItemsPanel>
|
</StatusBar.ItemsPanel>
|
||||||
<StatusBarItem Grid.Column="0" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
<StatusBarItem Grid.Column="0" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
||||||
<TextBlock x:Name="firealarmstatusbar" Text="Fire Alarm Status" />
|
<TextBlock x:Name="firealarmstatusbar" Text="Fire Alarm Status" Margin="5 0"/>
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
|
|
||||||
<StatusBarItem Grid.Column="1" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
<StatusBarItem Grid.Column="1" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
||||||
<TextBlock x:Name="modbusstatusbar" Text="Modbus Status" />
|
<TextBlock x:Name="modbusstatusbar" Text="Modbus Status" Margin="5 0"/>
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
<StatusBarItem Grid.Column="2" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
<StatusBarItem Grid.Column="2" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
||||||
<TextBlock x:Name="vxstatusbar" Text="VX-3000 Status" />
|
<TextBlock x:Name="vxstatusbar" Text="VX-3000 Status" Margin="5 0"/>
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
<StatusBarItem Grid.Column="3" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
<StatusBarItem Grid.Column="3" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1">
|
||||||
<TextBlock x:Name="datetimebar" Text="Date and Time" />
|
<TextBlock x:Name="datetimebar" Text="Date and Time" Margin="5 0"/>
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
</StatusBar>
|
</StatusBar>
|
||||||
<TabControl>
|
<TabControl x:Name="mainTab" SelectionChanged="mainTab_SelectionChanged" IsManipulationEnabled="True">
|
||||||
<TabItem Header="Fire Alarm">
|
<TabItem Header="Fire Alarm" TouchDown="TabItem_TouchDown">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<Grid DockPanel.Dock="Top" Height="75">
|
<Grid DockPanel.Dock="Top" Height="70">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="150"/>
|
<ColumnDefinition Width="300"/>
|
||||||
<ColumnDefinition Width="500"/>
|
<ColumnDefinition Width="430"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Margin="5,5,5,5" x:Name="btnStartStopFSM" Content="Start FSM Connection" Grid.Column="0" Click="btnStartStopFSM_Click" />
|
<Button Margin="5" Padding="5,0" x:Name="btnStartStopFSM" Content="Start FSM Connection" Grid.Column="0" Click="btnStartStopFSM_Click" TouchEnter="btnStartStopFSM_TouchEnter" />
|
||||||
<Grid Grid.Column="1">
|
<Grid Grid.Column="1" Margin="0,5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@@ -99,86 +180,119 @@
|
|||||||
<ComboBox x:Name="siSub" Text="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Grid.Row="1" Margin="5,0,5,5" ItemsSource="{Binding SISubList, IsAsync=True}" SelectedIndex="0"/>
|
<ComboBox x:Name="siSub" Text="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Grid.Row="1" Margin="5,0,5,5" ItemsSource="{Binding SISubList, IsAsync=True}" SelectedIndex="0"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Column="2">
|
<Grid Grid.Column="2" Margin="0,5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Visibility="Hidden" Grid.Column="0" Margin="5" x:Name="btnAddSIID" Content="Manual Add To Table" Click="btnAddSIID_Click"/>
|
<Button Grid.Column="0" Margin="5,0" Padding="5,0" x:Name="btnDelSIID" Content="Remove From Table" Click="btnDelSIID_Click"/>
|
||||||
<Button Grid.Column="1" Margin="5" x:Name="btnDelSIID" Content="Remove From Table" Click="btnDelSIID_Click"/>
|
<Button Grid.Column="1" Margin="5,0" Padding="5,0" x:Name="btnClearSIID" Content="Clear Table" Click="btnClearSIID_Click"/>
|
||||||
<Button Grid.Column="2" Margin="5" x:Name="btnClearSIID" Content="Clear Table" Click="btnClearSIID_Click"/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<DockPanel DockPanel.Dock="Left" Width="400">
|
<DockPanel DockPanel.Dock="Left" Width="300">
|
||||||
<Label Content="Detected SIID" DockPanel.Dock="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
<Label Content="Detected SIID" Margin="5,0" DockPanel.Dock="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontWeight="Bold" HorizontalAlignment="Left"/>
|
||||||
<Grid DockPanel.Dock="Bottom" Height="50">
|
<Grid DockPanel.Dock="Bottom" Height="50" Margin="5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Label Content="Count : 0" Margin="5,0" Grid.Column="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" x:Name="DetectedSIIDCount"/>
|
<Label Content="Count : 0" Margin="5,0" Grid.Column="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" x:Name="DetectedSIIDCount"/>
|
||||||
<Button Content="Add Selected to Table" Margin="5,0" Grid.Column="1" HorizontalAlignment="Stretch" Click="AddSelectedSIID" />
|
<Button Content="Add Selected to Table" Margin="5,0" Padding="5,0" Grid.Column="1" HorizontalAlignment="Stretch" Click="AddSelectedSIID" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<ListBox x:Name="DetectedSIID" Margin="5"/>
|
||||||
<ListBox x:Name="DetectedSIID" />
|
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<DataGrid MinRowHeight="50" x:Name="FSMTable" AutoGenerateColumns="True" AutoGeneratingColumn="FSMTable_AutoGeneratingColumn" />
|
<DockPanel >
|
||||||
|
<Label Content="FSM Status" DockPanel.Dock="Top" FontWeight="Bold" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left"/>
|
||||||
|
<DataGrid Margin="5" MinRowHeight="50" x:Name="FSMTable" AutoGenerateColumns="True" AutoGeneratingColumn="FSMTable_AutoGeneratingColumn" ColumnWidth="*" />
|
||||||
|
|
||||||
|
</DockPanel>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Modbus">
|
<TabItem Header="Modbus" TouchDown="TabItem_TouchDown">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<Grid DockPanel.Dock="Top" Height="75">
|
<Grid DockPanel.Dock="Top" Height="70">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="150"/>
|
<ColumnDefinition Width="300"/>
|
||||||
<ColumnDefinition Width="500"/>
|
<ColumnDefinition Width="280"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Margin="5" x:Name="btnStartStopModbus" Content="Start Modbus Connection" Grid.Column="0" Click="btnStartStopModbus_Click"/>
|
<Button Margin="5" Padding="5,0" x:Name="btnStartStopModbus" Content="Start Modbus Connection" Grid.Column="0" Click="btnStartStopModbus_Click"/>
|
||||||
<Grid Grid.Column="1">
|
<Grid Grid.Column="1" Margin="0,5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="75"/>
|
<ColumnDefinition Width="60"/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="6*"/>
|
<ColumnDefinition Width="60"/>
|
||||||
<ColumnDefinition Width="75"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="7*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Label Grid.Column="0" Content="SIID" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
<Label Grid.Column="0" Content="SIID" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
||||||
<ComboBox Grid.Column="1" x:Name="ModbusSIIDComboBox" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5,0,5,0" ItemsSource="{Binding FSMSIID, IsAsync=True}" Grid.ColumnSpan="2" SelectedIndex="0"/>
|
<ComboBox Grid.Column="1" x:Name="ModbusSIIDComboBox" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5" ItemsSource="{Binding FSMSIID, IsAsync=True}" SelectedIndex="0"/>
|
||||||
<Label Grid.Column="3" Content="Register" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
<Label Grid.Column="2" Content="Register" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
||||||
<ComboBox Grid.Column="4" x:Name="ModbusRegister" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5,0,5,0" ItemsSource="{Binding ModbusRegisters, IsAsync=True}" SelectedIndex="0" />
|
<ComboBox Grid.Column="3" x:Name="ModbusRegister" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5" ItemsSource="{Binding ModbusRegisters, IsAsync=True}" SelectedIndex="0" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Column="2">
|
<Grid Grid.Column="2">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="3*"/>
|
||||||
|
<RowDefinition Height="4*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Grid.Column="0" Margin="5" x:Name="btnAddModbus" Content="Add To Table" Click="btnAddModbus_Click"/>
|
<Button Grid.Column="0" Margin="5,5,5,5" Padding="5,0" x:Name="btnAddModbus" Content="Add To Table" Click="btnAddModbus_Click" Grid.RowSpan="2"/>
|
||||||
<Button Grid.Column="1" Margin="5" x:Name="btnDelModbus" Content="Remove From Table" Click="btnDelModbus_Click"/>
|
<Button Grid.Column="1" Margin="5,5,5,5" Padding="5,0" x:Name="btnDelModbus" Content="Remove From Table" Click="btnDelModbus_Click" Grid.RowSpan="2"/>
|
||||||
<Button Grid.Column="2" Margin="5" x:Name="btnClearModbus" Content="Clear Table" Click="btnClearModbus_Click"/>
|
<Button Grid.Column="2" Margin="5,5,5,5" Padding="5,0" x:Name="btnClearModbus" Content="Clear Table" Click="btnClearModbus_Click" Grid.RowSpan="2"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<DockPanel DockPanel.Dock="Left" Width="400">
|
<DockPanel DockPanel.Dock="Left" Width="300">
|
||||||
<Label Content="Connected Modbus Client" DockPanel.Dock="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
<Grid>
|
||||||
<Label Content="Count : 0" DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" x:Name="ConnectedModbusCount"/>
|
<Grid.RowDefinitions>
|
||||||
<ListBox x:Name="ConnectedModbusClients" />
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="2*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<DockPanel Grid.Row="0">
|
||||||
|
<Grid DockPanel.Dock="Top">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="AUTO"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Margin="5,0,5,0" Content="Connected Modbus Client" Grid.Column="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontWeight="Bold" Height="26" VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
||||||
|
<Label Margin="5,0" Content="Count : 0" Grid.Column="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" x:Name="ConnectedModbusCount"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<ListBox x:Name="ConnectedModbusClients" Margin="5,0" />
|
||||||
|
</DockPanel>
|
||||||
|
<DockPanel Grid.Row="1">
|
||||||
|
<Label Content="FA Status to Register Definition" DockPanel.Dock="Top" HorizontalContentAlignment="Center" FontWeight="Bold" HorizontalAlignment="Left"/>
|
||||||
|
<Grid DockPanel.Dock="Bottom" Height="60">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button x:Name="SetFSMtoModbusTranslationTable" Grid.Column="0" Content="Set Value" Margin="5,5,5,0" Padding="5,0" Click="SetFSMtoModbusTranslationTable_Click" Height="50" VerticalAlignment="Top"/>
|
||||||
|
<Button x:Name="ResetFSMtoModbusTranslationTable" Grid.Column="1" Content="Reset Default" Margin="5" Padding="5,0" Click="ResetFSMtoModbusTranslationTable_Click" Height="50"/>
|
||||||
|
</Grid>
|
||||||
|
<DataGrid x:Name="FSMtoModbusTranslationTable" MouseDoubleClick="FSMtoModbusTranslationTable_MouseDoubleClick" AutoGenerateColumns="True" Margin="5,0" ColumnWidth="*" AutoGeneratingColumn="FSMtoModbusTranslationTable_AutoGeneratingColumn" RowHeight="30"/>
|
||||||
|
</DockPanel>
|
||||||
|
</Grid>
|
||||||
|
</DockPanel>
|
||||||
|
<DockPanel>
|
||||||
|
<Label Content="Modbus Table" HorizontalAlignment="Left" DockPanel.Dock="Top" FontWeight="Bold"/>
|
||||||
|
<DataGrid MinRowHeight="50" x:Name="ModbusTable" AutoGenerateColumns="True" AutoGeneratingColumn="ModbusTable_AutoGeneratingColumn" ColumnWidth="*"/>
|
||||||
|
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<DataGrid x:Name="ModbusTable" AutoGenerateColumns="True" AutoGeneratingColumn="ModbusTable_AutoGeneratingColumn" />
|
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="TOA VX-3000">
|
<TabItem Header="TOA VX-3000" TouchDown="TabItem_TouchDown">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<Grid DockPanel.Dock="Top" Height="75">
|
<Grid DockPanel.Dock="Top" Height="70">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="150"/>
|
<ColumnDefinition Width="300"/>
|
||||||
<ColumnDefinition Width="500"/>
|
<ColumnDefinition Width="290"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Margin="5,5,5,5" x:Name="btnStartStopVX" Content="Start VX-3000 Connection" Grid.Column="0" Click="btnStartStopVX_Click" />
|
<Button Margin="5,5,5,5" x:Name="btnStartStopVX" Padding="5,0" Content="Start VX-3000 Connection" Grid.Column="0" Click="btnStartStopVX_Click" />
|
||||||
<Grid Grid.Column="1">
|
<Grid Grid.Column="1" Margin="0,5,0,5" >
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="50"/>
|
<ColumnDefinition Width="50"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@@ -188,11 +302,11 @@
|
|||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Label Grid.Column="0" Content="SIID" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
<Label Grid.Column="0" Content="SIID" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
||||||
<ComboBox Grid.Column="1" x:Name="VXSIIDComboBox" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5,0" ItemsSource="{Binding FSMSIID, IsAsync=True}" SelectedIndex="0"/>
|
<ComboBox Grid.Column="1" x:Name="VXSIIDComboBox" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5" ItemsSource="{Binding FSMSIID, IsAsync=True}" SelectedIndex="0"/>
|
||||||
<Label Grid.Column="2" Content="Frame" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
<Label Grid.Column="2" Content="Frame" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
||||||
<ComboBox Grid.Column="3" x:Name="VXFrame" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5,0" ItemsSource="{Binding VX3KID, IsAsync=True}" SelectedIndex="0"/>
|
<ComboBox Grid.Column="3" x:Name="VXFrame" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5" ItemsSource="{Binding VX3KID, IsAsync=True}" SelectedIndex="0"/>
|
||||||
<Label Grid.Column="4" Content="C-IN" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
<Label Grid.Column="4" Content="C-IN" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
||||||
<ComboBox Grid.Column="5" x:Name="VXCIN" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5,0" ItemsSource="{Binding VX3KCIN, IsAsync=True}" SelectedIndex="0" />
|
<ComboBox Grid.Column="5" x:Name="VXCIN" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="5" ItemsSource="{Binding VX3KCIN, IsAsync=True}" SelectedIndex="0" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Column="2">
|
<Grid Grid.Column="2">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -200,91 +314,121 @@
|
|||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Grid.Column="0" Margin="5" x:Name="btnAddVX" Content="Add To Table" Click="btnAddVX_Click"/>
|
<Button Grid.Column="0" Margin="5" x:Name="btnAddVX" Padding="5,0" Content="Add To Table" Click="btnAddVX_Click"/>
|
||||||
<Button Grid.Column="1" Margin="5" x:Name="btnDelVX" Content="Remove From Table" Click="btnDelVX_Click"/>
|
<Button Grid.Column="1" Margin="5" x:Name="btnDelVX" Padding="5,0" Content="Remove From Table" Click="btnDelVX_Click"/>
|
||||||
<Button Grid.Column="2" Margin="5" x:Name="btnClearVX" Content="Clear Table" Click="btnClearVX_Click"/>
|
<Button Grid.Column="2" Margin="5" x:Name="btnClearVX" Padding="5,0" Content="Clear Table" Click="btnClearVX_Click"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<DataGrid x:Name="VXTable" AutoGenerateColumns="True" AutoGeneratingColumn="VXTable_AutoGeneratingColumn" />
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="300"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<DockPanel Grid.Column="1">
|
||||||
|
<Label Content="TOA VX-3000" FontWeight="Bold" DockPanel.Dock="Top" HorizontalAlignment="Left"/>
|
||||||
|
<DataGrid MinRowHeight="50" x:Name="VXTable" AutoGenerateColumns="True" AutoGeneratingColumn="VXTable_AutoGeneratingColumn"/>
|
||||||
|
</DockPanel>
|
||||||
|
<DockPanel Grid.Column="0">
|
||||||
|
<Label Content="FSM Condition" FontWeight="Bold" DockPanel.Dock="Top" HorizontalAlignment="Left"/>
|
||||||
|
<Grid DockPanel.Dock="Bottom" Height="50">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button x:Name="btnResetFSMCon" Content="Reset Table" Height="50" Click="btnResetFSMCon_Click" Grid.Column="0"/>
|
||||||
|
<Button x:Name="btnSetFSMCon" Content="Set Table" Height="50" Click="btnSetFSMCon_Click" Grid.Column="1"/>
|
||||||
|
</Grid>
|
||||||
|
<DataGrid x:Name="ConditionTable" AutoGenerateColumns="True" AutoGeneratingColumn="ConditionTable_AutoGeneratingColumn" DockPanel.Dock="Top" ColumnWidth="*" RowHeight="30"/>
|
||||||
|
</DockPanel>
|
||||||
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Settings">
|
<TabItem Header="Settings" TouchDown="TabItem_TouchDown">
|
||||||
<StackPanel Orientation="Vertical">
|
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" IsDeferredScrollingEnabled="True" ScrollViewer.PanningMode="Both" >
|
||||||
<GroupBox Header="Fire Alarm Settings">
|
|
||||||
<DockPanel>
|
<StackPanel Orientation="Vertical" MinWidth="800" HorizontalAlignment="Stretch">
|
||||||
<Button x:Name="btnApplyFSMConfig" Content="Apply Config" Click="ApplyFSMConfig" DockPanel.Dock="Right" Margin="5"/>
|
<GroupBox>
|
||||||
<StackPanel Orientation="Vertical">
|
<GroupBox.Header>
|
||||||
<StackPanel Orientation="Horizontal">
|
<TextBlock Text="Fire Alarm Settings" FontWeight="Bold" FontSize="20"/>
|
||||||
<Label Content="NetGroup" Width="150"/>
|
</GroupBox.Header>
|
||||||
<TextBox x:Name="FSMConfig_NetGroup" Text="1" MinWidth="30" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_NetGroup_PreviewTextInput" TextChanged="FSMConfig_NetGroup_TextChanged"/>
|
<DockPanel>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Content="NetGroup" Width="250"/>
|
||||||
|
<TextBox x:Name="FSMConfig_NetGroup" Text="1" Padding="5,0" MinWidth="30" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_NetGroup_PreviewTextInput" TextChanged="FSMConfig_NetGroup_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Content="NetNode" Width="250"/>
|
||||||
|
<TextBox x:Name="FSMConfig_NetNode" Padding="5,0" Text="1" MinWidth="30" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_NetNode_PreviewTextInput" TextChanged="FSMConfig_NetNode_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Content="PNA" Width="250"/>
|
||||||
|
<TextBox x:Name="FSMConfig_PNA" Padding="5,0" Text="1" MinWidth="30" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_PNA_PreviewTextInput" TextChanged="FSMConfig_PNA_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Content="Local IP Address" Width="250"/>
|
||||||
|
<TextBox x:Name="FSMConfig_LocalIP" Padding="5,0" Text="0.0.0.0" MinWidth="75" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_LocalIP_PreviewTextInput" TextChanged="FSMConfig_LocalIP_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Content="Use Multicast" Width="250"/>
|
||||||
|
<CheckBox x:Name="FSM_UseMulticast" Content="No" Width="500" Height="35" IsChecked="False" VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Content="Multicast Address" Width="250"/>
|
||||||
|
<TextBox x:Name="FSMConfig_MulticastAddress" Padding="5,0" Text="239.192.0.1" MinWidth="75" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_MulticastAddress_PreviewTextInput" TextChanged="FSMConfig_MulticastAddress_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Content="Multicast Port" Width="250"/>
|
||||||
|
<TextBox x:Name="FSMConfig_MulticastPort" Padding="5,0" Text="25000" MinWidth="50" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_MulticastPort_PreviewTextInput" TextChanged="FSMConfig_MulticastPort_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Button x:Name="btnApplyFSMConfig" Content="Apply Config" Click="ApplyFSMConfig" DockPanel.Dock="Bottom" Margin="250,0" Padding="5,0" Width="500" Height="50" HorizontalAlignment="Left"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
</DockPanel>
|
||||||
<Label Content="NetNode" Width="150"/>
|
</GroupBox>
|
||||||
<TextBox x:Name="FSMConfig_NetNode" Text="1" MinWidth="30" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_NetNode_PreviewTextInput" TextChanged="FSMConfig_NetNode_TextChanged"/>
|
<GroupBox>
|
||||||
|
<GroupBox.Header>
|
||||||
|
<TextBlock Text="Modbus Setting" FontWeight="Bold" FontSize="20" HorizontalAlignment="Center"/>
|
||||||
|
</GroupBox.Header>
|
||||||
|
<DockPanel>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Width="250" Content="Listen Port"/>
|
||||||
|
<TextBox x:Name="ModbusListenPort" Text="502" Padding="5,0" MinWidth="50" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="ModbusListenPort_PreviewTextInput" TextChanged="ModbusListenPort_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Width="250" Content="Device ID"/>
|
||||||
|
<TextBox x:Name="ModbusDeviceID" Padding="5,0" Text="1" MinWidth="50" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="ModbusDeviceID_PreviewTextInput" TextChanged="ModbusDeviceID_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Width="250" Content="Max. Register"/>
|
||||||
|
<TextBox x:Name="ModbusMaxRegister" Padding="5,0" Text="2000" MinWidth="50" Height="35" Width="500" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="ModbusMaxRegister_PreviewTextInput" TextChanged="ModbusMaxRegister_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Button x:Name="btnApplyModbusConfig" Content="Apply Config" Click="ApplyModbusConfig" DockPanel.Dock="Bottom" Margin="250,0" Padding="5,0" Width="500" Height="50" HorizontalAlignment="Left"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
</DockPanel>
|
||||||
<Label Content="PNA" Width="150"/>
|
</GroupBox>
|
||||||
<TextBox x:Name="FSMConfig_PNA" Text="1" MinWidth="30" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_PNA_PreviewTextInput" TextChanged="FSMConfig_PNA_TextChanged"/>
|
<GroupBox>
|
||||||
|
<GroupBox.Header>
|
||||||
|
<TextBlock Text="VX-3000" FontWeight="Bold" FontSize="20" DockPanel.Dock="Top" HorizontalAlignment="Center"/>
|
||||||
|
</GroupBox.Header>
|
||||||
|
<DockPanel Margin="-1,0,1,0">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Width="250" Content="VX-3000 IP" />
|
||||||
|
<TextBox x:Name="VX3K_IP" Padding="5,0" Text="192.168.14.1" MinWidth="75" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="VX3K_IP_PreviewTextInput" TextChanged="VX3K_IP_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5">
|
||||||
|
<Label Width="250" Content="VX-3000 Port" />
|
||||||
|
<TextBox x:Name="VX3K_Port" Padding="5,0" Text="5000" MinWidth="50" Width="500" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="VX3K_Port_PreviewTextInput" TextChanged="VX3K_Port_TextChanged" />
|
||||||
|
</StackPanel>
|
||||||
|
<Button x:Name="btnApplyVX3KConfig" Content="Apply Config" Margin="250,0" Padding="5,0" Click="ApplyVX3KConfig" DockPanel.Dock="Bottom" Width="500" Height="50" HorizontalAlignment="Left"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
</DockPanel>
|
||||||
<Label Content="Local IP Address" Width="150"/>
|
</GroupBox>
|
||||||
<TextBox x:Name="FSMConfig_LocalIP" Text="0.0.0.0" MinWidth="75" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_LocalIP_PreviewTextInput" TextChanged="FSMConfig_LocalIP_TextChanged"/>
|
</StackPanel>
|
||||||
</StackPanel>
|
</ScrollViewer>
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Content="Use Multicast" Width="150"/>
|
|
||||||
<CheckBox x:Name="FSM_UseMulticast" Content="No" IsChecked="False" VerticalAlignment="Center"/>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Content="Multicast Address" Width="150"/>
|
|
||||||
<TextBox x:Name="FSMConfig_MulticastAddress" Text="239.192.0.1" MinWidth="75" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_MulticastAddress_PreviewTextInput" TextChanged="FSMConfig_MulticastAddress_TextChanged"/>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Content="Multicast Port" Width="150"/>
|
|
||||||
<TextBox x:Name="FSMConfig_MulticastPort" Text="25000" MinWidth="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="FSMConfig_MulticastPort_PreviewTextInput" TextChanged="FSMConfig_MulticastPort_TextChanged"/>
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
</DockPanel>
|
|
||||||
|
|
||||||
</GroupBox>
|
|
||||||
<GroupBox Header="Modbus Setting">
|
|
||||||
<DockPanel>
|
|
||||||
<Button x:Name="btnApplyModbusConfig" Content="Apply Config" Click="ApplyModbusConfig" DockPanel.Dock="Right" Margin="5"/>
|
|
||||||
<StackPanel Orientation="Vertical">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Width="150" Content="Listen Port"/>
|
|
||||||
<TextBox x:Name="ModbusListenPort" Text="502" MinWidth="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="ModbusListenPort_PreviewTextInput" TextChanged="ModbusListenPort_TextChanged"/>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Width="150" Content="Device ID"/>
|
|
||||||
<TextBox x:Name="ModbusDeviceID" Text="1" MinWidth="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="ModbusDeviceID_PreviewTextInput" TextChanged="ModbusDeviceID_TextChanged"/>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Width="150" Content="Max. Register"/>
|
|
||||||
<TextBox x:Name="ModbusMaxRegister" Text="2000" MinWidth="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="ModbusMaxRegister_PreviewTextInput" TextChanged="ModbusMaxRegister_TextChanged"/>
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
</DockPanel>
|
|
||||||
</GroupBox>
|
|
||||||
<GroupBox Header="VX-3000">
|
|
||||||
<DockPanel Margin="-1,0,1,0">
|
|
||||||
<Button x:Name="btnApplyVX3KConfig" Content="Apply Config" Margin="5" Click="ApplyVX3KConfig" DockPanel.Dock="Right"/>
|
|
||||||
<StackPanel Orientation="Vertical">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Width="150" Content="VX-3000 IP" />
|
|
||||||
<TextBox x:Name="VX3K_IP" Text="192.168.14.1" MinWidth="75" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="VX3K_IP_PreviewTextInput" TextChanged="VX3K_IP_TextChanged"/>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Label Width="150" Content="VX-3000 Port" />
|
|
||||||
<TextBox x:Name="VX3K_Port" Text="5000" MinWidth="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewTextInput="VX3K_Port_PreviewTextInput" TextChanged="VX3K_Port_TextChanged" />
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
</DockPanel>
|
|
||||||
</GroupBox>
|
|
||||||
</StackPanel>
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -55,8 +57,13 @@ namespace FAtoPA.Net
|
|||||||
// Isi VX Table
|
// Isi VX Table
|
||||||
ObservableCollection<VXData> VXTableMember { get; set; }
|
ObservableCollection<VXData> VXTableMember { get; set; }
|
||||||
|
|
||||||
public List<String> ConditionON;
|
// tabel translation FSM Status String to Modbus Register Value
|
||||||
public List<String> ConditionOFF;
|
ObservableCollection<FSMModbusData> ModbusTranslationTable;
|
||||||
|
|
||||||
|
|
||||||
|
ObservableCollection<FSMConditionVX> FSMConditionTable;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FSMEvent fsmEvent;
|
FSMEvent fsmEvent;
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
@@ -65,6 +72,8 @@ namespace FAtoPA.Net
|
|||||||
// Di-isi dengan user input di Tab Fire Alarm
|
// Di-isi dengan user input di Tab Fire Alarm
|
||||||
FSMSIID = new ObservableCollection<string>();
|
FSMSIID = new ObservableCollection<string>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Isinya ada di Window_Loaded
|
// Isinya ada di Window_Loaded
|
||||||
ModbusRegisters = new ObservableCollection<int>();
|
ModbusRegisters = new ObservableCollection<int>();
|
||||||
FsmTableMember = new ObservableCollection<FSMData>();
|
FsmTableMember = new ObservableCollection<FSMData>();
|
||||||
@@ -105,17 +114,204 @@ namespace FAtoPA.Net
|
|||||||
|
|
||||||
siType.ItemsSource = Enum.GetValues(typeof(SIType)).Cast<SIType>().ToList();
|
siType.ItemsSource = Enum.GetValues(typeof(SIType)).Cast<SIType>().ToList();
|
||||||
|
|
||||||
this.DataContext = this;
|
Load_ModbusTranslationTable();
|
||||||
|
Load_ConditionTable();
|
||||||
//TODO : Add Condition for ON and OFF
|
|
||||||
ConditionON = new List<string>();
|
|
||||||
ConditionON.Add(SILogicalState.ACTIVATION.ToString());
|
|
||||||
ConditionON.Add(SILogicalState.FIRE.ToString());
|
|
||||||
|
|
||||||
ConditionOFF = new List<string>();
|
DataContext = this;
|
||||||
ConditionOFF.Add(SILogicalState.NORMAL.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load Modbus Translation Table from JSON File
|
||||||
|
/// </summary>
|
||||||
|
private void Load_ModbusTranslationTable()
|
||||||
|
{
|
||||||
|
if (File.Exists("ModbusTranslationTable.json"))
|
||||||
|
{
|
||||||
|
String loadedJson = File.ReadAllText("ModbusTranslationTable.json");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ModbusTranslationTable = JsonSerializer.Deserialize<ObservableCollection<FSMModbusData>>(loadedJson);
|
||||||
|
Debug.WriteLine("ModbusTranslationTable loaded");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Error loading ModbusTranslationTable : " + ex.Message);
|
||||||
|
Create_Default_ModbusTranslationTable();
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Debug.WriteLine("ModbusTranslationTable.json not found, creating default");
|
||||||
|
Create_Default_ModbusTranslationTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create Default Modbus Translation Table
|
||||||
|
/// <para>It also save the default table to JSON File</para>
|
||||||
|
/// </summary>
|
||||||
|
private void Create_Default_ModbusTranslationTable()
|
||||||
|
{
|
||||||
|
ModbusTranslationTable = new ObservableCollection<FSMModbusData>();
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.INVALID.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.NORMAL.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.TROUBLE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.FIRE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.FIRE_PRE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.VERIFY_FIRE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.HEAT.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.SUPERVISORY.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.SMOKE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.ACTIVATION.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.ACTIVATION_FAILED.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.TAMPER.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.COVER_OPEN.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.PAPER_OUT.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.WARNING.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.TROUBLE_LIGHT.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.WATCHDOGRESTART.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.ON.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.OFF.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.POLLUTION.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.POLLUTION_LIGHT.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.MONITOR.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.WATER.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.POWERFAIL.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.MANUAL_ALARM.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.PAS_WAIT_FOR_ACK.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.PAS_INVESTIGATE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.AC_CHANGED.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.AC_COUNTDOWN_STARTED.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.AC_TAMPER.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.FIRE_INT.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.ERROR.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.UNKNOWN.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.MATCHALL.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.NET_CONFIG_MISMATCH.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.UNKNOWN_ITEM.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.MISSING_ITEM.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.INCOMPATIBLE_SOFTWARE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.INCOMPATIBLE_NET_PROTOCOL.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.INFO_ALARM.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.CHEMICAL.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.WARNING_HEAT.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.WARNING_SMOKE.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.WARNING_CHEMICAL.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.REBOOT_READY.ToString(), 0));
|
||||||
|
ModbusTranslationTable.Add(new FSMModbusData(SILogicalState.LASTLOGICAL.ToString(), 0));
|
||||||
|
Save_ModbusTranslationTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Save Modbus Translation Table to JSON File
|
||||||
|
/// </summary>
|
||||||
|
private void Save_ModbusTranslationTable()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String json = JsonSerializer.Serialize(ModbusTranslationTable);
|
||||||
|
File.WriteAllText("ModbusTranslationTable.json", json);
|
||||||
|
Debug.WriteLine("ModbusTranslationTable saved");
|
||||||
|
FSMtoModbusTranslationTable.ItemsSource = ModbusTranslationTable;
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Error saving ModbusTranslationTable : " + e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Load_ConditionTable()
|
||||||
|
{
|
||||||
|
if (File.Exists("FSMConditionTable.json"))
|
||||||
|
{
|
||||||
|
String loadedJson = File.ReadAllText("FSMConditionTable.json");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FSMConditionTable = JsonSerializer.Deserialize<ObservableCollection<FSMConditionVX>>(loadedJson);
|
||||||
|
Debug.WriteLine("FSMConditionTable loaded");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Error loading FSMConditionTable : " + ex.Message);
|
||||||
|
Create_Default_ConditionTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.WriteLine("FSMConditionTable.json not found, creating default");
|
||||||
|
Create_Default_ConditionTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Create_Default_ConditionTable()
|
||||||
|
{
|
||||||
|
FSMConditionTable = new ObservableCollection<FSMConditionVX>();
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.INVALID.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.NORMAL.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.TROUBLE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.FIRE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.FIRE_PRE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.VERIFY_FIRE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.HEAT.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.SUPERVISORY.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.SMOKE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.ACTIVATION.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.ACTIVATION_FAILED.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.TAMPER.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.COVER_OPEN.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.PAPER_OUT.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.WARNING.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.TROUBLE_LIGHT.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.WATCHDOGRESTART.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.ON.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.OFF.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.POLLUTION.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.POLLUTION_LIGHT.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.MONITOR.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.WATER.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.POWERFAIL.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.MANUAL_ALARM.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.PAS_WAIT_FOR_ACK.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.PAS_INVESTIGATE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.AC_CHANGED.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.AC_COUNTDOWN_STARTED.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.AC_TAMPER.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.FIRE_INT.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.ERROR.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.UNKNOWN.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.MATCHALL.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.NET_CONFIG_MISMATCH.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.UNKNOWN_ITEM.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.MISSING_ITEM.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.INCOMPATIBLE_SOFTWARE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.INCOMPATIBLE_NET_PROTOCOL.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.INFO_ALARM.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.CHEMICAL.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.WARNING_HEAT.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.WARNING_SMOKE.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.WARNING_CHEMICAL.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.REBOOT_READY.ToString(), 0));
|
||||||
|
FSMConditionTable.Add(new FSMConditionVX(SILogicalState.LASTLOGICAL.ToString(), 0));
|
||||||
|
Save_ConditionTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save_ConditionTable()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String json = JsonSerializer.Serialize(FSMConditionTable);
|
||||||
|
File.WriteAllText("FSMConditionTable.json", json);
|
||||||
|
Debug.WriteLine("FSMConditionTable saved");
|
||||||
|
ConditionTable.ItemsSource = FSMConditionTable;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Error saving FSMConditionTable : " + e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Window Loaded");
|
Debug.WriteLine("Window Loaded");
|
||||||
@@ -167,6 +363,8 @@ namespace FAtoPA.Net
|
|||||||
FSMTable.ItemsSource = FsmTableMember;
|
FSMTable.ItemsSource = FsmTableMember;
|
||||||
ModbusTable.ItemsSource = ModbusTableMember;
|
ModbusTable.ItemsSource = ModbusTableMember;
|
||||||
VXTable.ItemsSource = VXTableMember;
|
VXTable.ItemsSource = VXTableMember;
|
||||||
|
FSMtoModbusTranslationTable.ItemsSource = ModbusTranslationTable;
|
||||||
|
ConditionTable.ItemsSource = FSMConditionTable;
|
||||||
|
|
||||||
// Load FSM
|
// Load FSM
|
||||||
fsmEvent = new FSMEvent(this.firealarmstatusbar);
|
fsmEvent = new FSMEvent(this.firealarmstatusbar);
|
||||||
@@ -194,10 +392,20 @@ namespace FAtoPA.Net
|
|||||||
vx3k = new VX3K(new VX3KEvent(this.vxstatusbar));
|
vx3k = new VX3K(new VX3KEvent(this.vxstatusbar));
|
||||||
//vx3k.Connect(config.VX_TargetIP, config.VX_TargetPort);
|
//vx3k.Connect(config.VX_TargetIP, config.VX_TargetPort);
|
||||||
|
|
||||||
|
List<String> ConditionON = new List<string>();
|
||||||
|
List<String> ConditionOFF = new List<string>();
|
||||||
|
|
||||||
|
//add for example. delete if database condition done.
|
||||||
|
ConditionON.Add(SILogicalState.FIRE.ToString());
|
||||||
|
ConditionON.Add(SILogicalState.SMOKE.ToString());
|
||||||
|
ConditionOFF.Add(SILogicalState.NORMAL.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fsm.AddListener(new FSMTableUpdater(FsmTableMember, DetectedSIID, DetectedSIIDCount));
|
fsm.AddListener(new FSMTableUpdater(FsmTableMember, DetectedSIID, DetectedSIIDCount));
|
||||||
fsm.AddListener(new ModbusTriggerFromFSM(FsmTableMember, ModbusTableMember, modbusSlave, ConditionON, ConditionOFF));
|
fsm.AddListener(new ModbusTriggerFromFSM(FsmTableMember, ModbusTableMember, modbusSlave, ModbusTranslationTable));
|
||||||
fsm.AddListener(new VXTriggerFromFSM(FsmTableMember, VXTableMember, vx3k, ConditionON, ConditionOFF));
|
fsm.AddListener(new VXTriggerFromFSM(FsmTableMember, VXTableMember, vx3k, ConditionON, ConditionOFF));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Timer1s_Tick(object sender, EventArgs e)
|
private void Timer1s_Tick(object sender, EventArgs e)
|
||||||
@@ -788,33 +996,6 @@ namespace FAtoPA.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnAddSIID_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
SIID selected = GetSIID();
|
|
||||||
if (selected != null)
|
|
||||||
{
|
|
||||||
MessageBoxResult result = MessageBox.Show("Add SIID " + selected.ToString() + " ?", "Add SIID", MessageBoxButton.YesNo);
|
|
||||||
if (result == MessageBoxResult.Yes)
|
|
||||||
{
|
|
||||||
if (database != null)
|
|
||||||
{
|
|
||||||
//TODO Manual Add SIID, perlukah ?
|
|
||||||
|
|
||||||
//FSMData f = new FSMData(selected.ToString());
|
|
||||||
//if (database.AddFSMData(f))
|
|
||||||
//{
|
|
||||||
// FSMTable.ItemsSource = database.GetFSMDatas();
|
|
||||||
// FSMSIID.Add(selected.ToString());
|
|
||||||
//}
|
|
||||||
//else MessageBox.Show("Failed to add to database");
|
|
||||||
}
|
|
||||||
else MessageBox.Show("Database is null");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else MessageBox.Show("Invalid Selection");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnDelSIID_Click(object sender, RoutedEventArgs e)
|
private void btnDelSIID_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (FSMTable != null)
|
if (FSMTable != null)
|
||||||
@@ -846,39 +1027,6 @@ namespace FAtoPA.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SIID GetSIID()
|
|
||||||
{
|
|
||||||
int netgroup = 0;
|
|
||||||
int netnode = 0;
|
|
||||||
SIType sitype = 0;
|
|
||||||
int sinumber = 0;
|
|
||||||
int sisub = 0;
|
|
||||||
|
|
||||||
if (netGroupNumber.SelectedItem != null)
|
|
||||||
{
|
|
||||||
netgroup = (int)netGroupNumber.SelectedItem;
|
|
||||||
if (netNodeNumber.SelectedItem != null)
|
|
||||||
{
|
|
||||||
netnode = (int)netNodeNumber.SelectedItem;
|
|
||||||
if (siType.SelectedItem != null)
|
|
||||||
{
|
|
||||||
sitype = (SIType)siType.SelectedItem;
|
|
||||||
if (siNumber.SelectedItem != null)
|
|
||||||
{
|
|
||||||
sinumber = (int)siNumber.SelectedItem;
|
|
||||||
if (siSub.SelectedItem != null)
|
|
||||||
{
|
|
||||||
sisub = (int)siSub.SelectedItem;
|
|
||||||
|
|
||||||
return new SIID((byte)netgroup, (byte)netnode, sitype, (ushort)sinumber, (byte)sisub);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnAddModbus_Click(object sender, RoutedEventArgs e)
|
private void btnAddModbus_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -1039,7 +1187,6 @@ namespace FAtoPA.Net
|
|||||||
break;
|
break;
|
||||||
case "LastUpdate":
|
case "LastUpdate":
|
||||||
e.Column.Width = DataGridLength.Auto;
|
e.Column.Width = DataGridLength.Auto;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1066,6 +1213,7 @@ namespace FAtoPA.Net
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void VXTable_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
|
private void VXTable_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -1123,9 +1271,141 @@ namespace FAtoPA.Net
|
|||||||
else MessageBox.Show("Selected SIID dont have NodeData");
|
else MessageBox.Show("Selected SIID dont have NodeData");
|
||||||
} else MessageBox.Show("No SIID Selected");
|
} else MessageBox.Show("No SIID Selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void FSMtoModbusTranslationTable_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("FSMtoModbusTranslationTable_AutoGeneratingColumn : " + e.PropertyName);
|
||||||
|
switch (e.PropertyName)
|
||||||
|
{
|
||||||
|
case "LogicalState":
|
||||||
|
e.Column.Width = DataGridLength.Auto;
|
||||||
|
break;
|
||||||
|
case "Register":
|
||||||
|
e.Column.Width = DataGridLength.Auto;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FSMtoModbusTranslationTable_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
var selected = (sender as DataGrid).SelectedItem;
|
||||||
|
|
||||||
|
if (selected != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
FSMModbusData vv = (FSMModbusData)selected;
|
||||||
|
Debug.WriteLine($"Selected Key={vv.LogicalState}, Value={vv.Register}");
|
||||||
|
|
||||||
|
InputBox ib = new InputBox(vv.LogicalState, vv.Register);
|
||||||
|
bool? haschange = ib.ShowDialog();
|
||||||
|
if (haschange.Value)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"Changed Key={ib.FsmState}, Value={ib.ModbusRegister}");
|
||||||
|
for (int ii = 0; ii < ModbusTranslationTable.Count; ii++)
|
||||||
|
{
|
||||||
|
if (ModbusTranslationTable[ii].LogicalState == vv.LogicalState)
|
||||||
|
{
|
||||||
|
ModbusTranslationTable[ii].Register = ib.ModbusRegister;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
FSMtoModbusTranslationTable.InvalidateProperty(DataGrid.ItemsSourceProperty);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch(Exception exception)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("FSMtoModbusTranslationTable_MouseDoubleClick Error : " + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else Debug.WriteLine("Not selected yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetFSMtoModbusTranslationTable_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show($"Reset FSM to Modbus Translation Table ?", "Reset FSM to Modbus Translation Table", MessageBoxButton.YesNo);
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
if (ModbusTranslationTable != null) ModbusTranslationTable.Clear();
|
||||||
|
|
||||||
|
Create_Default_ModbusTranslationTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFSMtoModbusTranslationTable_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show($"Save FSM to Modbus Translation Table ?", "Save FSM to Modbus Translation Table", MessageBoxButton.YesNo);
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
Save_ModbusTranslationTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConditionTable_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("ConditionTable_AutoGeneratingColumn : " + e.PropertyName);
|
||||||
|
switch (e.PropertyName)
|
||||||
|
{
|
||||||
|
case "condition":
|
||||||
|
e.Column.Width = DataGridLength.Auto;
|
||||||
|
break;
|
||||||
|
case "status":
|
||||||
|
e.Column.Width = DataGridLength.Auto;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnResetFSMCon_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show($"Reset FSM Condition Table ?", "Reset FSM Condition Table", MessageBoxButton.YesNo);
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
if (FSMConditionTable != null) FSMConditionTable.Clear();
|
||||||
|
Create_Default_ConditionTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSetFSMCon_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show($"Save FSM Condition Table ?", "Save FSM Condition Table", MessageBoxButton.YesNo);
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
Save_ConditionTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnStartStopFSM_TouchEnter(object sender, TouchEventArgs e)
|
||||||
|
{
|
||||||
|
btnStartStopFSM_Click(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void TabItem_TouchDown(object sender, TouchEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is TabItem touchedTabItem)
|
||||||
|
{
|
||||||
|
// Set the touched TabItem as the selected one
|
||||||
|
mainTab.SelectedItem = touchedTabItem;
|
||||||
|
e.Handled = true; // Mark the event as handled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mainTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// event handler for VX3K
|
/// <summary>e
|
||||||
|
/// Event Handler for VX3K
|
||||||
|
/// </summary>
|
||||||
class VX3KEvent : EventInterface
|
class VX3KEvent : EventInterface
|
||||||
{
|
{
|
||||||
private TextBlock statusbar;
|
private TextBlock statusbar;
|
||||||
@@ -1150,6 +1430,9 @@ namespace FAtoPA.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event Handler for Modbus
|
||||||
|
/// </summary>
|
||||||
class ModbusEvent : ModbusSlaveEvent
|
class ModbusEvent : ModbusSlaveEvent
|
||||||
{
|
{
|
||||||
private TextBlock statusbar;
|
private TextBlock statusbar;
|
||||||
@@ -1173,12 +1456,8 @@ namespace FAtoPA.Net
|
|||||||
connectedlist.Items.Clear();
|
connectedlist.Items.Clear();
|
||||||
foreach (ModbusClientRecord client in ModbusSlave)
|
foreach (ModbusClientRecord client in ModbusSlave)
|
||||||
{
|
{
|
||||||
TextBlock l = new TextBlock();
|
TextBlock l = new TextBlock() { Margin=new Thickness(5,0,5,0), TextWrapping=TextWrapping.Wrap, Width=connectedlist.Width, Tag = client, Height=50 };
|
||||||
l.Width = connectedlist.Width;
|
|
||||||
l.Margin = new Thickness(5, 0, 5, 0);
|
|
||||||
l.TextWrapping = TextWrapping.Wrap;
|
|
||||||
UpdateLabel(l, client);
|
UpdateLabel(l, client);
|
||||||
l.Tag = client;
|
|
||||||
connectedlist.Items.Add(l);
|
connectedlist.Items.Add(l);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1233,6 +1512,9 @@ namespace FAtoPA.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event Handler for Bosch FSM
|
||||||
|
/// </summary>
|
||||||
class FSMEvent : EventInterface
|
class FSMEvent : EventInterface
|
||||||
{
|
{
|
||||||
private TextBlock statusbar;
|
private TextBlock statusbar;
|
||||||
@@ -1275,7 +1557,9 @@ namespace FAtoPA.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class ini untuk update Table FSM
|
/// <summary>
|
||||||
|
/// Class ini untuk update Table FSM
|
||||||
|
/// </summary>
|
||||||
class FSMTableUpdater : FSMResultInterface
|
class FSMTableUpdater : FSMResultInterface
|
||||||
{
|
{
|
||||||
// dari database
|
// dari database
|
||||||
@@ -1289,6 +1573,11 @@ namespace FAtoPA.Net
|
|||||||
this.countlabel = countlabel;
|
this.countlabel = countlabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method ini untuk menambahkan SIID yang muncul dari FSM ke Listbox
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SIID">SIID yang muncul</param>
|
||||||
|
/// <param name="type">Tipe nya</param>
|
||||||
public void DiscoveredSIID(string SIID, NodeData type)
|
public void DiscoveredSIID(string SIID, NodeData type)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"Discovered SIID={SIID} Label={type.Label} Type={type.Description}");
|
Debug.WriteLine($"Discovered SIID={SIID} Label={type.Label} Type={type.Description}");
|
||||||
@@ -1299,7 +1588,7 @@ namespace FAtoPA.Net
|
|||||||
// yang punya Label dan Description saja yang masuk ke Listbox dan dihitung
|
// yang punya Label dan Description saja yang masuk ke Listbox dan dihitung
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
listbox.Items.Add(new Label() { Content = $"{SIID} : {type.Label} : {type.Description}", Tag = type });
|
listbox.Items.Add(new Label() { Content = $"{SIID} : {type.Label} : {type.Description}", Tag = type, Height=50 });
|
||||||
countlabel.Content = "Count : " + listbox.Items.Count;
|
countlabel.Content = "Count : " + listbox.Items.Count;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1308,7 +1597,12 @@ namespace FAtoPA.Net
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method ini untuk mengupdate State SIID yang ada di FSM
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SIID">SIID yang muncul</param>
|
||||||
|
/// <param name="previous">Previous State kalau ada</param>
|
||||||
|
/// <param name="current">State sekarang</param>
|
||||||
public void NewState(string SIID, NodeState previous, NodeState current)
|
public void NewState(string SIID, NodeState previous, NodeState current)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("New State : " + SIID + " Previous : " + previous?.LogicalState + " Current : " + current.LogicalState);
|
Debug.WriteLine("New State : " + SIID + " Previous : " + previous?.LogicalState + " Current : " + current.LogicalState);
|
||||||
@@ -1334,29 +1628,36 @@ namespace FAtoPA.Net
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class ini untuk Update Modbus Register dari FSM Update
|
/// <summary>
|
||||||
|
/// Class ini untuk Update Modbus Register dari FSM Update
|
||||||
|
/// </summary>
|
||||||
class ModbusTriggerFromFSM : FSMResultInterface
|
class ModbusTriggerFromFSM : FSMResultInterface
|
||||||
{
|
{
|
||||||
// dari database
|
// dari database
|
||||||
ObservableCollection<FSMData> source;
|
ObservableCollection<FSMData> source;
|
||||||
ObservableCollection<ModbusData> data;
|
ObservableCollection<ModbusData> data;
|
||||||
ModbusSlave slave;
|
ModbusSlave slave;
|
||||||
List<String> ConditionON;
|
ObservableCollection<FSMModbusData> translation;
|
||||||
List<String> ConditionOFF;
|
public ModbusTriggerFromFSM(ObservableCollection<FSMData> source, ObservableCollection<ModbusData> data, ModbusSlave slave, ObservableCollection<FSMModbusData> translation)
|
||||||
public ModbusTriggerFromFSM(ObservableCollection<FSMData> source, ObservableCollection<ModbusData> data, ModbusSlave slave, List<string> conditionON, List<string> conditionOFF)
|
|
||||||
{
|
{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.slave = slave;
|
this.slave = slave;
|
||||||
ConditionON = conditionON;
|
this.translation = translation;
|
||||||
ConditionOFF = conditionOFF;
|
|
||||||
}
|
|
||||||
public void DiscoveredSIID(string SIID, NodeData type)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tidak dipakai
|
||||||
|
/// </summary>
|
||||||
|
void FSMResultInterface.DiscoveredSIID(string SIID, NodeData type) { }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ada State baru dari FSM, Action to Modbus
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SIID">SIID yang muncul</param>
|
||||||
|
/// <param name="previous">Previous State kalau ada</param>
|
||||||
|
/// <param name="current">State sekarang</param>
|
||||||
public void NewState(string SIID, NodeState previous, NodeState current)
|
public void NewState(string SIID, NodeState previous, NodeState current)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1387,29 +1688,27 @@ namespace FAtoPA.Net
|
|||||||
{
|
{
|
||||||
if (slave != null)
|
if (slave != null)
|
||||||
{
|
{
|
||||||
if (ConditionON != null && ConditionOFF != null)
|
if (translation != null)
|
||||||
{
|
{
|
||||||
if (ConditionON.Contains(current.LogicalState))
|
foreach (var x in translation)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"NewState for SIID={SIID} State={current.LogicalState} is ConditionON");
|
if (x.LogicalState.Equals(current.LogicalState))
|
||||||
slave.SetRegister(dt.Register, 1);
|
{
|
||||||
dt.Value = "ON";
|
ushort reg = (ushort)x.Register;
|
||||||
}
|
Debug.WriteLine($"NewState for SIID={SIID} State={current.LogicalState} is Register={reg}");
|
||||||
else if (ConditionOFF.Contains(current.LogicalState))
|
slave.SetRegister(dt.Register, reg);
|
||||||
{
|
dt.Value = "" + reg;
|
||||||
Debug.WriteLine($"NewState for SIID={SIID} State={current.LogicalState} is ConditionOFF");
|
dt.LastUpdate = DateTime.Now.ToString();
|
||||||
slave.SetRegister(dt.Register, 0);
|
return;
|
||||||
dt.Value = "OFF";
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.WriteLine($"NewState for SIID={SIID} in Modbus is ignored because Condition ON/OFF is not met");
|
|
||||||
dt.Value = "RULE NOT AVAILABLE";
|
|
||||||
}
|
}
|
||||||
|
Debug.WriteLine($"Translation for SIID={SIID} LogicalState={current.LogicalState} is not found");
|
||||||
|
dt.Value = "RULE NOT SET";
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"Condition ON/OFF for SIID={SIID} in Modbus is not set");
|
Debug.WriteLine($"Translation for SIID={SIID} in Modbus is not set");
|
||||||
dt.Value = "RULE NOT SET";
|
dt.Value = "RULE NOT SET";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1427,14 +1726,16 @@ namespace FAtoPA.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class ini untuk Trigger VX3K dari FSM Update
|
/// <summary>
|
||||||
|
/// Class ini untuk Trigger VX3K dari FSM Update
|
||||||
|
/// </summary>
|
||||||
class VXTriggerFromFSM : FSMResultInterface
|
class VXTriggerFromFSM : FSMResultInterface
|
||||||
{
|
{
|
||||||
ObservableCollection<VXData> data;
|
ObservableCollection<VXData> data;
|
||||||
ObservableCollection<FSMData> source;
|
ObservableCollection<FSMData> source;
|
||||||
VX3K vx;
|
VX3K vx;
|
||||||
List<String> ConditionON;
|
List<string> ConditionON;
|
||||||
List<String> ConditionOFF;
|
List<string> ConditionOFF;
|
||||||
public VXTriggerFromFSM(ObservableCollection<FSMData> source, ObservableCollection<VXData> data, VX3K vx, List<string> conditionON, List<string> conditionOFF)
|
public VXTriggerFromFSM(ObservableCollection<FSMData> source, ObservableCollection<VXData> data, VX3K vx, List<string> conditionON, List<string> conditionOFF)
|
||||||
{
|
{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
@@ -1443,12 +1744,19 @@ namespace FAtoPA.Net
|
|||||||
ConditionON = conditionON;
|
ConditionON = conditionON;
|
||||||
ConditionOFF = conditionOFF;
|
ConditionOFF = conditionOFF;
|
||||||
}
|
}
|
||||||
public void DiscoveredSIID(string SIID, NodeData type)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
/// <summary>
|
||||||
|
/// Event Discovered SIID, tidak dipakai di sini
|
||||||
|
/// </summary>
|
||||||
|
void FSMResultInterface.DiscoveredSIID(string SIID, NodeData type) { }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ada State baru dari FSM, Action to VX 3K
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SIID">SIID yang muncul</param>
|
||||||
|
/// <param name="previous">Previous state kalau ada</param>
|
||||||
|
/// <param name="current">State sekarang</param>
|
||||||
public void NewState(string SIID, NodeState previous, NodeState current)
|
public void NewState(string SIID, NodeState previous, NodeState current)
|
||||||
{
|
{
|
||||||
FSMData src = null;
|
FSMData src = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user