Files
TeslaSuite/Console/TeslaConsole/Squad.cs
T
CydandClaude Opus 4.8 548550b312 Initial commit: TeslaSuite monorepo (TeslaConsole + TeslaLauncher)
Co-locate the two cockpit-pod projects into a single repository:

- Console/  : TeslaConsole, the net48 WinForms operator console (decompiled
              reconstruction) plus its differential + catalog test suite.
- Launcher/ : TeslaLauncher, the net6 pod-side Service + Agent rewrite.

Adds a combined TeslaSuite.sln, root README documenting the shared wire
contract (and its current duplication, the main follow-up), and a root
.gitignore. Histories were not preserved per request; this is a fresh start
from the current working state of both projects.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 14:43:28 -05:00

142 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace TeslaConsole;
[Serializable]
internal class Squad
{
[NonSerialized]
private EventHandler mOnOnlineChanged;
private Guid mGuid = Guid.NewGuid();
private string mName = "";
private bool mOnline;
[NonSerialized]
private List<Pod> mPods = new List<Pod>();
public Guid Guid => mGuid;
public string Name
{
get
{
return mName;
}
set
{
mName = value;
}
}
public bool IsLocal
{
get
{
int num = 0;
foreach (Pod pod in Pods)
{
if (pod.IsLocal)
{
num++;
}
}
return num > 0;
}
}
public bool Online
{
get
{
return mOnline;
}
set
{
if (value == mOnline)
{
return;
}
mOnline = value;
if (mOnOnlineChanged != null)
{
mOnOnlineChanged(this, EventArgs.Empty);
}
foreach (Pod mPod in mPods)
{
mPod.Online = value;
}
}
}
public List<Pod> Pods
{
get
{
if (mPods == null)
{
mPods = new List<Pod>();
}
return mPods;
}
}
public List<Pod> OnlinePods
{
get
{
List<Pod> list = new List<Pod>();
foreach (Pod mPod in mPods)
{
if (mPod.Online)
{
list.Add(mPod);
}
}
return list;
}
}
public event EventHandler OnOnlineChanged
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
mOnOnlineChanged = (EventHandler)Delegate.Combine(mOnOnlineChanged, value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
mOnOnlineChanged = (EventHandler)Delegate.Remove(mOnOnlineChanged, value);
}
}
public Squad()
: this(Guid.NewGuid(), "")
{
}
public Squad(string name)
: this(Guid.NewGuid(), name)
{
}
public Squad(Guid guid, string name)
{
mGuid = guid;
mName = name;
}
public Squad Clone()
{
Squad squad = new Squad(mGuid, mName);
squad.mOnline = mOnline;
squad.mPods.AddRange(mPods);
return squad;
}
}