Skip to content

Commit

Permalink
Lots of Simulator Updates
Browse files Browse the repository at this point in the history
Makes all sim data classes have internal constructors.
Adds a new Simulator DS that works with for the new command tests.

Fixes the ButtonAttributeCommandTest. Needs to call TeleopPeriodic
twice, and needed delays added.
  • Loading branch information
ThadHouse committed Nov 2, 2015
1 parent dcc4b4b commit 727c150
Show file tree
Hide file tree
Showing 23 changed files with 444 additions and 90 deletions.
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/AccelerometerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class AccelerometerData : DataBase
private double m_y = 0;
private double m_z = 1;

internal AccelerometerData() { }

public bool HasSource
{
get { return m_hasSource; }
Expand Down
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/AnalogInData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class AnalogInData : NotifyDataBase
private int m_accumulatorCenter = 0;
private int m_accumulatorDeadband = 0;

internal AnalogInData() { }

public override void ResetData()
{
m_hasSource = false;
Expand Down
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/AnalogOutData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ public class AnalogOutData : NotifyDataBase
private double m_voltage = 0.0;
private bool m_initialized = false;

internal AnalogOutData() { }

public override void ResetData()
{
m_voltage = 0.0;
Expand Down
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/AnalogTriggerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class AnalogTriggerData : DataBase
private double m_trigUpper = 0;
private double m_trigLower = 0;

internal AnalogTriggerData() { }

public override void ResetData()
{
m_hasSource = false;
Expand Down
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/CanTalonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace HAL_Simulator.Data
{
public class CanTalonData : NotifyDataBase
{
internal CanTalonData() { }

private double m_eProfileParamSlot0_P = 0.0;
private double m_eProfileParamSlot0_I = 0.0;
private double m_eProfileParamSlot0_D = 0.0;
Expand Down
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/CounterData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace HAL_Simulator.Data
{
public class CounterData : EncoderData
{
internal CounterData() { }

private Mode mode = 0;
private int averageSize = 0;

Expand Down
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/DIOData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class DIOData : NotifyDataBase
private double m_pulseLength = 0;
private bool m_isInput = true;

internal DIOData() { }

public override void ResetData()
{
m_initialized = false;
Expand Down
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/DigitalPWMData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class DigitalPWMData : DataBase
private double m_dutyCycle = 0;
private uint m_pin = 0;

internal DigitalPWMData() { }

public override void ResetData()
{
m_initialized = false;
Expand Down
278 changes: 277 additions & 1 deletion HAL-Simulation/Data/DriverStationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,287 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HAL_Base;

namespace HAL_Simulator.Data
{
internal class DriverStationData
public class DSControlData : DataBase
{
public override void ResetData()
{
m_hasSource = false;
m_enabled = false;
m_autonomous = false;
m_test = false;
m_eStop = false;
m_fmsAttached = false;
m_dsAttached = true;
}

internal DSControlData() { }

private bool m_hasSource = false;
private bool m_enabled = false;
private bool m_autonomous = false;
private bool m_test = false;
private bool m_eStop = false;
private bool m_fmsAttached = false;
private bool m_dsAttached = true;

public bool HasSource
{
get { return m_hasSource; }
set
{
if (m_hasSource == value) return;
m_hasSource = value;
OnPropertyChanged(value);
}
}

public bool Enabled
{
get { return m_enabled; }
internal set
{
if (m_enabled == value) return;
m_enabled = value;
OnPropertyChanged(value);
}
}

public bool Autonomous
{
get { return m_autonomous; }
internal set
{
if (m_autonomous == value) return;
m_autonomous = value;
OnPropertyChanged(value);
}
}

public bool Test
{
get { return m_test; }
internal set
{
if (m_test == value) return;
m_test = value;
OnPropertyChanged(value);
}
}

public bool EStop
{
get { return m_eStop; }
internal set
{
if (m_eStop == value) return;
m_eStop = value;
OnPropertyChanged(value);
}
}

public bool FmsAttached
{
get { return m_fmsAttached; }
internal set
{
if (m_fmsAttached == value) return;
m_fmsAttached = value;
OnPropertyChanged(value);
}
}

public bool DsAttached
{
get { return m_dsAttached; }
internal set
{
if (m_dsAttached == value) return;
m_dsAttached = value;
OnPropertyChanged(value);
}
}
}

public class JoystickData : NotifyDataBase
{
public override void ResetData()
{
m_hasSource = false;
m_leftRumble = 0;
m_rightRumble = 0;
m_isXbox = 0;
m_type = 0;
m_name = "Joystick";
for (int i = 0; i < m_buttons.Length; i++)
{
m_buttons[i] = false;
}

for (int i = 0; i < m_axes.Length; i++)
{
m_axes[i] = 0.0;
}

for (int i = 0; i < m_povs.Length; i++)
{
m_povs[i] = -1;
}


base.ResetData();
}

internal JoystickData() { }

private bool m_hasSource = false;
private bool[] m_buttons = new bool[13];
private double[] m_axes = new double[6];
private int[] m_povs = new[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
private ushort m_leftRumble = 0;
private ushort m_rightRumble = 0;
private int m_isXbox = 0;
private byte m_type = 0;
private string m_name = "Joystick";

public bool HasSource
{
get { return m_hasSource; }
set
{
if (m_hasSource == value) return;
m_hasSource = value;
OnPropertyChanged(value);
}
}

public bool[] Buttons
{
get { return m_buttons; }
internal set
{
if (m_buttons == value) return;
m_buttons = value;
OnPropertyChanged(value);
}
}
public double[] Axes
{
get { return m_axes; }
internal set
{
if (m_axes == value) return;
m_axes = value;
OnPropertyChanged(value);
}
}
public ushort LeftRumble
{
get { return m_leftRumble; }
internal set
{
if (m_leftRumble == value) return;
m_leftRumble = value;
OnPropertyChanged(value);
}
}

public ushort RightRumble
{
get { return m_rightRumble; }
internal set
{
if (m_rightRumble == value) return;
m_rightRumble = value;
OnPropertyChanged(value);
}
}
public int IsXbox
{
get { return m_isXbox; }
internal set
{
if (m_isXbox == value) return;
m_isXbox = value;
OnPropertyChanged(value);
}
}

public byte Type
{
get { return m_type; }
internal set
{
if (m_type == value) return;
m_type = value;
OnPropertyChanged(value);
}
}

public int[] Povs
{
get { return m_povs; }
internal set
{
if (m_povs == value) return;
m_povs = value;
OnPropertyChanged(value);
}
}

public string Name
{
get { return m_name; }
internal set
{
if (m_name == value) return;
m_name = value;
OnPropertyChanged(value);
}
}
}

public class DriverStationData : DataBase
{
public override void ResetData()
{
foreach (var joystickData in Joysticks)
{
joystickData.ResetData();
}
ControlData.ResetData();
m_allianceStation = 0;
}

internal DriverStationData()
{
List<JoystickData> data = new List<JoystickData>();

for (int i = 0; i < 6; i++)
{
data.Add(new JoystickData());
}

Joysticks = data.AsReadOnly();
}


public IReadOnlyList<JoystickData> Joysticks { get; }
public DSControlData ControlData { get; } = new DSControlData();
private HALAllianceStationID m_allianceStation = 0;

public HALAllianceStationID AllianceStation
{
get { return m_allianceStation; }
set
{
if (m_allianceStation == value) return;
m_allianceStation = value;
OnPropertyChanged(value);
}
}
}
}
2 changes: 2 additions & 0 deletions HAL-Simulation/Data/EncoderData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class EncoderData : NotifyDataBase

public Dictionary<string, dynamic> Config = null;

internal EncoderData() { }

public override void ResetData()
{
m_hasSource = false;
Expand Down
Loading

0 comments on commit 727c150

Please sign in to comment.