001/* 002 * Copyright (C) Photon Vision. 003 * 004 * This program is free software: you can redistribute it and/or modify 005 * it under the terms of the GNU General Public License as published by 006 * the Free Software Foundation, either version 3 of the License, or 007 * (at your option) any later version. 008 * 009 * This program is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 * GNU General Public License for more details. 013 * 014 * You should have received a copy of the GNU General Public License 015 * along with this program. If not, see <https://www.gnu.org/licenses/>. 016 */ 017 018package org.photonvision.common.configuration; 019 020import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 021import java.util.ArrayList; 022import java.util.Collections; 023import java.util.List; 024 025@JsonIgnoreProperties(ignoreUnknown = true) 026public class HardwareConfig { 027 public final String deviceName; 028 public final String deviceLogoPath; 029 public final String supportURL; 030 031 // LED control 032 public final ArrayList<Integer> ledPins; 033 public final String ledSetCommand; 034 public final boolean ledsCanDim; 035 public final ArrayList<Integer> ledBrightnessRange; 036 public final String ledDimCommand; 037 public final String ledBlinkCommand; 038 public final ArrayList<Integer> statusRGBPins; 039 040 // Metrics 041 public final String cpuTempCommand; 042 public final String cpuMemoryCommand; 043 public final String cpuUtilCommand; 044 public final String cpuThrottleReasonCmd; 045 public final String cpuUptimeCommand; 046 public final String gpuMemoryCommand; 047 public final String ramUtilCommand; 048 public final String gpuMemUsageCommand; 049 public final String diskUsageCommand; 050 051 // Device stuff 052 public final String restartHardwareCommand; 053 public final double vendorFOV; // -1 for unmanaged 054 public final List<Integer> blacklistedResIndices; // this happens before the defaults are applied 055 056 public HardwareConfig() { 057 deviceName = ""; 058 deviceLogoPath = ""; 059 supportURL = ""; 060 ledPins = new ArrayList<>(); 061 ledSetCommand = ""; 062 ledsCanDim = false; 063 ledBrightnessRange = new ArrayList<>(); 064 statusRGBPins = new ArrayList<>(); 065 ledDimCommand = ""; 066 067 cpuTempCommand = ""; 068 cpuMemoryCommand = ""; 069 cpuUtilCommand = ""; 070 cpuThrottleReasonCmd = ""; 071 cpuUptimeCommand = ""; 072 gpuMemoryCommand = ""; 073 ramUtilCommand = ""; 074 ledBlinkCommand = ""; 075 gpuMemUsageCommand = ""; 076 diskUsageCommand = ""; 077 078 restartHardwareCommand = ""; 079 vendorFOV = -1; 080 blacklistedResIndices = Collections.emptyList(); 081 } 082 083 @SuppressWarnings("unused") 084 public HardwareConfig( 085 String deviceName, 086 String deviceLogoPath, 087 String supportURL, 088 ArrayList<Integer> ledPins, 089 String ledSetCommand, 090 boolean ledsCanDim, 091 ArrayList<Integer> ledBrightnessRange, 092 String ledDimCommand, 093 String ledBlinkCommand, 094 ArrayList<Integer> statusRGBPins, 095 String cpuTempCommand, 096 String cpuMemoryCommand, 097 String cpuUtilCommand, 098 String cpuThrottleReasonCmd, 099 String cpuUptimeCommand, 100 String gpuMemoryCommand, 101 String ramUtilCommand, 102 String gpuMemUsageCommand, 103 String diskUsageCommand, 104 String restartHardwareCommand, 105 double vendorFOV, 106 List<Integer> blacklistedResIndices) { 107 this.deviceName = deviceName; 108 this.deviceLogoPath = deviceLogoPath; 109 this.supportURL = supportURL; 110 this.ledPins = ledPins; 111 this.ledSetCommand = ledSetCommand; 112 this.ledsCanDim = ledsCanDim; 113 this.ledBrightnessRange = ledBrightnessRange; 114 this.ledDimCommand = ledDimCommand; 115 this.ledBlinkCommand = ledBlinkCommand; 116 this.statusRGBPins = statusRGBPins; 117 this.cpuTempCommand = cpuTempCommand; 118 this.cpuMemoryCommand = cpuMemoryCommand; 119 this.cpuUtilCommand = cpuUtilCommand; 120 this.cpuThrottleReasonCmd = cpuThrottleReasonCmd; 121 this.cpuUptimeCommand = cpuUptimeCommand; 122 this.gpuMemoryCommand = gpuMemoryCommand; 123 this.ramUtilCommand = ramUtilCommand; 124 this.gpuMemUsageCommand = gpuMemUsageCommand; 125 this.diskUsageCommand = diskUsageCommand; 126 this.restartHardwareCommand = restartHardwareCommand; 127 this.vendorFOV = vendorFOV; 128 this.blacklistedResIndices = blacklistedResIndices; 129 } 130 131 /** 132 * @return True if the FOV has been preset to a sane value, false otherwise 133 */ 134 public final boolean hasPresetFOV() { 135 return vendorFOV > 0; 136 } 137 138 /** 139 * @return True if any command has been configured to a non-default empty, false otherwise 140 */ 141 public final boolean hasCommandsConfigured() { 142 return cpuTempCommand != "" 143 || cpuMemoryCommand != "" 144 || cpuUtilCommand != "" 145 || cpuThrottleReasonCmd != "" 146 || cpuUptimeCommand != "" 147 || gpuMemoryCommand != "" 148 || ramUtilCommand != "" 149 || ledBlinkCommand != "" 150 || gpuMemUsageCommand != "" 151 || diskUsageCommand != ""; 152 } 153 154 @Override 155 public String toString() { 156 return "HardwareConfig [deviceName=" 157 + deviceName 158 + ", deviceLogoPath=" 159 + deviceLogoPath 160 + ", supportURL=" 161 + supportURL 162 + ", ledPins=" 163 + ledPins 164 + ", ledSetCommand=" 165 + ledSetCommand 166 + ", ledsCanDim=" 167 + ledsCanDim 168 + ", ledBrightnessRange=" 169 + ledBrightnessRange 170 + ", ledDimCommand=" 171 + ledDimCommand 172 + ", ledBlinkCommand=" 173 + ledBlinkCommand 174 + ", statusRGBPins=" 175 + statusRGBPins 176 + ", cpuTempCommand=" 177 + cpuTempCommand 178 + ", cpuMemoryCommand=" 179 + cpuMemoryCommand 180 + ", cpuUtilCommand=" 181 + cpuUtilCommand 182 + ", cpuThrottleReasonCmd=" 183 + cpuThrottleReasonCmd 184 + ", cpuUptimeCommand=" 185 + cpuUptimeCommand 186 + ", gpuMemoryCommand=" 187 + gpuMemoryCommand 188 + ", ramUtilCommand=" 189 + ramUtilCommand 190 + ", gpuMemUsageCommand=" 191 + gpuMemUsageCommand 192 + ", diskUsageCommand=" 193 + diskUsageCommand 194 + ", restartHardwareCommand=" 195 + restartHardwareCommand 196 + ", vendorFOV=" 197 + vendorFOV 198 + ", blacklistedResIndices=" 199 + blacklistedResIndices 200 + "]"; 201 } 202}