Get Weight & Set Scale to Zero

DataWedge 14.1

GET_WEIGHT & SET_SCALE_TO_ZERO

Introduced in DataWedge 11.4.

GET_WEIGHT

Retrieve the weight of the object on the connected MP7000 scale., then reset the scale to zero to ready it for weighing the next object.

SET_SCALE_TO_ZERO

Reset the weight scale to zero to ready it for weighing the next object.

Function Prototype

    Bundle bundleScale = new Bundle();
    Bundle bundleScaleConfig = new Bundle();
    bundleScaleConfig.putString("DEVICE_IDENTIFIER", "<scanner_identifier>");
    bundleScaleConfig.putString("COMMAND", "<command>");
    bundleScale.putBundle("SCALE_CONFIG", bundleScaleConfig);

    Intent i = new Intent();
    i.setAction("com.symbol.datawedge.api.ACTION");
    i.setPackage("com.symbol.datawedge.api.ACTION");
    i.putExtra("SEND_RESULT","true");
    i.putExtra("com.symbol.datawedge.api.SCALE", bundleScale);

Parameters

ACTION [String]: "com.symbol.datawedge.api.ACTION"

PACKAGE [String]: "com.symbol.datawedge"

EXTRA_DATA [Bundle]: "com.symbol.datawedge.api.SCALE"

COMMAND [String]: “SET_SCALE_TO_ZERO” or “GET_WEIGHT”

DEVICE_IDENTIFIER [String]: "USB_TGCS_MP7000"

Return Values

If the application uses the DataWedge result intent mechanism by incorporating the intent extras SEND_RESULT and COMMAND_IDENTIFIER, the following are the possible error codes returned:

  • SCALE_NOT_CONNECTED – The MP7000 Scanner is not connected to the mobile computer.
  • SCALE_IN_MOTION – The scale is not stable.
  • SCALE_HARDWARE_ERROR – Hardware-related error.
  • SCALE_READ_TIMEOUT – The scale was unable to read the weight within an acceptable time frame.
  • SCALE_OVER_CAPACITY – The scale is overweight.
  • SCALE_UNKNOWN_ERROR – There is an unknown error.
  • SCANNER_IN_INVALID_STATE – The scanner is not in the correct state to query the weight.
  • FAILED_TO_SET_SCANNER_TO_ZERO – Resetting the scale to zero failed.

Example Code

Get Weight

    void getWeightAPICall()
    {
        Bundle bundleScale = new Bundle();
        Bundle bundleScaleConfig = new Bundle();
        bundleScaleConfig.putString("DEVICE_IDENTIFIER", "USB_TGCS_MP7000");
        bundleScaleConfig.putString("COMMAND", "GET_WEIGHT");
        bundleScale.putBundle("SCALE_CONFIG", bundleScaleConfig);

        Intent i = new Intent();
        i.setAction(DATAWEDGE_API_ACTION);
        i.setPackage(DATAWEDGE_PACKAGE);
        i.putExtra("SEND_RESULT","true");
        i.putExtra("com.symbol.datawedge.api.SCALE", bundleScale);
        sendBroadcast(i);
    }

Set Scale to Zero

    void setScaleZeroAPICall()
    {
        Bundle bundleScale = new Bundle();
        Bundle bundleScaleConfig = new Bundle();
        bundleScaleConfig.putString("DEVICE_IDENTIFIER", "USB_TGCS_MP7000");
        bundleScaleConfig.putString("COMMAND", "SET_SCALE_TO_ZERO");
        bundleScale.putBundle("SCALE_CONFIG", bundleScaleConfig);

        Intent i = new Intent();
        i.setAction(DATAWEDGE_API_ACTION);
        i.setPackage(DATAWEDGE_PACKAGE);
        i.putExtra("SEND_RESULT","true");
        i.putExtra("com.symbol.datawedge.api.SCALE", bundleScale);
        sendBroadcast(i);
    }

SEE ALSO:

Zebra Support Central | Integrator Guides, Product Manuals, Software Downloads and Support

LaunchPad | Zebra Developer Community

Intent | Android Developers

Intents and Intent Filters | Android Developers

Android Intents | Tutorial