Skip to content

Commit

Permalink
Merge pull request #318 from xibosignage/develop
Browse files Browse the repository at this point in the history
Release v4 R401
  • Loading branch information
dasgarner authored Sep 19, 2023
2 parents 99844c5 + cc7a21c commit abef66d
Show file tree
Hide file tree
Showing 15 changed files with 421 additions and 75 deletions.
20 changes: 20 additions & 0 deletions Action/DataUpdatePlayerAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XiboClient.Action
{
class DataUpdatePlayerAction : PlayerActionInterface
{
public const string Name = "dataUpdate";

public int widgetId;

public string GetActionName()
{
return Name;
}
}
}
7 changes: 6 additions & 1 deletion Action/XmrSubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2022 Xibo Signage Ltd
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
Expand Down Expand Up @@ -232,6 +232,11 @@ private void processMessage(NetMQMessage message, AsymmetricCipherKeyPair rsaKey
new Thread(new ThreadStart(command.Run)).Start();
break;

case "dataUpdate":
DataUpdatePlayerAction dataUpdate = JsonConvert.DeserializeObject<DataUpdatePlayerAction>(opened);
OnAction?.Invoke(dataUpdate);
break;

case "collectNow":
case RevertToSchedulePlayerAction.Name:
OnAction?.Invoke(action);
Expand Down
7 changes: 5 additions & 2 deletions Control/FaultController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ public async Task<string> Fault()
}

string[] splitKey = data.key.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
string widgetId = splitKey[1];

// widgetId must be parseable as an integer
// only old widgets have string IDs and they would not support calling this method.
int widgetId = int.Parse(splitKey[1]);

CacheManager.Instance.AddUnsafeWidget(
(UnsafeFaultCodes)data.code,
widgetId,
widgetId + "",
data.reason,
data.ttl
);
Expand Down
1 change: 1 addition & 0 deletions Control/InfoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void GetInfo()
jObject.Add("scheduleManagerStatus", ClientInfo.Instance.ScheduleManagerStatus);
jObject.Add("unsafeList", ClientInfo.Instance.UnsafeList);
jObject.Add("requiredFileList", ClientInfo.Instance.RequiredFilesList);
jObject.Add("dataList", ClientInfo.Instance.DataFilesList);
#endif

writer.Write(jObject.ToString());
Expand Down
6 changes: 4 additions & 2 deletions InfoScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ private void Update()

textBoxSchedule.Text = ClientInfo.Instance.ScheduleManagerStatus;
textBoxRequiredFiles.Text = ClientInfo.Instance.UnsafeList
+ Environment.NewLine
+ ClientInfo.Instance.RequiredFilesList;
+ Environment.NewLine
+ ClientInfo.Instance.RequiredFilesList
+ Environment.NewLine
+ ClientInfo.Instance.DataFilesList;

// Log grid
logDataGridView.Items.Clear();
Expand Down
14 changes: 14 additions & 0 deletions Log/ClientInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ private static readonly Lazy<ClientInfo>
/// </summary>
public string RequiredFilesList;

/// <summary>
/// Set the data files list
/// </summary>
public string DataFilesList;

/// <summary>
/// Set the schedule manager status
/// </summary>
Expand Down Expand Up @@ -160,6 +165,15 @@ public void UpdateRequiredFiles(string requiredFilesString)
RequiredFilesList = requiredFilesString;
}

/// <summary>
/// Update the data files text box
/// </summary>
/// <param name="dataFilesString"></param>
public void UpdateDataFiles(string dataFilesString)
{
DataFilesList = dataFilesString;
}

/// <summary>
/// Update the unsafe files list
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Logic/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ private static readonly Lazy<ApplicationSettings>
/// </summary>
private List<string> ExcludedProperties;

public string ClientVersion { get; } = "4 R400.6";
public string ClientVersion { get; } = "4 R401.0";
public string Version { get; } = "7";
public int ClientCodeVersion { get; } = 400;
public int ClientCodeVersion { get; } = 401;

private ApplicationSettings()
{
Expand Down
25 changes: 15 additions & 10 deletions Logic/RequiredFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public int FilesMissing
int count = 0;
foreach (RequiredFile rf in RequiredFileList)
{
if (!rf.Complete)
if (!rf.Complete && !rf.IsWidgetData)
{
count++;
}
Expand Down Expand Up @@ -270,15 +270,7 @@ private void SetRequiredFiles()
{
// Add and skip onward
rf.Id = int.Parse(attributes["id"].Value);
rf.SaveAs = rf.Id + ".json";
rf.UpdateInterval = attributes["updateInterval"] != null ? int.Parse(attributes["updateInterval"].Value) : 120;

// Does this data file already exist? and if so, is it sufficiently up to date.
if (File.Exists(ApplicationSettings.Default.LibraryPath + @"\" + rf.SaveAs))
{
rf.Complete = File.GetLastWriteTime(ApplicationSettings.Default.LibraryPath + @"\" + rf.SaveAs) > DateTime.Now.AddMinutes(-1 * rf.UpdateInterval);
}

RequiredFileList.Add(rf);
continue;
}
Expand Down Expand Up @@ -444,7 +436,12 @@ public void ReportInventory()

foreach (RequiredFile rf in RequiredFileList)
{
if (rf.FileType == "dependency")
if (rf.FileType == "widget")
{
// We don't report media inventory for data
continue;
}
else if (rf.FileType == "dependency")
{
xml += string.Format("<file type=\"{0}\" id=\"{1}\" fileType=\"{2}\" complete=\"{3}\" lastChecked=\"{4}\" />",
rf.FileType,
Expand Down Expand Up @@ -518,5 +515,13 @@ public class RequiredFile

// Data
public int UpdateInterval;

public bool IsWidgetData
{
get
{
return FileType.Equals("widget", StringComparison.OrdinalIgnoreCase);
}
}
}
}
23 changes: 22 additions & 1 deletion Logic/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public class Schedule
private FaultsAgent _faultsAgent;
Thread _faultsAgentThread;

// Data Agent
private DataAgent _dataAgent;

Thread _dataAgentThread;

// XMR Subscriber
private XmrSubscriber _xmrSubscriber;
Thread _xmrSubscriberThread;
Expand Down Expand Up @@ -136,8 +141,15 @@ public Schedule(string scheduleLocation)
_scheduleManagerThread = new Thread(new ThreadStart(_scheduleManager.Run));
_scheduleManagerThread.Name = "ScheduleManagerThread";

// Data Agent
_dataAgent = new DataAgent();
_dataAgentThread = new Thread(new ThreadStart(_dataAgent.Run))
{
Name = "DataAgent"
};

// Create a RequiredFilesAgent
_scheduleAndRfAgent = new ScheduleAndFilesAgent();
_scheduleAndRfAgent = new ScheduleAndFilesAgent(_dataAgent);
_scheduleAndRfAgent.CurrentScheduleManager = _scheduleManager;
_scheduleAndRfAgent.ScheduleLocation = scheduleLocation;
_scheduleAndRfAgent.HardwareKey = _hardwareKey.Key;
Expand Down Expand Up @@ -202,6 +214,9 @@ public void InitializeComponents()
// Start the RequiredFilesAgent thread
_scheduleAndRfAgentThread.Start();

// Start the data agent thread
_dataAgentThread.Start();

// Start the ScheduleManager thread
_scheduleManagerThread.Start();

Expand Down Expand Up @@ -350,6 +365,12 @@ void _xmrSubscriber_OnAction(Action.PlayerActionInterface action)
wakeUpXmds();
break;

case "dataUpdate":
// Wakeup the data agent and mark the widget to be force updated.
_dataAgent.ForceUpdateWidget(((DataUpdatePlayerAction)action).widgetId);
_dataAgent.WakeUp();
break;

case LayoutChangePlayerAction.Name:
// Add to a collection of Layout Change events
if (((LayoutChangePlayerAction)action).changeMode == "replace")
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.400.6.0")]
[assembly: AssemblyFileVersion("4.400.6.0")]
[assembly: AssemblyVersion("4.401.0.0")]
[assembly: AssemblyFileVersion("4.401.0.0")]
[assembly: Guid("3bd467a4-4ef9-466a-b156-a79c13a863f7")]
3 changes: 3 additions & 0 deletions XiboClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Action\Command.cs" />
<Compile Include="Action\DataUpdatePlayerAction.cs" />
<Compile Include="Action\HttpCommand.cs" />
<Compile Include="Action\HttpCommandConfig.cs" />
<Compile Include="Action\LayoutChangePlayerAction.cs" />
Expand Down Expand Up @@ -191,13 +192,15 @@
<Compile Include="OptionsForm.xaml.cs">
<DependentUpon>OptionsForm.xaml</DependentUpon>
</Compile>
<Compile Include="XmdsAgents\DataAgent.cs" />
<Compile Include="XmdsAgents\FaultsAgent.cs" />
<Compile Include="XmdsAgents\FileAgent.cs" />
<Compile Include="XmdsAgents\LibraryAgent.cs" />
<Compile Include="XmdsAgents\LogAgent.cs" />
<Compile Include="XmdsAgents\RegisterAgent.cs" />
<Compile Include="XmdsAgents\ScheduleAndFilesAgent.cs" />
<Compile Include="XmdsAgents\StatAgent.cs" />
<Compile Include="XmdsAgents\WidgetData.cs" />
<Page Include="InfoScreen.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Loading

0 comments on commit abef66d

Please sign in to comment.