Theos/Greeks are still produced if AW2 window is not loaded
This commit is contained in:
1 parent
dc6ae2ac29
commit
2a65c45d21
2 files changed
+85
No files matched your search
@@ -142,6 +142,7 @@ namespace mbts.spark {
|
||||
var list_imm = new VolSurfaceUsageListImmutable(ulist);
|
||||
Log.Ui.info(list_imm.log_string());
|
||||
_bb.post(SparkTags.VolSurfaceUsageTag, list_imm);
|
||||
_spin_vss(list_imm);
|
||||
});
|
||||
_disps.Add(list_sub);
|
||||
}
|
||||
@@ -150,6 +151,13 @@ namespace mbts.spark {
|
||||
return _bb;
|
||||
}
|
||||
|
||||
void _spin_vss(VolSurfaceUsageListImmutable ulist) {
|
||||
foreach (var u in ulist.UsageList) {
|
||||
var vs_id = u.VsId;
|
||||
_bb.post(SparkTags.VolSurfaceActiveUITag(vs_id), true);
|
||||
}
|
||||
}
|
||||
|
||||
void _on_vs_usage_update(Update<VolSurfaceUsageListImmutable, int> update) {
|
||||
// TODO
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
public class BusTagDiagnostics {
|
||||
|
||||
private class TagInfo {
|
||||
public uint n_subs = 0;
|
||||
public uint n_udpates = 0;
|
||||
public DateTime last_sub_time = DateTime.MinValue;
|
||||
public DateTime last_pub_time = DateTime.MinValue;
|
||||
public bool published() {
|
||||
return last_pub_time != DateTime.MinValue;
|
||||
}
|
||||
public bool subscribed() {
|
||||
return last_sub_time != DateTime.MinValue;
|
||||
}
|
||||
public bool sub_without_pub() {
|
||||
return subscribed() && !published() &&
|
||||
(DateTime.Now - last_pub_time).Seconds >= 10;
|
||||
}
|
||||
}
|
||||
private readonly TimeSpan _log_per = TimeSpan.FromSeconds(5);
|
||||
private DateTime _last_log_time = DateTime.Now;
|
||||
private System.Threading.Thread _logging_thread;
|
||||
private Dictionary<object, TagInfo> tag_map = new Dictionary<object, TagInfo>();
|
||||
private TagInfo _get_or_add(object tag) {
|
||||
TagInfo ti = null;
|
||||
if (!tag_map.TryGetValue(tag, out ti)) {
|
||||
ti = new TagInfo();
|
||||
tag_map.Add(tag, ti);
|
||||
}
|
||||
return ti;
|
||||
}
|
||||
|
||||
public BusTagDiagnostics() {
|
||||
_logging_thread = new System.Threading.Thread(() => {
|
||||
while (true) {
|
||||
System.Threading.Thread.Sleep(5000);
|
||||
log_missing();
|
||||
}
|
||||
});
|
||||
_logging_thread.IsBackground = true;
|
||||
_logging_thread.Start();
|
||||
}
|
||||
|
||||
public void update_pub(object tag) {
|
||||
lock (this) {
|
||||
TagInfo ti = _get_or_add(tag);
|
||||
ti.n_udpates++;
|
||||
ti.last_pub_time = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
public void update_sub(object tag) {
|
||||
lock (this) {
|
||||
TagInfo ti = _get_or_add(tag);
|
||||
ti.last_sub_time = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
public void log_missing() {
|
||||
lock (this) {
|
||||
if (DateTime.Now - _last_log_time >= _log_per) {
|
||||
_last_log_time = DateTime.Now;
|
||||
foreach (var kv in tag_map) {
|
||||
var tag = kv.Key;
|
||||
TagInfo ti = kv.Value;
|
||||
if (ti.sub_without_pub()) {
|
||||
bts.Log.Ui.warn($"BusTagDiagnostics missing pub, tag: {tag.ToString()} n_subs: {ti.n_subs}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user