Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140package com.microchip.mplab.ipelib;
import com.microchip.crownking.mplabinfo.DeviceSupport;import com.microchip.mplab.libs.packmanagerservice.interfaces.Device;import com.microchip.mplab.libs.packmanagerservice.interfaces.DeviceProvider;import com.microchip.mplab.libs.packmanagerservice.interfaces.MPLABPackContext;import com.microchip.mplab.libs.packmanagerservice.interfaces.PackRelease;import com.microchip.mplab.libs.packmanagerservice.interfaces.PackRepoProvider;import com.microchip.mplab.libs.packmanagerservice.packmanagerservicefactory.PackManagerService;import com.microchip.mplab.logger.MPLABLogger;import java.util.ArrayList;import java.util.List;import java.util.Optional;import java.util.Map.Entry;import java.util.logging.Level;
public final class PackUtils { private final PackRepoProvider packRepoProvider = PackManagerService.getPackRepoProvider(); private final DeviceProvider deviceProvider = PackManagerService.getDeviceProvider(); private static PackUtils packUtils; private MPLABPackContext pack = null;
private PackUtils() { }
public static PackUtils getPackUtils() { if (packUtils == null) { packUtils = new PackUtils(); }
return packUtils; }
public boolean isDeviceDeprecated(String deviceName) { Device deviceInfo = this.packRepoProvider.getDevice(deviceName); boolean isDeprecated = false;
try { isDeprecated = deviceInfo.isDeprecated(); } catch (Exception var5) { MPLABLogger.mplog.log(Level.INFO, var5.toString()); }
return isDeprecated; }
public boolean isPackDeprecated(String deviceName) { boolean packDeprecated = false; MPLABPackContext compatiblePack = this.getInstalledLatestCompatibleDFP(deviceName);
try { packDeprecated = this.packRepoProvider.isPackDeprecated(compatiblePack.getName()); } catch (Exception var5) { MPLABLogger.mplog.log(Level.INFO, var5.toString()); }
return packDeprecated; }
public String getReplacementForDeprecatedPack(String deviceName) { String replacementPackName = "NA"; MPLABPackContext compatiblePack = this.getInstalledLatestCompatibleDFP(deviceName); if (compatiblePack != null) { MPLABPackContext replacementPack = this.packRepoProvider.getReplacementPack(compatiblePack.getName()); if (replacementPack != null) { replacementPackName = replacementPack.getName(); } }
return replacementPackName; }
public MPLABPackContext getInstalledLatestCompatibleDFP(String deviceName) { MPLABPackContext compatiblePack = null;
try { compatiblePack = this.packRepoProvider.getLatestInstalledCompatibleDFP(deviceName, "MPLAB X IDE", this.getMPLABXVersion()); } catch (Exception var4) { MPLABLogger.mplog.log(Level.INFO, var4.toString()); }
return compatiblePack; }
public String getMPLABXVersion() { String version = "0.0"; Optional<Entry<String, String>> mplabVersionInfo = DeviceSupport.getMPLABIPEVersionInfo(); if (mplabVersionInfo.isPresent() && !"0.0".equalsIgnoreCase(mplabVersionInfo.get().getValue())) { version = mplabVersionInfo.get().getValue(); }
return version; }
public String getMPLABXName() { String mplabxName = ""; Optional<Entry<String, String>> mplabVersionInfo = DeviceSupport.getMPLABIPEVersionInfo(); if (mplabVersionInfo.isPresent() && !mplabVersionInfo.get().getKey().isEmpty()) { mplabxName = mplabVersionInfo.get().getKey(); }
return mplabxName; }
public List<PackRelease> getInstalledCompatiblePackReleases(String packName, String deviceName) { new ArrayList(); List<PackRelease> installedCompatiblePacks = new ArrayList<>();
try { for (PackRelease pack : this.packRepoProvider.getInstalledReleases(packName)) { MPLABPackContext packContext = new MPLABPackContext(packName, pack.getVersion(), pack.getVendor()); boolean value = this.packRepoProvider.isPackCompatible(deviceName, packContext, this.getMPLABXName(), this.getMPLABXVersion()); if (value) { installedCompatiblePacks.add(pack); } } } catch (Exception var9) { MPLABLogger.mplog.log(Level.INFO, var9.toString()); }
return installedCompatiblePacks; }
public void UpdateCache() { try { this.packRepoProvider.updateCache(); } catch (Exception var2) { MPLABLogger.mplog.log(Level.INFO, var2.toString()); } }
public void SetPackInfo(String packName, String packVersion, String packVendor) { this.pack = new MPLABPackContext(packName, packVersion, packVendor); }
public MPLABPackContext GetPackInfo() { return this.pack; }}