Skip to content

Commit

Permalink
Fix for TS5
Browse files Browse the repository at this point in the history
  • Loading branch information
Rambalac committed Apr 21, 2017
1 parent b347ae0 commit b14690d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
<None Include="TestMenuSetGX7.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestMenuSetTS5.json" />
<None Include="TestMenuSetTS5.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
19 changes: 19 additions & 0 deletions Core.Tests/MenuSetHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,24 @@ public void TestJsons(string filename)
Assert.True(menuset.LiveviewQuality.Any(q => q.Value == "vga"));

}

[Theory]
[InlineData("TestMenuSetTS5.json")]
public void TestJsonsGh3(string filename)
{
using (var stream = File.OpenRead(filename))
{
var reader = new StreamReader(stream);
var str = reader.ReadToEnd();
var obj = JsonConvert.DeserializeObject<LogglyMessage>(str);
var serializer = new XmlSerializer(typeof(MenuSetRequestResult));
var result = (MenuSetRequestResult)serializer.Deserialize(new StringReader(obj.Data));
CameraParser.TryParseMenuSet(result.MenuSet, "en", out menuset, new CameraParser[] { new GH3Parser() });
}

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

}
}
}
17 changes: 17 additions & 0 deletions Core/Camera/CameraParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@

public abstract class CameraParser
{
protected static readonly TitledList<CameraMenuItemText> DefaultIsoValues = new List<string>
{
"100",
"200",
"400",
"800",
"1600",
"3200",
"6400",
"12800"
}.Select(i => new CameraMenuItemText(i, i, "setsetting", "iso", i)).ToTitledList("ISO Values");

public IReadOnlyDictionary<int, string> ApertureBinary { get; } = new Dictionary<int, string>
{
{ 392, "1.7" },
Expand Down Expand Up @@ -227,6 +239,11 @@ public virtual MenuSet ParseMenuSet(RawMenuSet menuset, string lang)

protected CameraMenuItemText ToMenuItem(Item item)
{
if (item == null)
{
return null;
}

return new CameraMenuItemText(item, GetText(item.TitleId));
}

Expand Down
4 changes: 2 additions & 2 deletions Core/Camera/GH3Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ protected override bool InnerParseMenuSet(MenuSet result, RawMenuSet menuset, st
result.MeteringMode = ToMenuItems(photosettings["menu_item_id_lightmet"]);

result.ExposureShifts = ToMenuItems(qmenu["menu_item_id_exposure2"]);
result.IsoValues = ToMenuItems(qmenu["menu_item_id_sensitivity"]);
result.IsoValues = ToMenuItems(qmenu["menu_item_id_sensitivity"]) ?? DefaultIsoValues;
result.WhiteBalances = ToMenuItems(qmenu["menu_item_id_whitebalance"]);

result.SingleShootMode = ToMenuItem(driveMode["menu_item_id_1shoot"]);
result.BurstModes = ToMenuItems(driveMode["menu_item_id_burst"]);
result.BurstModes = ToMenuItems(driveMode["menu_item_id_burst"]) ?? ToMenuItems(photosettings["menu_item_id_burst"]);

result.VideoFormat = null;

Expand Down

0 comments on commit b14690d

Please sign in to comment.