Search in sources :

Example 1 with CommConfig

use of us.mn.state.dot.tms.CommConfig in project iris by mnit-rtmc.

the class CommConfigModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<CommConfig>> createColumns() {
    ArrayList<ProxyColumn<CommConfig>> cols = new ArrayList<ProxyColumn<CommConfig>>(9);
    cols.add(new ProxyColumn<CommConfig>("comm.config", 60) {

        public Object getValueAt(CommConfig cc) {
            return cc.getName();
        }
    });
    cols.add(new ProxyColumn<CommConfig>("device.description", 220) {

        public Object getValueAt(CommConfig cc) {
            return cc.getDescription();
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "description");
        }

        public void setValueAt(CommConfig cc, Object value) {
            cc.setDescription(value.toString().trim());
        }
    });
    cols.add(new ProxyColumn<CommConfig>("comm.config.protocol", 140) {

        public Object getValueAt(CommConfig cc) {
            return CommProtocol.fromOrdinal(cc.getProtocol());
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "protocol");
        }

        public void setValueAt(CommConfig cc, Object value) {
            if (value instanceof CommProtocol) {
                CommProtocol cp = (CommProtocol) value;
                cc.setProtocol((short) cp.ordinal());
            }
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<CommProtocol> cbx = new JComboBox<CommProtocol>(CommProtocol.valuesSorted());
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<CommConfig>("comm.config.modem", 56, Boolean.class) {

        public Object getValueAt(CommConfig cc) {
            return cc.getModem();
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "modem");
        }

        public void setValueAt(CommConfig cc, Object value) {
            if (value instanceof Boolean)
                cc.setModem((Boolean) value);
        }
    });
    cols.add(new ProxyColumn<CommConfig>("comm.config.timeout_ms", 60) {

        public Object getValueAt(CommConfig cc) {
            return cc.getTimeoutMs();
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "timeoutMs");
        }

        public void setValueAt(CommConfig cc, Object value) {
            if (value instanceof Integer)
                cc.setTimeoutMs((Integer) value);
        }

        protected TableCellEditor createCellEditor() {
            return new TimeoutCellEditor(MAX_TIMEOUT_MS);
        }
    });
    cols.add(new PeriodColumn("comm.config.poll_period_sec", CommConfig.VALID_PERIODS, 92) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getPollPeriodSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setPollPeriodSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "pollPeriodSec");
        }
    });
    cols.add(new PeriodColumn("comm.config.long_poll_period_sec", CommConfig.VALID_PERIODS, 92) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getLongPollPeriodSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setLongPollPeriodSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "longPollPeriodSec");
        }
    });
    cols.add(new PeriodColumn("comm.config.idle_disconnect_sec", CommConfig.VALID_DISCONNECT, 108) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getIdleDisconnectSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setIdleDisconnectSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "idleDisconnectSec");
        }
    });
    cols.add(new PeriodColumn("comm.config.no_response_disconnect_sec", CommConfig.VALID_DISCONNECT, 108) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getNoResponseDisconnectSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setNoResponseDisconnectSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "noResponseDisconnectSec");
        }
    });
    return cols;
}
Also used : JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) DefaultCellEditor(javax.swing.DefaultCellEditor) CommProtocol(us.mn.state.dot.tms.CommProtocol) TableCellEditor(javax.swing.table.TableCellEditor) CommConfig(us.mn.state.dot.tms.CommConfig) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn)

Example 2 with CommConfig

use of us.mn.state.dot.tms.CommConfig in project iris by mnit-rtmc.

the class CommLinkModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<CommLink>> createColumns() {
    ArrayList<ProxyColumn<CommLink>> cols = new ArrayList<ProxyColumn<CommLink>>(6);
    cols.add(new ProxyColumn<CommLink>("comm.link", 80) {

        public Object getValueAt(CommLink cl) {
            return cl.getName();
        }
    });
    cols.add(new ProxyColumn<CommLink>("device.description", 220) {

        public Object getValueAt(CommLink cl) {
            return cl.getDescription();
        }

        public boolean isEditable(CommLink cl) {
            return canWrite(cl, "description");
        }

        public void setValueAt(CommLink cl, Object value) {
            cl.setDescription(value.toString().trim());
        }
    });
    cols.add(new ProxyColumn<CommLink>("comm.link.uri", 280) {

        public Object getValueAt(CommLink cl) {
            return cl.getUri();
        }

        public boolean isEditable(CommLink cl) {
            return canWrite(cl, "uri");
        }

        public void setValueAt(CommLink cl, Object value) {
            cl.setUri(value.toString().trim());
        }
    });
    cols.add(new ProxyColumn<CommLink>("comm.link.poll_enabled", 56, Boolean.class) {

        public Object getValueAt(CommLink cl) {
            return cl.getPollEnabled();
        }

        public boolean isEditable(CommLink cl) {
            return canWrite(cl, "pollEnabled");
        }

        public void setValueAt(CommLink cl, Object value) {
            if (value instanceof Boolean)
                cl.setPollEnabled((Boolean) value);
        }
    });
    cols.add(new ProxyColumn<CommLink>("comm.link.connected", 50) {

        public Object getValueAt(CommLink cl) {
            return cl.getConnected();
        }

        protected TableCellRenderer createCellRenderer() {
            return new ConnectedCellRenderer();
        }
    });
    cols.add(new ProxyColumn<CommLink>("comm.config", 180) {

        public Object getValueAt(CommLink cl) {
            return cl.getCommConfig();
        }

        public boolean isEditable(CommLink cl) {
            return canWrite(cl, "commConfig");
        }

        public void setValueAt(CommLink cl, Object value) {
            if (value instanceof CommConfig) {
                CommConfig cc = (CommConfig) value;
                cl.setCommConfig(cc);
            }
        }

        @Override
        protected TableCellEditor createCellEditor() {
            JComboBox<CommConfig> cbx = new JComboBox<CommConfig>();
            cbx.setModel(new IComboBoxModel<CommConfig>(comm_config_mdl));
            cbx.setRenderer(new CommConfigListRenderer());
            return new DefaultCellEditor(cbx);
        }

        @Override
        protected TableCellRenderer createCellRenderer() {
            return new CommConfigTableRenderer();
        }
    });
    return cols;
}
Also used : CommLink(us.mn.state.dot.tms.CommLink) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) DefaultCellEditor(javax.swing.DefaultCellEditor) IComboBoxModel(us.mn.state.dot.tms.client.widget.IComboBoxModel) TableCellEditor(javax.swing.table.TableCellEditor) CommConfig(us.mn.state.dot.tms.CommConfig) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn)

Example 3 with CommConfig

use of us.mn.state.dot.tms.CommConfig in project iris by mnit-rtmc.

the class CommLinkModel method createAttrs.

/**
 * Create a mapping of attributes
 */
private HashMap<String, Object> createAttrs() {
    if (comm_config_mdl.getSize() > 0) {
        CommConfig cc = comm_config_mdl.getProxy(0);
        HashMap<String, Object> attrs = new HashMap<String, Object>();
        attrs.put("comm_config", cc);
        return attrs;
    } else
        return null;
}
Also used : HashMap(java.util.HashMap) CommConfig(us.mn.state.dot.tms.CommConfig)

Example 4 with CommConfig

use of us.mn.state.dot.tms.CommConfig in project iris by mnit-rtmc.

the class CommLinkForm method updateCommConfig.

/**
 * Update the comm config
 */
private void updateCommConfig() {
    CommLink cl = watcher.getProxy();
    CommConfig cc = (cl != null) ? cl.getCommConfig() : null;
    config_pnl.setProxy(cc);
}
Also used : CommLink(us.mn.state.dot.tms.CommLink) CommConfig(us.mn.state.dot.tms.CommConfig)

Example 5 with CommConfig

use of us.mn.state.dot.tms.CommConfig in project iris by mnit-rtmc.

the class OpDms method calcTimeoutMS.

/**
 * Get the timeout for this operation
 */
private int calcTimeoutMS() {
    CommConfig cc = controller.getCommLink().getCommConfig();
    int s = cc.getNoResponseDisconnectSec();
    LOG.log("Op timeout is " + s + " secs, dms=" + m_dms);
    return s * 1000;
}
Also used : CommConfig(us.mn.state.dot.tms.CommConfig)

Aggregations

CommConfig (us.mn.state.dot.tms.CommConfig)5 ArrayList (java.util.ArrayList)2 DefaultCellEditor (javax.swing.DefaultCellEditor)2 JComboBox (javax.swing.JComboBox)2 TableCellEditor (javax.swing.table.TableCellEditor)2 CommLink (us.mn.state.dot.tms.CommLink)2 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)2 HashMap (java.util.HashMap)1 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1 TableCellRenderer (javax.swing.table.TableCellRenderer)1 CommProtocol (us.mn.state.dot.tms.CommProtocol)1 IComboBoxModel (us.mn.state.dot.tms.client.widget.IComboBoxModel)1