private void initializeReceiverData(long receiverId) { if (receiverId == -1) { // init blank brandListView.setItemChecked(0, true); updateModelList(brandListView.getSelectedItem().toString()); modelListView.setItemChecked(0, true); } else { try { // init existing receiver final Receiver receiver = DatabaseHandler.getReceiver(receiverId); int brandPosition = brandNamesAdapter.getPosition(receiver.getBrand().getName()); brandListView.setItemChecked(brandPosition, true); brandListView.smoothScrollToPosition(brandPosition); updateModelList(receiver.getBrand().getName()); int modelPosition = modelNamesAdapter.getPosition(receiver.getModel()); modelListView.setItemChecked(modelPosition, true); modelListView.smoothScrollToPosition(modelPosition); } catch (Exception e) { StatusMessageHandler.showErrorMessage(getActivity(), e); } } }
public class CMR1224 extends CMR1000 implements MasterSlaveReceiver { private static final String MODEL = Receiver.getModelName(CMR1224.class.getCanonicalName()); public CMR1224( Context context, Long id, String name, char channelMaster, int channelSlave, Long roomId) { super(context, id, name, channelMaster, channelSlave, roomId); model = MODEL; } @Override public String getSignal(Gateway gateway, String action) throws GatewayNotSupportedException, ActionNotSupportedException { return super.getSignal(gateway, action); } }
public class Telecontrol extends Receiver implements MasterSlaveReceiver { private static final Brand BRAND = Brand.REV; static String MODEL = Receiver.getModelName(Telecontrol.class.getCanonicalName()); private String tx433version = "1,"; private String sSpeedConnAir = "16"; private String headConnAir = "TXP:0,0,10,5600,350,25,"; private String tailConnAir = tx433version + sSpeedConnAir + ";"; private String sSpeedITGW = "32,"; private String headITGW = "0,0,10,11200,350,26,0,"; private String tailITGW = tx433version + sSpeedITGW + "0"; private Character channelMaster; private int channelSlave; public Telecontrol( Context context, Long id, String name, char channelMaster, int channelSlave, Long roomId) { super(context, id, name, BRAND, MODEL, Type.MASTER_SLAVE, roomId); buttons.add(new OnButton(context, id)); buttons.add(new OffButton(context, id)); this.channelMaster = channelMaster; this.channelSlave = channelSlave; } public ArrayList<String> getMasterNames() { ArrayList<String> m = new ArrayList<>(); m.add("A"); m.add("B"); m.add("C"); m.add("D"); return m; } public ArrayList<String> getSlaveNames() { ArrayList<String> s = new ArrayList<>(); s.add("1"); s.add("2"); s.add("3"); return s; } @Override public String getSignal(Gateway gateway, String action) throws GatewayNotSupportedException, ActionNotSupportedException { boolean actionSupported = false; for (Button button : buttons) { if (button.getName().equals(action)) { actionSupported = true; break; } } if (!actionSupported) { throw new ActionNotSupportedException(action); } String lo = "1,"; String hi = "3,"; String seqHi = hi + lo + hi + lo; String seqLo = lo + hi + lo + hi; String seqFl = lo + hi + hi + lo; String h = seqFl; String l = seqHi; String on = seqFl + seqFl; String off = seqLo + seqLo; String additional = seqLo + seqFl + seqFl; // switch channelMaster (character) String master = ""; switch (channelMaster) { case 'A': master = l + h + h + h; break; case 'B': master = h + l + h + h; break; case 'C': master = h + h + l + h; break; case 'D': master = h + h + h + l; break; default: Log.e("Switch", "No Matching Master"); break; } // switch channelSlave (number) String slave = ""; switch (channelSlave) { case 1: slave = l + h + h; break; case 2: slave = h + l + h; break; case 3: slave = h + h + l; break; default: Log.e("Switch", "No Matching Slave"); break; } if (gateway instanceof ConnAir) { if (action.equals(context.getString(R.string.on))) { String ON = headConnAir + master + slave + additional + on + tailConnAir; return ON; } else { String OFF = headConnAir + master + slave + additional + off + tailConnAir; return OFF; } } else if (gateway instanceof BrematicGWY433) { if (action.equals(context.getString(R.string.on))) { String ON = headConnAir + master + slave + additional + on + tailConnAir; return ON; } else { String OFF = headConnAir + master + slave + additional + off + tailConnAir; return OFF; } } else if (gateway instanceof ITGW433) { if (action.equals(context.getString(R.string.on))) { String ON = headITGW + master + slave + additional + on + tailITGW; return ON; } else { String OFF = headITGW + master + slave + additional + off + tailITGW; return OFF; } } else { throw new GatewayNotSupportedException(); } } @Override public char getMaster() { return channelMaster; } @Override public int getSlave() { return channelSlave; } }