001package jmri.jmrix.can.cbus.swing.modules.merg; 002 003import java.util.*; 004 005import javax.annotation.Nonnull; 006 007import jmri.jmrix.can.cbus.node.CbusNode; 008import jmri.jmrix.can.cbus.node.CbusNodeNVTableDataModel; 009import jmri.jmrix.can.cbus.swing.modules.*; 010 011import org.openide.util.lookup.ServiceProvider; 012 013/** 014 * Returns configuration objects for a MERG CANACC8 015 * 016 * @author Andrew Crosland Copyright (C) 2021 017 */ 018@ServiceProvider(service = CbusConfigPaneProvider.class) 019public class Canacc8PaneProvider extends CbusConfigPaneProvider { 020 021 String type = "CANACC8"; 022 023 public static final int OUTPUT1 = 1; 024 public static final int OUTPUT2 = 2; 025 public static final int OUTPUT3 = 3; 026 public static final int OUTPUT4 = 4; 027 public static final int OUTPUT5 = 5; 028 public static final int OUTPUT6 = 6; 029 public static final int OUTPUT7 = 7; 030 public static final int OUTPUT8 = 8; 031 public static final int FEEDBACK_DELAY = 9; 032 public static final int STARTUP_POSITION = 10; 033 public static final int STARTUP_MOVE = 11; 034 035 public Canacc8PaneProvider() { 036 super(); 037 } 038 039 /** {@inheritDoc} */ 040 @Override 041 @Nonnull 042 public String getModuleType() { 043 return type; 044 } 045 046 /** 047 * Hashmap for decoding NV names 048 */ 049 private static final Map<Integer, String> nvMap = createNvMap(); 050 051 /* 052 * Populate hashmap with nv strings 053 * 054 */ 055 private static Map<Integer, String> createNvMap() { 056 Map<Integer, String> result = new HashMap<>(); 057 result.put(0, "Error - invalid NV index"); 058 result.put(OUTPUT1, Bundle.getMessage("OutputX", 1)); 059 result.put(OUTPUT2, Bundle.getMessage("OutputX", 2)); 060 result.put(OUTPUT3, Bundle.getMessage("OutputX", 3)); 061 result.put(OUTPUT4, Bundle.getMessage("OutputX", 4)); 062 result.put(OUTPUT5, Bundle.getMessage("OutputX", 5)); 063 result.put(OUTPUT6, Bundle.getMessage("OutputX", 6)); 064 result.put(OUTPUT7, Bundle.getMessage("OutputX", 7)); 065 result.put(OUTPUT8, Bundle.getMessage("OutputX", 8)); 066 result.put(FEEDBACK_DELAY, Bundle.getMessage("FeedbackDelay")); 067 result.put(STARTUP_POSITION, Bundle.getMessage("StartupPosition")); 068 result.put(STARTUP_MOVE, Bundle.getMessage("StartupMove")); 069 return Collections.unmodifiableMap(result); 070 } 071 072 /** {@inheritDoc} */ 073 @Override 074 public String getNVNameByIndex(int index) { 075 // look for the NV 076 String nv = nvMap.get(index); 077 if (nv == null) { 078 return Bundle.getMessage("UnknownNv"); 079 } else { 080 return nv; 081 } 082 } 083 084 /** {@inheritDoc} */ 085 @Override 086 public AbstractEditNVPane getEditNVFrameInstance() { 087 return _nVarEditFrame; 088 } 089 090 /** {@inheritDoc} */ 091 @Override 092 public AbstractEditNVPane getEditNVFrame(CbusNodeNVTableDataModel dataModel, CbusNode node) { 093 _nVarEditFrame = new Canacc8EditNVPane(dataModel, node); 094 return _nVarEditFrame.getContent(); 095 } 096}