void 
Timeslice::reset() 
{
	m_last_duration = 0;
	m_start_time = UtcTime();
	m_never_ran_before = true;
	m_expedite_next_run = false;
	updateNextStartTime();
}
void GlobalTimeSyncMaster::IfaceMaster::setTxTimestamp(UtcTime ts)
{
    if (ts.isZero())
    {
        UAVCAN_ASSERT(0);
        pub_.getNode().registerInternalFailure("GlobalTimeSyncMaster zero TX ts");
        return;
    }
    if (!prev_tx_utc_.isZero())
    {
        prev_tx_utc_ = UtcTime(); // Reset again, because there's something broken in the driver and we don't trust it
        pub_.getNode().registerInternalFailure("GlobalTimeSyncMaster pub conflict");
        return;
    }
    prev_tx_utc_ = ts;
}
int GlobalTimeSyncMaster::IfaceMaster::publish(TransferID tid, MonotonicTime current_time)
{
    UAVCAN_ASSERT(pub_.getTransferSender()->getCanIOFlags() == CanIOFlagLoopback);
    UAVCAN_ASSERT(pub_.getTransferSender()->getIfaceMask() == (1 << iface_index_));

    const MonotonicDuration since_prev_pub = current_time - iface_prev_pub_mono_;
    iface_prev_pub_mono_ = current_time;
    UAVCAN_ASSERT(since_prev_pub.isPositive());
    const bool long_period = since_prev_pub.toMSec() >= protocol::GlobalTimeSync::MAX_PUBLICATION_PERIOD_MS;

    protocol::GlobalTimeSync msg;
    msg.prev_utc_usec = long_period ? 0 : prev_tx_utc_.toUSec();
    prev_tx_utc_ = UtcTime();

    UAVCAN_TRACE("GlobalTimeSyncMaster", "Publishing %llu iface=%i tid=%i",
                 static_cast<unsigned long long>(msg.prev_utc_usec), int(iface_index_), int(tid.get()));
    return pub_.broadcast(msg, tid);
}