robotdotnet / WPILib

DotNet implementation of WPILib for FIRST Robotics Competition (FRC)
27 stars 8 forks source link

Rewrite of the entire simulator. #52

Closed ThadHouse closed 8 years ago

ThadHouse commented 8 years ago

The old simulator we had was completely based off of the python implementation, and used a single dictionary to store all data. This was cool, but was an absolute pain, and more pythonic then we wanted. This is a rewrite of the entire simulator to make it act more like a C# program should.

Every module now has its own class, with properties to set values. If a property gets written from outside the HAL, its set to public get and set. However if its something we only want the HAL writing to its public get internal set, which helps with threading. Some modules are notify modules, which classes can register for updates. Originally this was going to be based on INotifyPropertyChanged, however that was about 4 times slower then doing it the way the old NotifyDict handled callbacks. So the way it checks to see if a callback exists is based off of NotifyDict.

Another change was to make the code act more like the real FPGA would. For some things, this means instead of storing seperate values for raw voltage and voltage for analog ins and outs, only voltage is stored, and it automatically converts between them. For the PDP, total current is calculated based off of the sum of all 16 ports. Interrupts now work for analog triggers, and counter handling is now automatic.

Also added was a new ShooterMechanism, which means the simulator now has all 3 of the major basic feedback mechanisms simulated with wrapper classes.

This PR does not include the P/Invoke changes, but they will work without issue, since that part of the code did not change at all.

This does not include the new official DS software for simulators, as that has not been finished. However, the simulator is now always in Teleop Enabled, and the old simulated DS does not update the dictionary anymore, which should save ALOT of the trouble we have been having with unit testing and simulation.

It still needs lots of commenting, but that can be done later. Its fairly easy to understand, and the main parts teams are going to access already have better wrapper functions.