Component import/export implemented, ver. 2.17.771
This commit is contained in:
parent
7983423e2a
commit
d225d97863
@ -3,6 +3,8 @@
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -53,6 +55,59 @@ namespace Config.Entities
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual void Export(StreamWriter output)
|
||||
{
|
||||
output.WriteLine(Name);
|
||||
output.WriteLine(ClassName);
|
||||
output.WriteLine(ParentName);
|
||||
output.WriteLine(Mode.ToString());
|
||||
output.WriteLine(Logging.ToString());
|
||||
output.Write(Parameters);
|
||||
|
||||
output.Close();
|
||||
}
|
||||
|
||||
public static Component Import(StreamReader input)
|
||||
{
|
||||
Component result = new Component();
|
||||
|
||||
result.Name = input.ReadLine();
|
||||
result.ClassName = input.ReadLine();
|
||||
result.ParentName = input.ReadLine();
|
||||
|
||||
string line = input.ReadLine();
|
||||
if (line.Equals(DebugMode.DetectedOff.ToString())) result.Mode = DebugMode.DetectedOff;
|
||||
else if (line.Equals(DebugMode.DetectedOn.ToString())) result.Mode = DebugMode.DetectedOn;
|
||||
else if (line.Equals(DebugMode.Normal.ToString())) result.Mode = DebugMode.Normal;
|
||||
else if (line.Equals(DebugMode.AutoDetect.ToString())) result.Mode = DebugMode.AutoDetect;
|
||||
else if (line.Equals(DebugMode.FailureDuringOperation.ToString())) result.Mode = DebugMode.FailureDuringOperation;
|
||||
else if (line.Equals(DebugMode.Off.ToString())) result.Mode = DebugMode.Off;
|
||||
else if (line.Equals(DebugMode.Record.ToString())) result.Mode = DebugMode.Record;
|
||||
else if (line.Equals(DebugMode.Reply.ToString())) result.Mode = DebugMode.Reply;
|
||||
else if (line.Equals(DebugMode.Simulate.ToString())) result.Mode = DebugMode.Simulate;
|
||||
else if (line.Equals(DebugMode.Inherit.ToString())) result.Mode = DebugMode.Inherit;
|
||||
|
||||
line = input.ReadLine();
|
||||
if (line.Equals(LogLevel.Off.ToString())) result.Logging = LogLevel.Off;
|
||||
else if (line.Equals(LogLevel.Fatal.ToString())) result.Logging = LogLevel.Fatal;
|
||||
else if (line.Equals(LogLevel.Error.ToString())) result.Logging = LogLevel.Error;
|
||||
else if (line.Equals(LogLevel.Warn.ToString())) result.Logging = LogLevel.Warn;
|
||||
else if (line.Equals(LogLevel.Info.ToString())) result.Logging = LogLevel.Info;
|
||||
else if (line.Equals(LogLevel.Debug.ToString())) result.Logging = LogLevel.Debug;
|
||||
else if (line.Equals(LogLevel.All.ToString())) result.Logging = LogLevel.All;
|
||||
|
||||
result.Parameters = string.Empty;
|
||||
line = input.ReadLine();
|
||||
while (line != null)
|
||||
{
|
||||
result.Parameters += line;
|
||||
result.Parameters += Environment.NewLine;
|
||||
line = input.ReadLine();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual string ToString(string indent)
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// 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("2.17.742.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.742.0")]
|
||||
[assembly: AssemblyVersion("2.17.771.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.771.0")]
|
||||
|
||||
@ -65,13 +65,15 @@ namespace TBF
|
||||
/// SharedDlgButtons configuration
|
||||
sharedButtons.RequiredGroupMembership = Users.Grp.GID.Administrators;
|
||||
|
||||
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
|
||||
SharedButtons.Buttons.Remove |
|
||||
SharedButtons.Buttons.Up |
|
||||
SharedButtons.Buttons.Down |
|
||||
SharedButtons.Buttons.Edit |
|
||||
SharedButtons.Buttons.Copy;
|
||||
sharedButtons.Unlocked += Unlocked;
|
||||
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
|
||||
SharedButtons.Buttons.Remove |
|
||||
SharedButtons.Buttons.Up |
|
||||
SharedButtons.Buttons.Down |
|
||||
SharedButtons.Buttons.Edit |
|
||||
SharedButtons.Buttons.Copy |
|
||||
SharedButtons.Buttons.Export |
|
||||
SharedButtons.Buttons.Import;
|
||||
sharedButtons.Unlocked += Unlocked;
|
||||
sharedButtons.OKClicked += okButton_Click;
|
||||
sharedButtons.CancelClicked += cancelButton_Click;
|
||||
sharedButtons.AddClicked += addButton_Click;
|
||||
@ -80,6 +82,8 @@ namespace TBF
|
||||
sharedButtons.DownClicked += downButton_Click;
|
||||
sharedButtons.EditClicked += editButton_Click;
|
||||
sharedButtons.CopyClicked += copyButton_Click;
|
||||
sharedButtons.ExportClicked += exportButton_Click;
|
||||
sharedButtons.ImportClicked += importButton_Click;
|
||||
}
|
||||
|
||||
private void ComponentsManagerDlg_Load(object sender, EventArgs e)
|
||||
@ -446,6 +450,49 @@ namespace TBF
|
||||
}
|
||||
}
|
||||
|
||||
/// Export a component to a file
|
||||
private void exportButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listViewEx.SelectedIndices.Count != 1) return;
|
||||
|
||||
Component component = listViewEx.SelectedItems[0].Tag as Component;
|
||||
if (component == null) return;
|
||||
|
||||
SaveFileDialog dlg = new SaveFileDialog();
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
component.Export(new StreamWriter(dlg.FileName, false, System.Text.Encoding.UTF8));
|
||||
}
|
||||
}
|
||||
|
||||
/// Import a component form a file
|
||||
private void importButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog dlg = new OpenFileDialog();
|
||||
if (dlg.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
/// Import a procedure from a file
|
||||
Component newComponent = Component.Import(new StreamReader(dlg.FileName, System.Text.Encoding.UTF8));
|
||||
|
||||
IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(newComponent);
|
||||
if (cfg != null)
|
||||
{
|
||||
IComponentCfgCtrl cfgControl = cfg.GetControl();
|
||||
cfgControl.Config = cfg;
|
||||
cfgControl.Config.Name = cfgControl.Config.Name + " imported";
|
||||
cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1;
|
||||
|
||||
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
|
||||
cfgForm.TbfComponents = cmpntEntities;
|
||||
cfgForm.ComponentCfgCtrl = cfgControl;
|
||||
cfgForm.UnlockAfterStart = true;
|
||||
if (cfgForm.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
AddOne(cfgForm.Config.CreateDbEntity());
|
||||
}
|
||||
}
|
||||
|
||||
private void upButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listViewEx.SelectedIndices.Count != 1) return;
|
||||
|
||||
@ -548,30 +548,33 @@ namespace TBF
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question))
|
||||
{
|
||||
/// Show 'Closing_Test_Bench_Framework' modeless window in separate thread
|
||||
var form = new TBF.Forms.ModelessActivityForm()
|
||||
{
|
||||
Message = Strings.Closing_Test_Bench_Framework,
|
||||
FontFamily = "Arial",
|
||||
FontSize = 24,
|
||||
FontStyle = FontStyle.Regular,
|
||||
BackgroundColor = Color.PeachPuff,
|
||||
StartActivityHandler = false,
|
||||
};
|
||||
Thread formThread = new Thread(() => form.ShowDialog());
|
||||
formThread.Start();
|
||||
if (BenchControl.StateMachine.Running)
|
||||
{
|
||||
/// Show 'Closing_Test_Bench_Framework' modeless window in separate thread
|
||||
var form = new TBF.Forms.ModelessActivityForm()
|
||||
{
|
||||
Message = Strings.Closing_Test_Bench_Framework,
|
||||
FontFamily = "Arial",
|
||||
FontSize = 24,
|
||||
FontStyle = FontStyle.Regular,
|
||||
BackgroundColor = Color.PeachPuff,
|
||||
StartActivityHandler = false,
|
||||
};
|
||||
Thread formThread = new Thread(() => form.ShowDialog());
|
||||
formThread.Start();
|
||||
|
||||
/// Stop the system
|
||||
BenchControl.StateMachine.Stop();
|
||||
while (BenchControl.StateMachine.Running) { } /// wait until the last StopOperaions() completes
|
||||
BenchControl.StateMachine.StopDevices();
|
||||
BenchControl.StateMachine.StopDevices2();
|
||||
/// Stop the system
|
||||
BenchControl.StateMachine.Stop();
|
||||
while (BenchControl.StateMachine.Running) { } /// wait until the last StopOperaions() completes
|
||||
BenchControl.StateMachine.StopDevices();
|
||||
BenchControl.StateMachine.StopDevices2();
|
||||
|
||||
UiBridge.Bridge.OnEmergencyStopChanged(this, UiBridge.EmergencyStopEventArgs.State.CloseForm);
|
||||
UiBridge.Bridge.OnEmergencyStopChanged(this, UiBridge.EmergencyStopEventArgs.State.CloseForm);
|
||||
|
||||
/// Close 'Closing_Test_Bench_Framework' modeless window
|
||||
form.CloseForm(null, new EventArgs());
|
||||
formThread.Join();
|
||||
/// Close 'Closing_Test_Bench_Framework' modeless window
|
||||
form.CloseForm(null, new EventArgs());
|
||||
formThread.Join();
|
||||
}
|
||||
|
||||
/// Close the main window
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.17.770.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.770.0")]
|
||||
[assembly: AssemblyVersion("2.17.771.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.771.0")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user