All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.nodes.client.view.AspectMappingUtils Maven / Gradle / Ivy

package org.bidib.wizard.nodes.client.view;

import org.bidib.jbidibc.messages.utils.ProductUtils;

public final class AspectMappingUtils {

    public static String prepareAspectMapping(
        long uniqueId, Integer accessoryNumber, Integer aspectNumber, Integer dccAddress, Integer dccAspect) {
        // prepare the aspect mapping write
        int vid = ProductUtils.getVendorId(uniqueId);
        int pid = getPid(uniqueId);
        int serial = getSerial(uniqueId);
        return String
            .format("%1$02x%2$04x%3$04x %4$d %5$d %6$d %7$d", vid, pid, serial, accessoryNumber, aspectNumber,
                dccAddress, dccAspect);
    }

    /**
     * Get the product id from the unique id.
     * 
     * @param uniqueId
     *            the unique id
     * @return the product id
     */
    public static int getPid(long uniqueId) {

        long pid = (uniqueId >> 16) & 0xffffL;
        return (int) pid;
    }

    /**
     * Get the serial number from the unique id.
     * 
     * @param uniqueId
     *            the unique id
     * @return the serial number
     */
    public static int getSerial(long uniqueId) {

        long serial = uniqueId & 0xffffL;
        return (int) serial;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy