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.dataflow.websocket; 019 020import java.util.List; 021import java.util.stream.Collectors; 022import org.photonvision.PhotonVersion; 023import org.photonvision.common.configuration.NeuralNetworkModelManager; 024import org.photonvision.common.configuration.PhotonConfiguration; 025import org.photonvision.common.hardware.Platform; 026import org.photonvision.common.networking.NetworkManager; 027import org.photonvision.common.networking.NetworkUtils; 028import org.photonvision.mrcal.MrCalJNILoader; 029import org.photonvision.raspi.LibCameraJNILoader; 030import org.photonvision.vision.processes.VisionModule; 031import org.photonvision.vision.processes.VisionSourceManager; 032 033public class UIPhotonConfiguration { 034 public List<UICameraConfiguration> cameraSettings; 035 public UIProgramSettings settings; 036 037 public UIPhotonConfiguration( 038 UIProgramSettings settings, List<UICameraConfiguration> cameraSettings) { 039 this.cameraSettings = cameraSettings; 040 this.settings = settings; 041 } 042 043 public static UIPhotonConfiguration programStateToUi(PhotonConfiguration c) { 044 return new UIPhotonConfiguration( 045 new UIProgramSettings( 046 new UINetConfig( 047 c.getNetworkConfig(), 048 NetworkUtils.getAllActiveWiredInterfaces(), 049 NetworkManager.getInstance().networkingIsDisabled), 050 new UILightingConfig( 051 c.getHardwareSettings().ledBrightnessPercentage, 052 !c.getHardwareConfig().ledPins.isEmpty()), 053 new UIGeneralSettings( 054 PhotonVersion.versionString, 055 // TODO add support for other types of GPU accel 056 LibCameraJNILoader.isSupported() ? "Zerocopy Libcamera Working" : "", 057 MrCalJNILoader.getInstance().isLoaded(), 058 NeuralNetworkModelManager.getInstance().getModels(), 059 NeuralNetworkModelManager.getInstance().getSupportedBackends(), 060 c.getHardwareConfig().deviceName.isEmpty() 061 ? Platform.getHardwareModel() 062 : c.getHardwareConfig().deviceName, 063 Platform.getPlatformName()), 064 c.getApriltagFieldLayout()), 065 VisionSourceManager.getInstance().getVisionModules().stream() 066 .map(VisionModule::toUICameraConfig) 067 .collect(Collectors.toList())); 068 } 069}