Search in sources :

Example 1 with DmsSignGroup

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

the class QuickMessageCBox method createMessageSet.

/**
 * Create a set of quick messages for the specified DMS
 */
private TreeSet<QuickMessage> createMessageSet(DMS dms) {
    TreeSet<QuickMessage> msgs = new TreeSet<QuickMessage>(new NumericAlphaComparator<QuickMessage>());
    Iterator<DmsSignGroup> it = DmsSignGroupHelper.iterator();
    while (it.hasNext()) {
        DmsSignGroup dsg = it.next();
        if (dsg.getDms() == dms) {
            SignGroup sg = dsg.getSignGroup();
            Iterator<QuickMessage> qit = QuickMessageHelper.iterator();
            while (qit.hasNext()) {
                QuickMessage qm = qit.next();
                if (qm.getSignGroup() == sg) {
                    if (isValidMulti(qm))
                        msgs.add(qm);
                }
            }
        }
    }
    return msgs;
}
Also used : SignGroup(us.mn.state.dot.tms.SignGroup) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) TreeSet(java.util.TreeSet) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) QuickMessage(us.mn.state.dot.tms.QuickMessage)

Example 2 with DmsSignGroup

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

the class WMsgSelectorForm method getSingleSignGroup.

/**
 * Get the single-sign sign group for a sign. If it does not exist,
 *  it is created.
 */
public static SignGroup getSingleSignGroup(Session s, DMS sign) {
    SignGroup sg = SignGroupHelper.lookup(sign.getName());
    if (sg == null) {
        // if we don't, add one
        TypeCache<SignGroup> sgCache = s.getSonarState().getDmsCache().getSignGroups();
        HashMap<String, Object> sgAttrs = new HashMap<String, Object>();
        sgAttrs.put("local", true);
        sgCache.createObject(sign.getName(), sgAttrs);
        // also a DMS sign group
        TypeCache<DmsSignGroup> dsgCache = s.getSonarState().getDmsCache().getDmsSignGroups();
        sg = SignGroupHelper.lookup(sign.getName());
        HashMap<String, Object> attrs = new HashMap<String, Object>();
        String oname = sign.getName() + "_" + sign.getName();
        attrs.put("dms", sign);
        attrs.put("sign_group", sg);
        dsgCache.createObject(oname, attrs);
    }
    return sg;
}
Also used : SignGroup(us.mn.state.dot.tms.SignGroup) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) HashMap(java.util.HashMap) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup)

Example 3 with DmsSignGroup

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

the class ActionPlanImpl method isDeployable.

/**
 * Check if a DMS action is deployable
 */
private boolean isDeployable(DmsAction da) {
    SignGroup sg = da.getSignGroup();
    Iterator<DmsSignGroup> it = DmsSignGroupHelper.iterator();
    while (it.hasNext()) {
        DmsSignGroup dsg = it.next();
        if (dsg.getSignGroup() == sg) {
            DMS dms = dsg.getDms();
            if (dms instanceof DMSImpl) {
                if (((DMSImpl) dms).hasError())
                    return false;
            }
        }
    }
    return true;
}
Also used : SignGroup(us.mn.state.dot.tms.SignGroup) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) DMS(us.mn.state.dot.tms.DMS)

Example 4 with DmsSignGroup

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

the class MultiConfig method from.

/**
 * Create a MultiConfig tree from a SignGroup object.
 */
public static MultiConfig from(SignGroup sg) {
    if (sg == null)
        return fromErrorMsg("Unable to load a null SignGroup configuration");
    if ((sg.getName() == null) || sg.getName().isEmpty())
        return fromErrorMsg("Unable to load a nameless SignGroup configuration");
    // build an array list of sign MultiConfig objects
    MultiConfig mcSign;
    DmsSignGroup dsg;
    DMS dms;
    Iterator<DmsSignGroup> it = DmsSignGroupHelper.iterator();
    ArrayList<MultiConfig> mcaSigns = new ArrayList<MultiConfig>();
    while (it.hasNext()) {
        dsg = it.next();
        if (dsg.getSignGroup() == sg) {
            dms = dsg.getDms();
            if (dms == null)
                continue;
            try {
                mcSign = from(dms);
                if (mcSign == null)
                    continue;
                mcaSigns.add(mcSign);
            } catch (TMSException e) {
                // Should never happen...
                e.printStackTrace();
            }
        }
    }
    if (mcaSigns.isEmpty())
        return fromErrorMsg("Unable to load any configurations for sign group " + sg.getName());
    // Sort and group the sign-MultiConfigs,
    // creating a new config-MultiConfig for
    // each set of identical signs.
    ArrayList<MultiConfig> mcaConfigs;
    mcaConfigs = sortAndGroup(mcaSigns);
    if (mcaConfigs.isEmpty())
        return null;
    // Create a primary SignGroup-MultiConfig
    // based on the most common config in
    // in the SignGroup.
    MultiConfig mcConfig = mcaConfigs.get(0);
    MultiConfig mcSignGroup = fromSignName(mcConfig.name, SIGNGROUP);
    mcSignGroup.name = sg.getName();
    mcSignGroup.configList = mcaConfigs;
    // Sort final list of sign MultiConfigs by sign name
    mcaSigns.sort(compareByName);
    mcSignGroup.signList = mcaSigns;
    // Rename config MultiConfigs based on
    // position in list and number of signs
    // in each config.
    int cfgNo = 1;
    int cnt;
    String suffix;
    boolean oneGood = false;
    for (MultiConfig mc : mcaConfigs) {
        if (mc.signList != null) {
            cnt = mc.signList.size();
            suffix = (cnt == 1) ? " sign)" : " signs)";
            mc.name = CONFIG + "_" + cfgNo + " (" + cnt + suffix;
        } else {
            // This "shouldn't be possible", but...
            mc.name = CONFIG + "_" + cfgNo + " (no signs)";
        }
        if (mc.isUseable())
            oneGood = true;
        ++cfgNo;
    }
    if (oneGood) {
        mcSignGroup.clearErrors();
    }
    return mcSignGroup;
}
Also used : TMSException(us.mn.state.dot.tms.TMSException) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) ArrayList(java.util.ArrayList) DMS(us.mn.state.dot.tms.DMS)

Example 5 with DmsSignGroup

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

the class PlanDispatcher method countDMS.

/**
 * Get a count of DMS controlled by an action plan
 */
private int countDMS(ActionPlan p) {
    HashSet<SignGroup> plan_groups = new HashSet<SignGroup>();
    Iterator<DmsAction> dit = DmsActionHelper.iterator();
    while (dit.hasNext()) {
        DmsAction da = dit.next();
        if (da.getActionPlan() == p)
            plan_groups.add(da.getSignGroup());
    }
    HashSet<DMS> plan_signs = new HashSet<DMS>();
    Iterator<DmsSignGroup> git = DmsSignGroupHelper.iterator();
    while (git.hasNext()) {
        DmsSignGroup dsg = git.next();
        if (plan_groups.contains(dsg.getSignGroup()))
            plan_signs.add(dsg.getDms());
    }
    return plan_signs.size();
}
Also used : SignGroup(us.mn.state.dot.tms.SignGroup) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) DmsSignGroup(us.mn.state.dot.tms.DmsSignGroup) DMS(us.mn.state.dot.tms.DMS) DmsAction(us.mn.state.dot.tms.DmsAction) HashSet(java.util.HashSet)

Aggregations

DmsSignGroup (us.mn.state.dot.tms.DmsSignGroup)6 SignGroup (us.mn.state.dot.tms.SignGroup)5 DMS (us.mn.state.dot.tms.DMS)4 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 DmsAction (us.mn.state.dot.tms.DmsAction)1 QuickMessage (us.mn.state.dot.tms.QuickMessage)1 TMSException (us.mn.state.dot.tms.TMSException)1