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