Component/Device name displayed in case of an exception during components loading or devices initialization.
This commit is contained in:
@@ -263,9 +263,14 @@ namespace TBF.BenchControl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static string CurrentlyInitializedDeviceName;
|
||||
///
|
||||
public static string InitializeDevices()
|
||||
{
|
||||
bool anyComponentIsInSimulMode = false;
|
||||
CurrentlyInitializedDeviceName = "-";
|
||||
|
||||
bool anyComponentIsInSimulMode = false;
|
||||
StringBuilder inSimulMode = new StringBuilder();
|
||||
|
||||
/// Add all devices to the state machine and initialize them
|
||||
@@ -277,13 +282,17 @@ namespace TBF.BenchControl
|
||||
anyComponentIsInSimulMode = true;
|
||||
}
|
||||
|
||||
if (cmpnt is IDevice)
|
||||
IDevice device = cmpnt as IDevice;
|
||||
if (device != null)
|
||||
{
|
||||
(cmpnt as IDevice).Initialize();
|
||||
AddDevice(cmpnt as IDevice); /// Only components that were initialized are added
|
||||
CurrentlyInitializedDeviceName = device.Name;
|
||||
device.Initialize();
|
||||
AddDevice(device); /// Only components that were initialized are added
|
||||
}
|
||||
}
|
||||
|
||||
CurrentlyInitializedDeviceName = "---";
|
||||
|
||||
/// Propagate debug levels from parents to children when necessary
|
||||
foreach (var cmpnt in components)
|
||||
{
|
||||
|
||||
@@ -125,6 +125,9 @@ namespace TBF.BenchControl
|
||||
return (cmpntFactory != null) ? cmpntFactory.CmpntCfgFromCmpntEntity(entity) : null;
|
||||
}
|
||||
|
||||
|
||||
public static string CurrentlyLoadedComponentName;
|
||||
|
||||
/// <summary>
|
||||
/// Load component entities from the database and convert them to TBF components
|
||||
/// derived from IComponent with mutual references.
|
||||
@@ -133,6 +136,8 @@ namespace TBF.BenchControl
|
||||
/// <returns>A list of TBF Components</returns>
|
||||
public static IList<IComponent> LoadComponentsFromDB(NHibernate.ISession session)
|
||||
{
|
||||
CurrentlyLoadedComponentName = string.Empty;
|
||||
|
||||
foreach (var factory in Factories) factory.ResetStaticProperties();
|
||||
|
||||
/// Load the list of components from the database
|
||||
@@ -144,6 +149,8 @@ namespace TBF.BenchControl
|
||||
IList<IComponent> components = new List<BenchControl.Generic.IComponent>();
|
||||
foreach (var entity in cmptnEntities)
|
||||
{
|
||||
CurrentlyLoadedComponentName = entity.Name;
|
||||
|
||||
IComponentFactory cmpntFactory = BenchControl.TbfComponents.CmpntFactoryFromClassName(entity.ClassName);
|
||||
if (cmpntFactory == null) continue;
|
||||
|
||||
@@ -177,6 +184,8 @@ namespace TBF.BenchControl
|
||||
if (cmpnt.Cfg.DebugLevel != DebugMode.Off) components.Add(cmpnt);
|
||||
}
|
||||
|
||||
CurrentlyLoadedComponentName = string.Empty;
|
||||
|
||||
return components;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,9 +112,14 @@ namespace TBF
|
||||
catch (Exception exc)
|
||||
{
|
||||
benchInitializationFailed = true;
|
||||
log.FatalFormat("Failed to initialize a test bench component: {0}", exc.Message);
|
||||
MessageBox.Show(string.Format("Failed to initialize a test bench component: {0}", exc.Message),
|
||||
Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
|
||||
string errMsg = string.Format(Strings.Failed_to_initialize_component_0_crlf_1,
|
||||
BenchControl.TbfComponents.CurrentlyLoadedComponentName,
|
||||
exc.Message);
|
||||
log.Fatal(errMsg);
|
||||
MessageBox.Show(errMsg, Strings.Error,
|
||||
System.Windows.Forms.MessageBoxButtons.OK,
|
||||
System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,9 +207,13 @@ namespace TBF
|
||||
catch (Exception exc)
|
||||
{
|
||||
benchInitializationFailed = true;
|
||||
log.Fatal("Failed to initialize a test bench component", exc);
|
||||
MessageBox.Show(exc.Message, Strings.Error, System.Windows.Forms.MessageBoxButtons.OK,
|
||||
System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||
string errMsg = string.Format(Strings.Failed_to_initialize_device_0_crlf_1,
|
||||
BenchControl.StateMachine.CurrentlyInitializedDeviceName,
|
||||
exc.Message);
|
||||
log.Fatal(errMsg);
|
||||
MessageBox.Show(errMsg, Strings.Error,
|
||||
System.Windows.Forms.MessageBoxButtons.OK,
|
||||
System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -1410,6 +1410,24 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to initialize component {0}\r\n{1}.
|
||||
/// </summary>
|
||||
internal static string Failed_to_initialize_component_0_crlf_1 {
|
||||
get {
|
||||
return ResourceManager.GetString("Failed_to_initialize_component_0_crlf_1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to initialize device {0}\r\n{1}.
|
||||
/// </summary>
|
||||
internal static string Failed_to_initialize_device_0_crlf_1 {
|
||||
get {
|
||||
return ResourceManager.GetString("Failed_to_initialize_device_0_crlf_1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to fast.
|
||||
/// </summary>
|
||||
|
||||
@@ -1374,4 +1374,10 @@
|
||||
<data name="Do_you_want_to_save_changes" xml:space="preserve">
|
||||
<value>Wollen sie die Änderungen speichern?</value>
|
||||
</data>
|
||||
<data name="Failed_to_initialize_component_0_crlf_1" xml:space="preserve">
|
||||
<value>Fehler beim Komponentestart {0}{1}{2}</value>
|
||||
</data>
|
||||
<data name="Failed_to_initialize_device_0_crlf_1" xml:space="preserve">
|
||||
<value>Fehler beim Gerätstart {0}{1}{2}</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1624,4 +1624,10 @@
|
||||
<data name="User_code" xml:space="preserve">
|
||||
<value>User code</value>
|
||||
</data>
|
||||
<data name="Failed_to_initialize_device_0_crlf_1" xml:space="preserve">
|
||||
<value>Failed to initialize device {0}\r\n{1}</value>
|
||||
</data>
|
||||
<data name="Failed_to_initialize_component_0_crlf_1" xml:space="preserve">
|
||||
<value>Failed to initialize component {0}\r\n{1}</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user