Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .run/Build Robot.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Robot" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="build" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
12 changes: 9 additions & 3 deletions src/main/java/xbot/common/command/BaseRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,10 @@ protected void sharedPeriodic() {

// Then, refresh any Subsystem or other components that implement DataFrameRefreshable.
double dataFrameStart = getPerformanceTimestampInMs();
for (DataFrameRefreshable refreshable : dataFrameRefreshables) {
refreshable.refreshDataFrame();
}
refreshAllSubsystems();
// for (DataFrameRefreshable refreshable : dataFrameRefreshables) {
Comment thread
WeWaWu marked this conversation as resolved.
// refreshable.refreshDataFrame();
// }
double dataFrameEnd = getPerformanceTimestampInMs();
Logger.recordOutput("RefreshDevicesMs", dataFrameEnd - dataFrameStart);

Expand All @@ -275,6 +276,11 @@ protected void sharedPeriodic() {
outsidePeriodicStart = getPerformanceTimestampInMs();
}

public void refreshAllSubsystems() {
for (BaseSubsystem subsystem : DataFrameRegistry.getAllSubsystems()) {
subsystem.refreshDataFrame();
}
}

@Override
public void simulationInit() {
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/xbot/common/command/BaseSubsystem.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package xbot.common.command;

import java.util.ArrayList;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -15,20 +12,23 @@ public abstract class BaseSubsystem extends SubsystemBase implements IPropertySu

protected final Logger log;
protected final AKitLogger aKitLog;
protected final List<DataFrameRefreshable> dataFrameRefreshables = new ArrayList<>();
// protected final List<DataFrameRefreshable> dataFrameRefreshables = new ArrayList<>();
Comment thread
WeWaWu marked this conversation as resolved.

public BaseSubsystem() {
super();
log = LogManager.getLogger(this.getName());
aKitLog = new AKitLogger(this);

DataFrameRegistry.registerSubsystem(this);
}

Comment thread
WeWaWu marked this conversation as resolved.
public String getPrefix() {
return this.getName() + "/";
}

protected void registerDataFrameRefreshable(DataFrameRefreshable refreshable) {
dataFrameRefreshables.add(refreshable);
}
// protected void registerDataFrameRefreshable(DataFrameRefreshable refreshable) {
// dataFrameRefreshables.add(refreshable);
// }

/**
* This method is called on each {@link edu.wpi.first.wpilibj2.command.CommandScheduler} loop.
Expand All @@ -43,8 +43,5 @@ public void periodic() {

@Override
public void refreshDataFrame() {
for (DataFrameRefreshable refreshable : dataFrameRefreshables) {
refreshable.refreshDataFrame();
}
}
}
14 changes: 14 additions & 0 deletions src/main/java/xbot/common/command/DataFrameRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package xbot.common.command;

import java.util.ArrayList;
import java.util.List;

public final class DataFrameRegistry {
Comment thread
WeWaWu marked this conversation as resolved.
private static final List<BaseSubsystem> subsystems = new ArrayList<>();
public static void registerSubsystem(BaseSubsystem s) {
subsystems.add(s);
}
public static List<BaseSubsystem> getAllSubsystems() {
return subsystems;
}
}
2 changes: 2 additions & 0 deletions src/main/java/xbot/common/properties/IPropertySupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

public interface IPropertySupport {
public String getPrefix();

// void refreshDataFrame();
Comment thread
WeWaWu marked this conversation as resolved.
}