def cast_to_datapoint(measurement, at=Time.now())
      @logger.debug "cast_to_datapoint(#{measurement.inspect})"
      if measurement.is_a?(Xively::Datapoint)
        return measurement
      elsif measurement.is_a?(Hash)
        raise "The datapoint hash does not contain :at" unless measurement[:at]
        raise "The datapoint hash does not contain :value" unless measurement[:value]
        return Xively::Datapoint.new(measurement)
      else
        return Xively::Datapoint.new(:at => at, :value => measurement.to_s)
      end
    end
def cast_to_datapoint(measurement, at=Time.now())
      @logger.debug "cast_to_datapoint(#{measurement.inspect})"
      if measurement.is_a?(Xively::Datapoint)
        return measurement
      elsif measurement.is_a?(Hash)
        raise "The datapoint hash does not contain :at" unless measurement[:at]
        raise "The datapoint hash does not contain :value" unless measurement[:value]
        return Xively::Datapoint.new(measurement)
      else
        return Xively::Datapoint.new(:at => at, :value => measurement.to_s)
      end
    end
Converts a measurement to a Datapoint