Skip to content

Commit

Permalink
Added Option to scale Mach Value / Fix FSUIPC AutoStart with only Run
Browse files Browse the repository at this point in the history
  • Loading branch information
Fragtality committed Dec 23, 2023
1 parent 3c51034 commit 9839f08
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$projdir = "C:\Users\Fragtality\source\repos\FenixQuartz"
$instBinDir = $projdir + "\Installer\bin\Release\app.publish"
$version = "v1.2.0"
$version = "v1.3.0"

#Create Lock
cd $projdir
Expand Down
Binary file modified FenixQuartz-latest.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions FenixQuartz/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public partial class App : Application
public static bool rawValues;
public static bool useLvars;
public static int updateIntervall;
public static bool scaleMachValue;
public static string altScaleDelim;
public static bool addFcuMode;
public static bool ooMode;
Expand Down Expand Up @@ -54,6 +55,7 @@ protected static void LoadConfiguration()
rawValues = Convert.ToBoolean(ConfigurationFile.GetSetting("rawValues", "false"));
useLvars = Convert.ToBoolean(ConfigurationFile.GetSetting("useLvars", "false"));
updateIntervall = Convert.ToInt32(ConfigurationFile.GetSetting("updateIntervall", "100"));
scaleMachValue = Convert.ToBoolean(ConfigurationFile.GetSetting("scaleMachValue", "false"));
altScaleDelim = Convert.ToString(ConfigurationFile.GetSetting("altScaleDelim", " "));
addFcuMode = Convert.ToBoolean(ConfigurationFile.GetSetting("addFcuMode", "true"));
ooMode = Convert.ToBoolean(ConfigurationFile.GetSetting("ooMode", "false"));
Expand Down
9 changes: 5 additions & 4 deletions FenixQuartz/ElementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ private void UpdateFCU()
if (isModeSpd)
result += value.ToString("D3");
else
result += "." + value.ToString();
result += "0." + value.ToString();

if (isSpdManaged)
result += "*";
Expand Down Expand Up @@ -652,15 +652,16 @@ private void UpdateFCU()

private void UpdateRawFCU()
{
//SPD
bool isSpdManaged = IPCManager.SimConnect.ReadLvar("I_FCU_SPEED_MANAGED") == 1;

bool isModeSpd = IPCManager.SimConnect.ReadLvar("I_FCU_SPEED_MODE") == 1;
float fvalue;
if (isSpdManaged)
fvalue = MemoryValues["fcuSpdManaged"].GetValue();
else
fvalue = (int)Math.Round(MemoryValues["fcuSpd"].GetValue());

if (App.scaleMachValue && !isModeSpd)
fvalue /= 100.0f;

IPCValues["fcuSpd"].SetValue(fvalue);
if (MemoryValues["fcuSpdDashed"].GetValue())
IPCValues["fcuSpdDashed"].SetValue((byte)1);
Expand Down
1 change: 1 addition & 0 deletions FenixQuartz/FenixQuartz.config.numlvar
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add key="rawValues" value="true" />
<add key="useLvars" value="true" />
<add key="updateIntervall" value="100" />
<add key="scaleMachValue" value="false"/>
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
Expand Down
1 change: 1 addition & 0 deletions FenixQuartz/FenixQuartz.config.numoffset
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add key="rawValues" value="true" />
<add key="useLvars" value="false" />
<add key="updateIntervall" value="100" />
<add key="scaleMachValue" value="false"/>
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
Expand Down
1 change: 1 addition & 0 deletions FenixQuartz/FenixQuartz.config.string
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add key="rawValues" value="false" />
<add key="useLvars" value="false" />
<add key="updateIntervall" value="100" />
<add key="scaleMachValue" value="false"/>
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
Expand Down
6 changes: 3 additions & 3 deletions FenixQuartz/FenixQuartz.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<IsPublishable>True</IsPublishable>
<PlatformTarget>x64</PlatformTarget>
<SignAssembly>False</SignAssembly>
<AssemblyVersion>1.2</AssemblyVersion>
<FileVersion>1.2</FileVersion>
<Version>1.2</Version>
<AssemblyVersion>1.3</AssemblyVersion>
<FileVersion>1.3</FileVersion>
<Version>1.3</Version>
<Copyright>Fragtality © 2023</Copyright>
<Authors>Fragtality</Authors>
<UseWPF>True</UseWPF>
Expand Down
Binary file modified Installer/AppPackage.zip
Binary file not shown.
1 change: 1 addition & 0 deletions Installer/FenixQuartz.config.numlvar
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add key="rawValues" value="true" />
<add key="useLvars" value="true" />
<add key="updateIntervall" value="100" />
<add key="scaleMachValue" value="false"/>
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
Expand Down
1 change: 1 addition & 0 deletions Installer/FenixQuartz.config.numoffset
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add key="rawValues" value="true" />
<add key="useLvars" value="false" />
<add key="updateIntervall" value="100" />
<add key="scaleMachValue" value="false"/>
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
Expand Down
1 change: 1 addition & 0 deletions Installer/FenixQuartz.config.string
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add key="rawValues" value="false" />
<add key="useLvars" value="false" />
<add key="updateIntervall" value="100" />
<add key="scaleMachValue" value="false"/>
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
Expand Down
50 changes: 42 additions & 8 deletions Installer/InstallerFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,56 @@ public static bool AutoStartFsuipc()
}
else
{
string pattern = @"^RunIf(\d+).*FenixQuartz\.exe";
if (Regex.IsMatch(fileContent, pattern, RegexOptions.Compiled | RegexOptions.Multiline))
RegexOptions regOptions = RegexOptions.Compiled | RegexOptions.Multiline;
var runMatches = Regex.Matches(fileContent, @"[;]{0,1}Run(\d+).*", regOptions);
int lastRun = 0;
if (runMatches.Count > 0 && runMatches[runMatches.Count - 1].Groups.Count == 2)
lastRun = Convert.ToInt32(runMatches[runMatches.Count - 1].Groups[1].Value);

var runIfMatches = Regex.Matches(fileContent, @"[;]{0,1}RunIf(\d+).*", regOptions);
int lastRunIf = 0;
if (runIfMatches.Count > 0 && runIfMatches[runIfMatches.Count - 1].Groups.Count == 2)
lastRunIf = Convert.ToInt32(runIfMatches[runIfMatches.Count - 1].Groups[1].Value);

if (Regex.IsMatch(fileContent, @"^[;]{0,1}Run(\d+).*FenixQuartz\.exe", regOptions))
{
fileContent = Regex.Replace(fileContent, pattern, $"RunIf$1={programParam},KILL,{Parameters.binPath}", RegexOptions.Compiled | RegexOptions.Multiline);
fileContent = Regex.Replace(fileContent, @"^[;]{0,1}Run(\d+).*FenixQuartz\.exe", $"RunIf{lastRunIf + 1}={programParam},KILL,{Parameters.binPath}", regOptions);
File.WriteAllText(regPath, fileContent, Encoding.Default);
result = true;
}
else
else if (Regex.IsMatch(fileContent, @"^[;]{0,1}RunIf(\d+).*FenixQuartz\.exe", regOptions))
{
int posLastRunBegin = fileContent.LastIndexOf("RunIf");
int posLastRunEnd = fileContent.IndexOf('\n', posLastRunBegin);
int lastIndex = Convert.ToInt32(fileContent.Substring(posLastRunBegin + 5, 1));
fileContent = fileContent.Insert(posLastRunEnd + 1, $"RunIf{lastIndex + 1}={programParam},KILL,{Parameters.binPath}\r\n");
fileContent = Regex.Replace(fileContent, @"^[;]{0,1}RunIf(\d+).*FenixQuartz\.exe", $"RunIf$1={programParam},KILL,{Parameters.binPath}", regOptions);
File.WriteAllText(regPath, fileContent, Encoding.Default);
result = true;
}
else
{
int index = -1;
if (runIfMatches.Count > 0 && runMatches.Count > 0)
{
index = runIfMatches[runIfMatches.Count - 1].Index + runIfMatches[runIfMatches.Count - 1].Length;
if (runMatches[runMatches.Count - 1].Index > runIfMatches[runIfMatches.Count - 1].Index)
index = runMatches[runMatches.Count - 1].Index + runMatches[runMatches.Count - 1].Length;
}
else if (runIfMatches.Count > 0)
index = runIfMatches[runIfMatches.Count - 1].Index + runIfMatches[runIfMatches.Count - 1].Length;
else if (runMatches.Count > 0)
index = runMatches[runMatches.Count - 1].Index + runMatches[runMatches.Count - 1].Length;

if (index > 0)
{
fileContent = fileContent.Insert(index + 1, $"RunIf{lastRunIf + 1}={programParam},KILL,{Parameters.binPath}\r\n");
File.WriteAllText(regPath, fileContent, Encoding.Default);
result = true;
}
else
{
fileContent = Regex.Replace(fileContent, @"^\[Programs\]\r\n", $"[Programs]\r\nRunIf{lastRunIf + 1}={programParam},KILL,{Parameters.binPath}\r\n", regOptions);
File.WriteAllText(regPath, fileContent, Encoding.Default);
result = true;
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Installer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You can also choose to export the numeric Raw-Values to L-Vars (**useLvars**) (a
Besides the displayed Value it also exports the "is Dashed" State of a Display (regardless of Mode). The State of the Dot ("is Managed") can directly be read from the Fenix Lvars (I_FCU_SPEED_MANAGED, I_FCU_HEADING_MANAGED, I_FCU_ALTITUDE_MANAGED). So with any Client capable of reading FSUIPC-Offsets and/or Lvars, you have all the Information to build an accurate working FCU!<br/>
It also exports a Variable "isVsActive" which tells if the Plane is currently in VS Mode - that is mostly needed internally, but it exported also to be used in other Use-Cases. I use it for my Alt-Knob-Toggle Function on the StreamDeck, so the Lua-Script does a "Pull" instead of an "Push" on the Alt-Knob when VS is active. Note that part of the accurate Detection of the VS Mode is based on the State-Changes of the Alt- and VS-Knob, make sure they are triggered in the correct way (that is incrementing/decrementing the according S_ Variable).<br/><br/>

Regardless of Mode or Output: The Binary will create a File called **Assignments.txt** when executed which will tell you the Name/Location of the Values (even when no Sim is running). Please note that this is in Accordance to the current Configuration, so you only see the Name/Location for the currently configured Mode and Output! Also note that the TO-Speeds are always exported as L-Vars, regardless of the current Configuration.<br/><br/>
Regardless of Mode or Output: The Binary will create a File called **Assignments.txt** (located in %appdata\FenixQuartz) when executed which will tell you the Name/Location of the Values (even when no Sim is running). Please note that this is in Accordance to the current Configuration, so you only see the Name/Location for the currently configured Mode and Output! Also note that the TO-Speeds are always exported as L-Vars, regardless of the current Configuration.<br/><br/>
If you miss the UTC Time on the Clock: that doe not need to be read from Memory. Since the Clock always displays the current Sim-Time, the correct Time can be retrieved via Offsets 0x023B, 0x023C and 0x023A (should be A-Vars ZULU_HOUR, ZULU_MINUTE and CLOCK_SECOND).

<br/><br/><br/>
Expand All @@ -93,6 +93,7 @@ The available Parameters are:
- **rawValues**: When *true*, the FCU Values are exported directly as numeric Values ("Raw-Value/Offset" Mode). Default: *"false"*
- **useLvars**: When *true*, the Values are exported as L-Vars instead of FSUIPC Offsets ("Raw-Value/L-Var" Mode). Only works when rawValues is also set!. Default: *"false"*
- **updateIntervall**: The time between each Update in Milliseconds (Read Memory-Locations -> Write to Variables). Default: *"100"*
- **scaleMachValue**: The MACH Value is scaled to a float Value in in both Raw-Value Modes (e.g. it is output as 0.79 instead of 79)
- **altScaleDelim**: The Character to be inserted in the FCU Altitude String when the Scale is set to 100. Has no Effect on any the Raw-Value Mode. Default: *" "* (Space)
- **addFcuMode**: If *false*, the FCUs Displays show only the Value (no SPD/HDG/VS Header) in one Line. Has no Effect on any Raw-Value Mode. Default: *"true"*
- **ooMode**: If *true*, the Zeroes on the VS-Display will be exported as "o" instead of "0" if your Hardware/Font allows Letters to be displayed (only relevant in String/Offset Mode). Default *"false"*
Expand Down

0 comments on commit 9839f08

Please sign in to comment.