Esempio n. 1
0
 public static string GetNameFromStatus(DymoScaleStatus status)
 {
     switch (status)
     {
         case DymoScaleStatus.Fault: return "Fault";
         case DymoScaleStatus.StableAtZero: return "Stable at Zero";
         case DymoScaleStatus.InMotion: return "In Motion";
         case DymoScaleStatus.Stable: return "Stable";
         case DymoScaleStatus.StableUnderZero: return "Stable under Zero";
         case DymoScaleStatus.OverWeight: return "Over Weight";
         case DymoScaleStatus.RequiresCalibration: return "Requires Calibration";
         case DymoScaleStatus.RequiresRezeroing: return "Requires Re-zeroing";
         default: return "Unknown Error";
     }
 }
Esempio n. 2
0
        public static string GetNameFromStatus(DymoScaleStatus status)
        {
            switch (status)
            {
            case DymoScaleStatus.Fault: return("Fault");

            case DymoScaleStatus.StableAtZero: return("Stable at Zero");

            case DymoScaleStatus.InMotion: return("In Motion");

            case DymoScaleStatus.Stable: return("Stable");

            case DymoScaleStatus.StableUnderZero: return("Stable under Zero");

            case DymoScaleStatus.OverWeight: return("Over Weight");

            case DymoScaleStatus.RequiresCalibration: return("Requires Calibration");

            case DymoScaleStatus.RequiresRezeroing: return("Requires Re-zeroing");

            default: return("Unknown Error");
            }
        }
Esempio n. 3
0
        public void ReadSample(out int value, out int exponent, out DymoScaleUnit unit, out DymoScaleStatus status,
                               out bool buffered)
        {
            if (Stream == null)
            {
                throw new InvalidOperationException("Stream not set.");
            }
            buffered = true;

            while (_offset < ReportLength)
            {
                buffered = false;
                int count = Stream.Read(_buffer, _offset, _buffer.Length - _offset);
                _offset += count;
            }

            ParseSample(_buffer, 0, out value, out exponent, out unit, out status);
            Array.Copy(_buffer, ReportLength, _buffer, 0, _offset - ReportLength); _offset -= ReportLength;
        }
Esempio n. 4
0
        public void ParseSample(byte[] buffer, int offset,
                                out int value, out int exponent, out DymoScaleUnit unit, out DymoScaleStatus status)
        {
            value = 0; exponent = 0; unit = 0; status = 0;
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (offset < 0 || buffer.Length - offset < ReportLength)
            {
                throw new ArgumentException("Not enough bytes.", "offset");
            }
            if (buffer[offset + 0] != ReportID)
            {
                throw new IOException("Unexpected report ID.");
            }

            value = (int)(buffer[offset + 4] | buffer[offset + 5] << 8);

            status = (DymoScaleStatus)buffer[offset + 1]; if (status == DymoScaleStatus.StableUnderZero)
            {
                value = -value;
            }
            unit     = (DymoScaleUnit)buffer[offset + 2];
            exponent = (sbyte)buffer[offset + 3];
        }
Esempio n. 5
0
        public void ReadSample(out int value, out int exponent, out DymoScaleUnit unit, out DymoScaleStatus status,
            out bool buffered)
        {
            if (Stream == null) { throw new InvalidOperationException("Stream not set."); }
            buffered = true;

            while (_offset < ReportLength)
            {
                buffered = false;
                int count = Stream.Read(_buffer, _offset, _buffer.Length - _offset);
                _offset += count;
            }

            ParseSample(_buffer, 0, out value, out exponent, out unit, out status);
            Array.Copy(_buffer, ReportLength, _buffer, 0, _offset - ReportLength); _offset -= ReportLength;
        }
Esempio n. 6
0
        public void ParseSample(byte[] buffer, int offset,
            out int value, out int exponent, out DymoScaleUnit unit, out DymoScaleStatus status)
        {
            value = 0; exponent = 0; unit = 0; status = 0;
            if (buffer == null) { throw new ArgumentNullException("buffer"); }
            if (offset < 0 || buffer.Length - offset < ReportLength) { throw new ArgumentException("Not enough bytes.", "offset"); }
            if (buffer[offset + 0] != ReportID) { throw new IOException("Unexpected report ID."); }

            value = (int)(buffer[offset + 4] | buffer[offset + 5] << 8);

            status = (DymoScaleStatus)buffer[offset + 1]; if (status == DymoScaleStatus.StableUnderZero) { value = -value; }
            unit = (DymoScaleUnit)buffer[offset + 2];
            exponent = (sbyte)buffer[offset + 3];
        }