Skip to content

Commit

Permalink
- Philips ChannelMap\_100: fixed reading/writing favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
Horst Beham committed Jul 27, 2021
1 parent bba6ffb commit 0639750
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 10 deletions.
2 changes: 1 addition & 1 deletion source/ChanSort.Api/Model/DataRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public virtual void ValidateAfterLoad()
this.FavListCount = this.loader.Features.MaxFavoriteLists;

var favMode = this.FavoritesMode;
if (this.ChannelLists.Any(l => l.IsMixedSourceFavoritesList))
if (this.ChannelLists.Any(l => l.IsMixedSourceFavoritesList && l.Channels.Count > 0))
favMode = loader.Features.FavoritesMode = FavoritesMode.MixedSource;

foreach (var list in this.ChannelLists)
Expand Down
5 changes: 4 additions & 1 deletion source/ChanSort.Loader.Philips/XmlSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public XmlSerializer(string inputFile) : base(inputFile)
this.DataRoot.AddChannelList(this.dvbcChannels);
this.DataRoot.AddChannelList(this.satChannels);
this.DataRoot.AddChannelList(this.allSatChannels);
this.DataRoot.AddChannelList(this.favChannels);
//this.DataRoot.AddChannelList(this.favChannels); // format 100.0 does not support mixed source favs and adding it would automatically switch to mixed source fav mode

this.dvbtChannels.VisibleColumnFieldNames.Add("Source");
this.dvbcChannels.VisibleColumnFieldNames.Add("Source");
Expand Down Expand Up @@ -174,6 +174,9 @@ public override void Load()
// otherwise load the single file that was originally selected by the user
LoadFile(this.FileName);
}

if (this.Features.FavoritesMode == FavoritesMode.MixedSource)
this.DataRoot.AddChannelList(this.favChannels);
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion source/ChanSort.sln
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.M3u", "Chan
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Philips", "ChanSort.Loader.Philips\ChanSort.Loader.Philips.csproj", "{1F52B5EC-A2F1-4E53-9E1A-4658296C5BB5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spike.LgWebOs5", "Spike.LgWebOs5\Spike.LgWebOs5.csproj", "{32EFB306-DEF8-4488-B1AE-46D5B183C373}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spikes", "Spike.LgWebOs5\Spikes.csproj", "{32EFB306-DEF8-4488-B1AE-46D5B183C373}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Grundig", "ChanSort.Loader.Grundig\ChanSort.Loader.Grundig.csproj", "{4D5AF0A3-1B96-42C8-910D-0C4852EA22F4}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public struct LaSat
uint8 header[28];
struct
{
uint16 u1[3];
uint16 u1;
uint16 zero1;
uint16 zero2;
uint16 sid;
uint16 u2;
uint16 pcrPid;
Expand Down Expand Up @@ -53,5 +55,5 @@ public struct LaSat
} satellites[30];
} structured;
} dataBlock;
uint8 suffix_0A_0D[2];
uint8 suffix_0A_0D[2]; // this may or may not be present, also additional data may follow, which should be kept as-is
};
93 changes: 93 additions & 0 deletions source/Spike.LgWebOs5/PhilipsXmlStatsCollector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ChanSort.Api;
using ChanSort.Loader.Philips;

namespace Spike.PhilipsXml
{
class PhilipsXmlStatsCollector
{
static void Main()
{
using var w = new StreamWriter(@"d:\sources\chansort\testfiles_philips\stats.txt");
var dirs = new[] {"100.0", "105.0", "110.0"};
foreach (var dir in dirs)
ProcessDir(Path.Combine(@"d:\sources\chansort\testfiles_philips", dir), w);
}

private static void ProcessDir(string dir, StreamWriter w)
{
foreach (var bak in Directory.GetFiles(dir, "*.bak"))
File.Copy(bak, bak.Replace(".bak", ""), true);

foreach (var subdir in Directory.GetDirectories(dir))
ProcessDir(subdir, w);

var file = Path.Combine(dir, "chanLst.bin");
if (File.Exists(file))
ProcessFile(file, w);
}

private static void ProcessFile(string file, StreamWriter w)
{
var sb = new StringBuilder();
sb.Append(file);
try
{
var p = new PhilipsPlugin();
var ser = p.CreateSerializer(file);
ser.Load();
int totalChans = 0;
var conseq = true;
var inOrder = true;
var hasFav = false;
var srcSum = new int[5];
var typeSum = new int[4];
foreach (var list in ser.DataRoot.ChannelLists)
{
if (list.IsMixedSourceFavoritesList)
continue;
totalChans += list.Channels.Count;
var lastNr = 0;
var chanCountBySrc = new int[5,4];
foreach (var c in list.Channels)
{
inOrder &= c.OldProgramNr >= lastNr;
if (!inOrder)
{
}
conseq &= c.OldProgramNr == lastNr + 1;
if (!conseq)
{
}
lastNr = c.OldProgramNr;
hasFav |= c.GetOldPosition(1) != -1;
var s = c.SignalSource;
var i0 = (s & SignalSource.Antenna) != 0 ? 1 : (s & SignalSource.Cable) != 0 ? 2 : (s & SignalSource.Sat) != 0 ? 3 : (s & SignalSource.IP) != 0 ? 4 : 0;
var i1 = (s & SignalSource.Tv) != 0 ? 1 : (s & SignalSource.Radio) != 0 ? 2 : (s & SignalSource.Data) != 0 ? 3 : 0;
++chanCountBySrc[i0, i1];
++srcSum[i0];
++typeSum[i1];
}
}

sb.Append($"\t{totalChans}");
foreach(var n in srcSum)
sb.Append("\t").Append(n);
foreach (var n in typeSum)
sb.Append("\t").Append(n);
sb.Append($"\t{inOrder}\t{conseq}\t{hasFav}");
}
catch (Exception ex)
{
sb.Append("\t").Append(ex.Message);
}
w.WriteLine(sb.ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="PhilipsXmlStatsCollector.cs" />
<None Include="WebOs5StatsCollector.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -86,6 +87,10 @@
<Project>{dccffa08-472b-4d17-bb90-8f513fc01392}</Project>
<Name>ChanSort.Api</Name>
</ProjectReference>
<ProjectReference Include="..\ChanSort.Loader.Philips\ChanSort.Loader.Philips.csproj">
<Project>{1f52b5ec-a2f1-4e53-9e1a-4658296c5bb5}</Project>
<Name>ChanSort.Loader.Philips</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@

namespace Spike.LgWebOs5
{
class Program
class WebOs5StatsCollector
{
private static string basedir;

static void Main(string[] args)
{
CollectLgWebOs5Stats(args);
}

#region CollectLgWebOs5Stats()
static void CollectLgWebOs5Stats(string[] args)
{
basedir = args.Length > 0 ? args[0] : @"d:\sources\chansort\testfiles_lg";

Expand Down Expand Up @@ -44,7 +50,9 @@ static void Main(string[] args)

ProcessWebOs5Files(basedir, csv);
}
#endregion

#region ProcessWebOs5Files
private static void ProcessWebOs5Files(string dir, StreamWriter csv)
{
var files = Directory.GetFiles(dir, "GlobalClone*.tll");
Expand All @@ -61,6 +69,7 @@ private static void ProcessWebOs5Files(string dir, StreamWriter csv)
foreach (var subdir in Directory.GetDirectories(dir))
ProcessWebOs5Files(subdir, csv);
}
#endregion

#region ProcessFile()
private static string ProcessFile(string file)
Expand Down Expand Up @@ -192,13 +201,15 @@ private static string ProcessWebOs5JsonData(string json)
}
#endregion

#region Dup()
private static string Dup(string str, int count)
{
var sb = new StringBuilder(str.Length * count);
for (int i = 0; i < count; i++)
sb.Append(str);
return sb.ToString();
}
#endregion
}

#region class ChanListStats
Expand Down
7 changes: 4 additions & 3 deletions source/changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
ChanSort Change Log
===================

TBD
- improved Linux/Wine performance
- minor fixes ("File / File information" didn't ignore deleted channels when counting duplicates)
2021-07-27
- Philips ChannelMap\_100: fixed reading/writing favorites
- updated Swiss reference lists with new ONID-TSID-SID for SRF info HD and RSI LA HD
- improved Linux/Wine performance
- "File / File information" now ignores deleted channels when counting duplicates

2021-07-26
- user interface can now be toggled between
Expand Down

0 comments on commit 0639750

Please sign in to comment.