Skip to content

Commit

Permalink
fixes for bad camera behavior, camera respoce contains duplicated ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rambalac committed Apr 12, 2017
1 parent aafa131 commit 35be868
Show file tree
Hide file tree
Showing 10 changed files with 3,631 additions and 50 deletions.
4 changes: 2 additions & 2 deletions GMaster.Tests/GMaster.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="MenuSetHelperTestsGH3.cs" />
<Compile Include="MenuSetHelperTestsGH4.cs" />
<Compile Include="MenuSetHelperTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTestApp.xaml.cs">
<DependentUpon>UnitTestApp.xaml</DependentUpon>
Expand All @@ -120,6 +119,7 @@
<None Include="GMaster.Tests_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="TestMenuSetGH5.xml" />
<None Include="Package.StoreAssociation.xml" />
<Content Include="capabilities.xml" />
<Content Include="Properties\UnitTestApp.rd.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,29 @@ public async Task Load(string filename)
[InlineData("TestMenuSetGH3.xml")]
[InlineData("TestMenuSetGH3_M.xml")]
[InlineData("TestMenuSetGH3_S.xml")]
[InlineData("TestMenuSetGH4.xml")]
[InlineData("TestMenuSetGH5.xml")]
public async Task TestLiveviewQualiyty(string filename)
{
await Load(filename);
Assert.Equal(2, menuset.LiveviewQuality.Count);
Assert.True(menuset.LiveviewQuality.Any(q => q.Value == "vga"));
}

[Fact]
public async Task TestGH5()
{
var file = await Package.Current.InstalledLocation.GetFileAsync("TestMenuSetGH5.xml");
using (var stream = await file.OpenSequentialReadAsync())
{
var serializer = new XmlSerializer(typeof(MenuSetRuquestResult));
var result = (MenuSetRuquestResult)serializer.Deserialize(stream.AsStreamForRead());
CameraParser.TryParseMenuSet(result.MenuSet, "en", out menuset, new CameraParser[] { new GH4Parser() });
}

Assert.Equal(2, menuset.LiveviewQuality.Count);
Assert.True(menuset.LiveviewQuality.Any(q => q.Value == "vga"));
}

}
}
40 changes: 0 additions & 40 deletions GMaster.Tests/MenuSetHelperTestsGH4.cs

This file was deleted.

3,596 changes: 3,596 additions & 0 deletions GMaster.Tests/TestMenuSetGH5.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions GMaster.sln
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ Global
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Debug|Any CPU.ActiveCfg = Release|x86
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Debug|ARM.ActiveCfg = Debug|ARM
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Debug|x64.ActiveCfg = Debug|x64
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Debug|x64.Build.0 = Debug|x64
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Debug|x86.ActiveCfg = Debug|x86
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Debug|x86.Build.0 = Debug|x86
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Release|Any CPU.ActiveCfg = Release|x86
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Release|ARM.ActiveCfg = Release|ARM
{E47763B4-2DDD-445E-8F8E-A32AB1816DAE}.Release|x64.ActiveCfg = Release|x64
Expand All @@ -74,7 +76,9 @@ Global
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Debug|Any CPU.ActiveCfg = Release|x86
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Debug|ARM.ActiveCfg = Debug|ARM
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Debug|x64.ActiveCfg = Debug|x64
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Debug|x64.Build.0 = Debug|x64
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Debug|x86.ActiveCfg = Debug|x86
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Debug|x86.Build.0 = Debug|x86
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Release|Any CPU.ActiveCfg = Release|x86
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Release|ARM.ActiveCfg = Release|ARM
{D9E969D8-E655-4E21-8A2F-FBA250F30D48}.Release|x64.ActiveCfg = Release|x64
Expand Down
6 changes: 3 additions & 3 deletions GMaster/Camera/CameraParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ public static string ApertureBinToText(int bin)
return Math.Pow(2, bin / 512.0).ToString("F1", CultureInfo.InvariantCulture);
}

public static CameraParser TryParseMenuSet(RawMenuSet resultMenuSet, string lang, out MenuSet menuset)
public static CameraParser TryParseMenuSet(RawMenuSet resultMenuSet, string lang, out MenuSet menuset, CameraParser[] parsers = null)
{
var parsers = new CameraParser[]
var innerParsers = parsers ?? new CameraParser[]
{
new GH4Parser(),
new GH3Parser()
};

var exceptions = new List<Exception>();
foreach (var p in parsers)
foreach (var p in innerParsers)
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion GMaster/Camera/GH4Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected override bool InnerParseMenuSet(MenuSet result, RawMenuSet menuset, st
result.FlashModes = ToMenuItems(photosettings["menu_item_id_flash"]);

result.Angles = ToMenuItems(qmenu["menu_item_id_f_and_ss_angle"]);
result.ExposureShifts = ToMenuItems(qmenu["menu_item_id_exposure2"]);
result.ExposureShifts = ToMenuItems(qmenu["menu_item_id_exposure3"] ?? qmenu["menu_item_id_exposure2"]);
result.AutofocusModes = ToMenuItems(qmenu["menu_item_id_afmode"]);
result.CustomMultiModes = ToMenuItems(qmenu["menu_item_id_afmode"].Items["menu_item_id_afmode_custom_multi"]);
result.IsoValues = ToMenuItems(qmenu["menu_item_id_sensitivity"]);
Expand Down
2 changes: 1 addition & 1 deletion GMaster/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="51338Rambalac.GMaster" Publisher="CN=92765C0E-C69D-491B-9315-91859F5319B9" Version="1.7.2.0" />
<Identity Name="51338Rambalac.GMaster" Publisher="CN=92765C0E-C69D-491B-9315-91859F5319B9" Version="1.7.3.0" />
<mp:PhoneIdentity PhoneProductId="19ca5020-d17a-4012-ad2c-663f57d568c7" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>GMaster</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion GMaster/_pkginfo.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
E:\Projects\GMaster\GMaster\bin\ARM\Release\Upload\GMaster_1.7.2.0\GMaster_1.7.2.0_x86_x64_arm.appxbundle
E:\Projects\GMaster\GMaster\bin\ARM\Release\Upload\GMaster_1.7.3.0\GMaster_1.7.3.0_x86_x64_arm.appxbundle
7 changes: 5 additions & 2 deletions Tools/HashCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ public HashCollection(IEnumerable<TItem> items)

public bool IsReadOnly => false;

public TItem this[string index] => dictionary.TryGetValue(index, out var value) ? value : throw new KeyNotFoundException("Key not found: " + index);
public TItem this[string index] => dictionary.TryGetValue(index, out var value) ? value : default(TItem);

public virtual void Add(TItem item)
{
dictionary.Add(item.Id, item);
if (!dictionary.ContainsKey(item.Id))
{
dictionary.Add(item.Id, item);
}
}

public virtual void Clear()
Expand Down

0 comments on commit 35be868

Please sign in to comment.