Пример #1
0
 /// <summary> Prints the specified array of bytes with a given label
 /// if debug mode is enabled.  This method calls
 /// <code>PrintStream.println(String)</code>,
 /// and pre-pends the <code>String</code> ">> " to the message, so
 /// taht if a program were to call (when debug mode was enabled):
 /// <code><pre>
 /// com.dalsemi.onewire.debug.Debug.debug("Some notification...", myBytes, 0, 8);
 /// </pre></code>
 /// the resulting output would look like:
 /// <code><pre>
 /// >> my label
 /// >>   FF F1 F2 F3 F4 F5 F6 FF
 /// </pre></code>
 ///
 /// </summary>
 /// <param name="lbl">the message to print out above the array
 /// </param>
 /// <param name="bytes">the byte array to print out
 /// </param>
 /// <param name="offset">the offset to start printing from the array
 /// </param>
 /// <param name="length">the number of bytes to print from the array
 /// </param>
 public static void  debug(System.String lbl, byte[] bytes, int offset, int length)
 {
     if (DEBUG)
     {
         out_Renamed.Write(">> " + lbl + ", offset=" + offset + ", length=" + length);
         length += offset;
         int  inc       = 8;
         bool printHead = true;
         for (int i = offset; i < length; i += inc)
         {
             if (printHead)
             {
                 out_Renamed.WriteLine();
                 out_Renamed.Write(">>    ");
             }
             else
             {
                 out_Renamed.Write(" : ");
             }
             int len = System.Math.Min(inc, length - i);
             out_Renamed.Write(Convert.toHexString(bytes, i, len, " "));
             printHead = !printHead;
         }
         out_Renamed.WriteLine();
     }
 }
Пример #2
0
        //--------
        //-------- Clock 'set' Methods
        //--------

        /// <summary> Sets the Real-Time clock.
        /// The method <code>writeDevice(byte[])</code> must be called to finalize
        /// changes to the device.  Note that multiple 'set' methods can
        /// be called before one call to <code>writeDevice(byte[])</code>.
        ///
        /// </summary>
        /// <param name="time">new value for the Real-Time clock, in milliseconds
        /// since some reference time (ie. 12:00am, January 1st, 1970)
        /// </param>
        /// <param name="state">current state of the device returned from <code>readDevice()</code>
        ///
        /// </param>
        /// <seealso cref="com.dalsemi.onewire.container.OneWireSensor.writeDevice(byte[])">
        /// </seealso>
        /// <seealso cref="getClock(byte[])">
        /// </seealso>
        public virtual void  setClock(long time, byte[] state)
        {
            Convert.toByteArray((time / 1000L), state, RTC_OFFSET, 4);
        }
Пример #3
0
        //--------
        //-------- Clock 'get' Methods
        //--------

        /// <summary> Extracts the Real-Time clock value in milliseconds.
        ///
        /// </summary>
        /// <param name="state">current state of the device returned from <code>readDevice()</code>
        ///
        /// </param>
        /// <returns> the time represented in this clock in milliseconds since some reference time,
        /// as chosen by the user (ie. 12:00am, Jan 1st 1970)
        ///
        /// </returns>
        /// <seealso cref="com.dalsemi.onewire.container.OneWireSensor.readDevice()">
        /// </seealso>
        /// <seealso cref="setClock(long,byte[])">
        /// </seealso>
        public virtual long getClock(byte[] state)
        {
            return(Convert.toLong(state, RTC_OFFSET, 4) * 1000);
        }