Files
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

314 lines
3.8 KiB
C#

using System;
using System.Drawing;
using System.IO;
using System.Net;
using System.Runtime.CompilerServices;
namespace TeslaConsole;
[Serializable]
public class Pod : IDisposable
{
[NonSerialized]
private EventHandler mOnOnlineChanged;
private Guid mId = Guid.NewGuid();
private IPAddress mIPAddress = IPAddress.Any;
private IPAddress mGateway = IPAddress.Any;
private IPAddress mDns = IPAddress.Any;
private IPAddress mSubnet = IPAddress.Any;
private string mHostName = "";
private byte[] mKey;
private byte[] mMacAddress;
private string mName;
private string mPodArtPath;
private HostType mHostType;
private bool mOnline;
[NonSerialized]
private Image mPodArtImage;
[NonSerialized]
private MungaGame mMungaGame;
public Guid ID
{
get
{
return mId;
}
set
{
mId = value;
}
}
public bool IsLocal
{
get
{
if (mKey != null)
{
return mKey.Length > 0;
}
return false;
}
}
public IPAddress IPAddress
{
get
{
return mIPAddress;
}
set
{
mIPAddress = value;
}
}
public IPAddress DNS
{
get
{
return mDns;
}
set
{
mDns = value;
}
}
public IPAddress Gateway
{
get
{
return mGateway;
}
set
{
mGateway = value;
}
}
public IPAddress Subnet
{
get
{
return mSubnet;
}
set
{
mSubnet = value;
}
}
public string HostName
{
get
{
return mHostName;
}
set
{
mHostName = value;
}
}
public byte[] Key
{
get
{
return mKey;
}
set
{
mKey = value;
}
}
public string Name
{
get
{
return mName;
}
set
{
mName = value;
}
}
public byte[] MacAddress
{
get
{
return mMacAddress;
}
set
{
mMacAddress = value;
}
}
public string PodArtFilePath
{
get
{
return mPodArtPath;
}
set
{
mPodArtPath = value;
}
}
public HostType HostType
{
get
{
return mHostType;
}
set
{
mHostType = value;
}
}
public Image PodArtImage
{
get
{
if (mPodArtImage == null)
{
try
{
if (mPodArtPath == null || !File.Exists(mPodArtPath))
{
return null;
}
mPodArtImage = Image.FromFile(mPodArtPath);
}
catch
{
}
}
return mPodArtImage;
}
}
public bool Online
{
get
{
return mOnline;
}
set
{
if (value != mOnline)
{
mOnline = value;
if (mOnOnlineChanged != null)
{
mOnOnlineChanged(this, EventArgs.Empty);
}
}
}
}
public MungaGame MungaGame
{
get
{
if (mMungaGame == null)
{
mMungaGame = new MungaGame(this);
}
return mMungaGame;
}
}
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 Pod()
{
mMungaGame = new MungaGame(this);
}
public Pod Clone()
{
Pod pod = new Pod();
pod.mId = mId;
pod.mIPAddress = mIPAddress;
pod.mGateway = mGateway;
pod.mDns = mDns;
pod.mSubnet = mSubnet;
pod.mHostName = mHostName;
pod.mKey = mKey;
pod.mMacAddress = mMacAddress;
pod.mName = mName;
pod.mPodArtPath = mPodArtPath;
pod.mHostType = mHostType;
pod.mOnline = mOnline;
pod.mPodArtImage = mPodArtImage;
pod.mMungaGame = mMungaGame;
return pod;
}
public bool MacAddressEquals(byte[] macAddress)
{
if (mMacAddress == null)
{
return macAddress == null;
}
if (mMacAddress.Length != macAddress.Length)
{
return false;
}
for (int i = 0; i < macAddress.Length; i++)
{
if (mMacAddress[i] != macAddress[i])
{
return false;
}
}
return true;
}
~Pod()
{
Dispose();
}
public void Dispose()
{
if (mPodArtImage != null)
{
mPodArtImage.Dispose();
}
}
}