Skip to content

Commit

Permalink
v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
somapatrik committed Dec 11, 2020
1 parent b49ac0e commit 2c86eb3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
10 changes: 9 additions & 1 deletion S7Lite/Class/PlcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void StopPLCServer()
{
PLC.Stop();
PLC.CpuStatus = 4;
//IsRunning = false;
UnregisterAllDB();
}

#region DB add/remove
Expand All @@ -88,6 +88,14 @@ private static void UnregisterDB(int num)
PLC.UnregisterArea(S7Server.S7AreaDB, num);
}

public static void UnregisterAllDB()
{
foreach (DB datablock in PLC_Memory)
{
PLC.UnregisterArea(S7Server.srvAreaDB, datablock.number);
}
}

public static void DBRemove(int DBNumber)
{
UnregisterDB(DBNumber);
Expand Down
22 changes: 17 additions & 5 deletions S7Lite/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,21 @@ private void PlcServer_UpdatedDB(object sender, EventArgs e)
{
try
{
string dbnumberS = sender.ToString();
int dbnumber = Int32.Parse(dbnumberS);

string msg = "Client updated DB " + sender.ToString();
Logger.Log(msg);
LogGUI(msg);

foreach (DBControl db in DBStack.Children)
{
if (db.DBNumber == (int)sender)
db.UpdateDB();
}
// TODO Invoke needed
DBStack.Dispatcher.Invoke(() => {
foreach (DBControl db in DBStack.Children)
{
if (db.DBNumber == dbnumber)
db.UpdateDB();
}
});

} catch (Exception ex)
{
Expand All @@ -97,6 +103,10 @@ private void SetGUI()
// Disable start
lbl_start.IsEnabled = false;

// Version
Version version = Assembly.GetExecutingAssembly().GetName().Version;
lbl_Version.Content = string.Format("v{0}.{1} (Beta)",version.Major, version.Minor);

}

#region GUI events
Expand All @@ -121,6 +131,8 @@ private void lbl_start_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
lblAddDB.IsEnabled = false;
cmb_ip.IsEnabled = false;



foreach (DBControl db in DBStack.Children)
{
db.Activate();
Expand Down
10 changes: 5 additions & 5 deletions S7Lite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("S7Lite")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("S7Lite is S7-300 PLC Server simulation")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Patrik Šoma")]
[assembly: AssemblyProduct("S7Lite")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © 2020 Patrik Šoma")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]

0 comments on commit 2c86eb3

Please sign in to comment.