common/Hardware/WaterMeter/Genesis/GenesisFile/Consts/FwUpdateStateInfo.cs
2026-04-23 17:50:07 +02:00

91 lines
4.6 KiB
C#

using System;
using System.Linq;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Properties;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts
{
/// <summary>
/// Concatenation of state and string
/// </summary>
public static class FwUpdateStateInfo
{
/// <summary>
/// Build state information
/// </summary>
private static readonly FwUpdateStateText[] StateInfos;
/// <summary>
/// Ctor
/// </summary>
static FwUpdateStateInfo()
{
StateInfos = new FwUpdateStateText[(Int32)FwUpdateState.FwUpdateStateListDelimiter];
StateInfos[(Int32)FwUpdateState.Idle].State = FwUpdateState.Idle;
StateInfos[(Int32)FwUpdateState.Idle].Message = Resources.StrFwUpdateStateIdle;
StateInfos[(Int32)FwUpdateState.StepFailed].State = FwUpdateState.StepFailed;
StateInfos[(Int32)FwUpdateState.StepFailed].Message = Resources.StrFwUpdateStateStepFailed;
StateInfos[(Int32)FwUpdateState.UpdateFailed].State = FwUpdateState.UpdateFailed;
StateInfos[(Int32)FwUpdateState.UpdateFailed].Message = Resources.StrFwUpdateStateUpdateFailed;
StateInfos[(Int32)FwUpdateState.StartInitial].State = FwUpdateState.StartInitial;
StateInfos[(Int32)FwUpdateState.StartInitial].Message = Resources.StrFwUpdateStateStartInitial;
StateInfos[(Int32)FwUpdateState.EraseTstFile].State = FwUpdateState.EraseTstFile;
StateInfos[(Int32)FwUpdateState.EraseTstFile].Message = Resources.StrEraseTstFile;
StateInfos[(Int32)FwUpdateState.RepeatFwUpdate].State = FwUpdateState.RepeatFwUpdate;
StateInfos[(Int32)FwUpdateState.RepeatFwUpdate].Message = Resources.StrFwUpdateStateRepeatFwUpdate;
StateInfos[(Int32)FwUpdateState.UploadFileApps].State = FwUpdateState.UploadFileApps;
StateInfos[(Int32)FwUpdateState.UploadFileApps].Message = Resources.StrFwUpdateStateUploadFileApps;
StateInfos[(Int32)FwUpdateState.DownloadFileApps].State = FwUpdateState.DownloadFileApps;
StateInfos[(Int32)FwUpdateState.DownloadFileApps].Message = Resources.StrFwUpdateStateDownloadFileApps;
StateInfos[(Int32)FwUpdateState.CompareFileApps].State = FwUpdateState.CompareFileApps;
StateInfos[(Int32)FwUpdateState.CompareFileApps].Message = Resources.StrFwUpdateStateCompareFileApps;
StateInfos[(Int32)FwUpdateState.DownloadUpgradeControlFile].State = FwUpdateState.DownloadUpgradeControlFile;
StateInfos[(Int32)FwUpdateState.DownloadUpgradeControlFile].Message = Resources.StrFwUpdateStateDownloadUpgradeControlFile;
StateInfos[(Int32)FwUpdateState.BuildUpgradeControlFile].State = FwUpdateState.BuildUpgradeControlFile;
StateInfos[(Int32)FwUpdateState.BuildUpgradeControlFile].Message = Resources.StrFwUpdateStateBuildUpgradeControlFile;
StateInfos[(Int32)FwUpdateState.BuildFileApps].State = FwUpdateState.BuildFileApps;
StateInfos[(Int32)FwUpdateState.BuildFileApps].Message = Resources.StrFwUpdateStateBuildFileApps;
StateInfos[(Int32)FwUpdateState.TriggerUpgrade].State = FwUpdateState.TriggerUpgrade;
StateInfos[(Int32)FwUpdateState.TriggerUpgrade].Message = Resources.StrFwUpdateStateTriggerUpgrade;
StateInfos[(Int32)FwUpdateState.EraseUpdateFile].State = FwUpdateState.EraseUpdateFile;
StateInfos[(Int32)FwUpdateState.EraseUpdateFile].Message = Resources.StrFwUpdateStateEraseUpdateFile;
StateInfos[(Int32)FwUpdateState.PrepareUpdate].State = FwUpdateState.PrepareUpdate;
StateInfos[(Int32)FwUpdateState.PrepareUpdate].Message = Resources.StrFwUpdateStatePrepareUpdate;
}
/// <summary>
/// Get the current information
/// </summary>
/// <param name="state">state to search for information text</param>
public static String GetTextFromState(FwUpdateState state)
{
return (from stateInfo in StateInfos
where stateInfo.State == state
select stateInfo.Message).FirstOrDefault();
}
/// <summary>
/// Get the state of the text
/// </summary>
/// <param name="text">information text to search if state is assigned</param>
public static FwUpdateState GetStateFromText(String text)
{
return (from stateInfo in StateInfos
where stateInfo.Message == text
select stateInfo.State).FirstOrDefault();
}
}
}