diff --git a/C/src/Deadline.lf b/C/src/Deadline.lf index 02560206..feed728c 100644 --- a/C/src/Deadline.lf +++ b/C/src/Deadline.lf @@ -26,7 +26,7 @@ reactor Sensor { break; } } - schedule(response, 0); + lf_schedule(response, 0); if (c == EOF) { break; } @@ -45,8 +45,8 @@ reactor Sensor { =} reaction(response) -> y {= - printf("Reacting to physical action at %lld\n", get_elapsed_logical_time()); - SET(y, true); + printf("Reacting to physical action at %lld\n", lf_time_logical_elapsed()); + lf_set(y, true); =} } @@ -62,21 +62,21 @@ reactor Analysis { printf("Skipping work!\n"); } self->do_work = !self->do_work; - SET(y, true); + lf_set(y, true); =} } reactor Actuator { input x:bool; reaction(x) {= - instant_t l = get_elapsed_logical_time(); - instant_t p = get_elapsed_physical_time(); + instant_t l = lf_time_logical_elapsed(); + instant_t p = lf_time_physical_elapsed(); printf("Actuating... Logical time: %lld " "Physical time: %lld Lag: %lld\n", l, p, p-l); =} deadline(500 usecs) {= - instant_t d = get_elapsed_physical_time() - - get_elapsed_logical_time(); + instant_t d = lf_time_physical_elapsed() + - lf_time_logical_elapsed(); printf("Deadline missed! Lag: %lld " "(too late by %lld nsecs)\n", d, d-500000); diff --git a/C/src/Delay.lf b/C/src/Delay.lf index cb577eb0..1ca8f6ef 100644 --- a/C/src/Delay.lf +++ b/C/src/Delay.lf @@ -28,7 +28,7 @@ reactor Ramp { output y:int; state count:int(0); reaction(t) -> y {= - SET(y, self->count); + lf_set(y, self->count); self->count++; =} } @@ -41,10 +41,10 @@ reactor Delay2 { input x:int; output y:int; reaction(a) -> y {= - SET(y, a->value); + lf_set(y, a->value); =} reaction(x) -> a {= - schedule_int(a, 0, x->value); + lf_schedule_int(a, 0, x->value); =} } @@ -56,7 +56,7 @@ reactor Print { reaction(x) {= printf("Logical time: %lld, Physical time %lld" ", Value: %d\n", - get_elapsed_logical_time(), - get_elapsed_physical_time(), x->value); + lf_time_logical_elapsed(), + lf_time_physical_elapsed(), x->value); =} } diff --git a/C/src/DistributedDatabase/ReplicatedDatabase.lf b/C/src/DistributedDatabase/ReplicatedDatabase.lf index 49cae5fd..a03eea3d 100644 --- a/C/src/DistributedDatabase/ReplicatedDatabase.lf +++ b/C/src/DistributedDatabase/ReplicatedDatabase.lf @@ -76,25 +76,25 @@ reactor Server( output update:int; state queries_outstanding:int(0); reaction(query_trigger) -> query {= - SET(query, true); + lf_set(query, true); self->queries_outstanding++; =} reaction(update_trigger) -> update {= - SET(update, self->update_amount); + lf_set(update, self->update_amount); =} deadline(update_deadline) {= error_print("At tag (%lld, %u), deadline missed at database \"%s\". Rejecting update.\n" " Elapsed physical time is %lld.", - get_logical_time() - start_time, + lf_time_logical() - start_time, get_microstep(), self->name, - get_elapsed_physical_time() + lf_time_physical_elapsed() ); =} reaction(reply) {= info_print("***** At tag (%lld, %u), server \"%s\" reports balance: %d.", - get_elapsed_logical_time(), get_microstep(), self->server_name, reply->value + lf_time_logical_elapsed(), get_microstep(), self->server_name, reply->value ); self->queries_outstanding--; =} @@ -173,10 +173,10 @@ reactor Database( } info_print("At tag (%lld, %u), database \"%s\" updated balance to %d.\n" " Elapsed physical time is %lld.", - get_logical_time() - start_time, get_microstep(), + lf_time_logical() - start_time, get_microstep(), self->name, self->record, - get_elapsed_physical_time() + lf_time_physical_elapsed() ); =} STP (4 msec) {= #ifdef FEDERATED_DECENTRALIZED @@ -192,7 +192,7 @@ reactor Database( remote_update[i]->value, remote_update[i]->intended_tag.time - start_time, remote_update[i]->intended_tag.microstep, - get_elapsed_physical_time() + lf_time_physical_elapsed() ); self->record += remote_update[i]->value; } @@ -204,7 +204,7 @@ reactor Database( =} reaction(query) -> balance {= - SET(balance, self->record); + lf_set(balance, self->record); =} } diff --git a/C/src/DistributedHelloWorld/HelloWorld.lf b/C/src/DistributedHelloWorld/HelloWorld.lf index 98e252cd..10524a76 100644 --- a/C/src/DistributedHelloWorld/HelloWorld.lf +++ b/C/src/DistributedHelloWorld/HelloWorld.lf @@ -50,7 +50,7 @@ reactor MessageGenerator(prefix:string("")) { // Populate the output string and increment the count. snprintf(message->value, length, "%s %d", self->prefix, self->count++); - tag_t tag = get_current_tag(); + tag_t tag = lf_tag(); info_print("At (elapsed) logical tag (%lld, %u), source sends message: %s", tag.time - start_time, tag.microstep, message->value @@ -66,7 +66,7 @@ reactor MessageGenerator(prefix:string("")) { reactor PrintMessage { input message:char*; reaction(message) {= - tag_t tag = get_current_tag(); + tag_t tag = lf_tag(); info_print("At (elapsed) logical tag (%lld, %u), print receives: %s", tag.time - start_time, tag.microstep, message->value diff --git a/C/src/DistributedHelloWorld/HelloWorldDecentralized.lf b/C/src/DistributedHelloWorld/HelloWorldDecentralized.lf index e6d67c5f..b9fbfd8c 100644 --- a/C/src/DistributedHelloWorld/HelloWorldDecentralized.lf +++ b/C/src/DistributedHelloWorld/HelloWorldDecentralized.lf @@ -37,7 +37,7 @@ reactor PrintMessageWithDetector(offset:time(10 msec)) extends PrintMessage { ); =} reaction(local) {= - tag_t tag = get_current_tag(); + tag_t tag = lf_tag(); info_print("Timer triggered at logical tag (%lld, %u).", tag.time - start_time, tag.microstep ); diff --git a/C/src/DistributedResourceManagement/ResourceManagement.lf b/C/src/DistributedResourceManagement/ResourceManagement.lf index 1053ad4c..63a0fbd3 100644 --- a/C/src/DistributedResourceManagement/ResourceManagement.lf +++ b/C/src/DistributedResourceManagement/ResourceManagement.lf @@ -67,37 +67,37 @@ reactor Client( reaction(startup, release_trigger) -> release, request_trigger {= if (release_trigger->is_present) { - tag_t tag = get_current_tag(); + tag_t tag = lf_tag(); info_print("%s (ID %d): At tag (%lld, %u), released access.", self->name, self->id, tag.time - start_time, tag.microstep ); - SET(release, true); + lf_set(release, true); } - schedule(request_trigger, 0); + lf_schedule(request_trigger, 0); =} reaction(request_trigger) -> request {= - tag_t tag = get_current_tag(); + tag_t tag = lf_tag(); info_print("%s (ID %d): At tag (%lld, %u), requesting access.", self->name, self->id, tag.time - start_time, tag.microstep ); self->requests_outstanding++; - SET(request, true); + lf_set(request, true); =} reaction (grant) -> release_trigger {= - tag_t tag = get_current_tag(); + tag_t tag = lf_tag(); info_print("%s (ID %d): At tag (%lld, %u), granted access.", self->name, self->id, tag.time - start_time, tag.microstep ); self->requests_outstanding--; - schedule(release_trigger, 0); + lf_schedule(release_trigger, 0); =} reaction(shutdown) {= @@ -247,7 +247,7 @@ reactor ResourceManager( // Just forward the request. The determination of whether // the request can be granted cannot be made until we have received // any remote requests with the same tag. - SET(request, self->id); + lf_set(request, self->id); =} reaction(local_release) -> release {= @@ -259,7 +259,7 @@ reactor ResourceManager( ); } else { pop(&self->queue, NULL); - SET(release, self->id); + lf_set(release, self->id); } =} @@ -280,7 +280,7 @@ reactor ResourceManager( && self->queue.queue[self->queue.head] == self->id ) { // Next request on the queue is me! - SET(local_grant, true); + lf_set(local_grant, true); } // Since there shouldn't be more than one request, return now. return; @@ -358,7 +358,7 @@ reactor ResourceManager( // matches the local ID, grant the request. if (local_request->is_present && self->queue.queue[self->queue.head] == self->id) { // Grant request. - SET(local_grant, true); + lf_set(local_grant, true); } =} diff --git a/C/src/MQTT/MQTTDistributed.lf b/C/src/MQTT/MQTTDistributed.lf index b3eff1df..f7632cec 100644 --- a/C/src/MQTT/MQTTDistributed.lf +++ b/C/src/MQTT/MQTTDistributed.lf @@ -97,7 +97,7 @@ reactor MessageGenerator(root:string("")) { // Populate the output string and increment the count. snprintf(message->value, length, "%s %d", self->root, self->count++); info_print("MessageGenerator: At time %lld, publish message: %s", - get_elapsed_logical_time(), + lf_time_logical_elapsed(), message->value ); =} @@ -112,7 +112,7 @@ reactor PrintMessage { input message:char*; reaction(message) {= info_print("PrintMessage: At (elapsed) logical time %lld, subscriber receives: %s", - get_elapsed_logical_time(), + lf_time_logical_elapsed(), message->value ); =} diff --git a/C/src/MQTT/MQTTPhysical.lf b/C/src/MQTT/MQTTPhysical.lf index 3112f392..69be4a59 100644 --- a/C/src/MQTT/MQTTPhysical.lf +++ b/C/src/MQTT/MQTTPhysical.lf @@ -94,7 +94,7 @@ reactor MessageGenerator(root:string("")) { // Populate the output string and increment the count. snprintf(message->value, length, "%s %d", self->root, self->count++); printf("MessageGenerator: At time %lld, publish message: %s\n", - get_elapsed_logical_time(), + lf_time_logical_elapsed(), message->value ); =} @@ -109,7 +109,7 @@ reactor PrintMessage { input message:char*; reaction(message) {= printf("PrintMessage: At (elapsed) time %lld, subscriber receives: %s\n", - get_elapsed_logical_time(), + lf_time_logical_elapsed(), message->value ); =} diff --git a/C/src/MQTT/MQTTPublisher.lf b/C/src/MQTT/MQTTPublisher.lf index b0eb7aef..96f3a8cc 100644 --- a/C/src/MQTT/MQTTPublisher.lf +++ b/C/src/MQTT/MQTTPublisher.lf @@ -142,7 +142,7 @@ reactor MQTTPublisher ( // Append the current timestamp to the message. // This is always last, after the physical timestamp if it is included. - encode_int64(get_logical_time(), + encode_int64(lf_time_logical(), (unsigned char*)(self->inflight.message + length - sizeof(instant_t)) ); // printf("DEBUG: Timestamp of sending message: %lld.\n", *timestamp); @@ -161,7 +161,7 @@ reactor MQTTPublisher ( // As close as possible to the publishing of the message, insert // the physical timestamp if it has been requested. if (self->include_physical_timestamp) { - encode_int64(get_physical_time(), + encode_int64(lf_time_physical(), (unsigned char*)(self->inflight.message + length - 2 * sizeof(instant_t)) ); } diff --git a/C/src/MQTT/MQTTSubscriber.lf b/C/src/MQTT/MQTTSubscriber.lf index efb9d9dc..e22f4388 100644 --- a/C/src/MQTT/MQTTSubscriber.lf +++ b/C/src/MQTT/MQTTSubscriber.lf @@ -80,7 +80,7 @@ reactor MQTTSubscriber ( int topicLen, MQTTClient_message *message ) { - instant_t receive_physical_time = get_physical_time(); + instant_t receive_physical_time = lf_time_physical(); // If a physical timestamp was sent, report the transport time. size_t string_length = strlen((char*)message->payload); // Assumes null-terminated string. if (message->payloadlen == string_length + 1 + 2*sizeof(instant_t)) { @@ -103,7 +103,7 @@ reactor MQTTSubscriber ( lf_mutex_lock(&mutex); instant_t timestamp = extract_int64((unsigned char*)message->payload + message->payloadlen - sizeof(instant_t)); - interval_t delay = timestamp - get_logical_time(); + interval_t delay = timestamp - lf_time_logical(); // printf("DEBUG: MQTTSubscriber.message_arrived: received timestamp that is %lld ahead of current_time %lld.\n", *timestamp - start_time, current_time); // printf("DEBUG: MQTTSubscriber.message_arrived: physical time is ahead of current logical time by: %lld.\n", receive_physical_time - current_time); @@ -115,14 +115,14 @@ reactor MQTTSubscriber ( // exactly the logical time at the publisher plus the offset. // Otherwise, it will be scheduled at the current physical time. // The incoming message is in dynamically allocated memory. - // We copy the message using schedule_copy() because, unfortunately, Paho MQTT uses its own + // We copy the message using lf_schedule_copy() because, unfortunately, Paho MQTT uses its own // version of malloc() and free() (defined in Heap.h and Heap.c). // We could modify Paho MQTT to use the generic malloc() and free(), - // and then we could use schedule_value() to avoid the copy. + // and then we could use lf_schedule_value() to avoid the copy. // Note that the last 8 bytes of the message are the sender's timestamp. // We include that in the copy so that the reaction to the physical action // can measure the latency. - schedule_copy(incoming_message, delay, (char*)message->payload, message->payloadlen); + lf_schedule_copy(incoming_message, delay, (char*)message->payload, message->payloadlen); lf_mutex_unlock(&mutex); @@ -208,7 +208,7 @@ reactor MQTTSubscriber ( // The incoming_message action contains a token that we can just forward. // The allocated memory will be freed when the token's reference count hits 0. // Note that this token will still contain the sender's timestamp. - SET_TOKEN(message, incoming_message->token); + lf_set_token(message, incoming_message->token); // Get the sender's timestamp. instant_t* timestamp = (instant_t*)( @@ -221,14 +221,14 @@ reactor MQTTSubscriber ( // and its receipt here, offset by the clock synchronization error, // assuming that the sender sent the message at a physical time matching its // logical timestamp. - interval_t latency = get_logical_time() - *timestamp; + interval_t latency = lf_time_logical() - *timestamp; LOG_PRINT("MQTTSubscriber.reaction: Received timestamp is larger than sent timestamp by: %lld.", latency); // If a physical timestamp was sent, use that to collect // latency stats instead of the logical time increment. size_t string_length = strlen(incoming_message->value); // Assumes null-terminated string. if (incoming_message->token->length == string_length + 1 + 2*sizeof(instant_t)) { - instant_t receive_physical_time = get_physical_time(); + instant_t receive_physical_time = lf_time_physical(); instant_t physical_timestamp = extract_int64((unsigned char*)(incoming_message->value + string_length + 1)); latency = receive_physical_time - physical_timestamp; // printf("DEBUG: MQTTReceiver.reaction: Reacted to message after measured latency of %lld nsec (assuming synchronized clocks).\n", latency); diff --git a/C/src/Parallelism/ForkJoin.lf b/C/src/Parallelism/ForkJoin.lf index cc0d6846..c559b15f 100644 --- a/C/src/Parallelism/ForkJoin.lf +++ b/C/src/Parallelism/ForkJoin.lf @@ -16,7 +16,7 @@ reactor Source { output out:int; state s:int(0); reaction(t) -> out {= - SET(out, self->s); + lf_set(out, self->s); self->s++; =} } @@ -31,7 +31,7 @@ reactor TakeTime { for (int i = 0; i < 100000000; i++) { offset++; } - SET(out, in->value + offset); + lf_set(out, in->value + offset); =} } reactor Destination(width:int(4)) { diff --git a/C/src/Parallelism/Pipeline.lf b/C/src/Parallelism/Pipeline.lf index 4511d23a..160b9059 100644 --- a/C/src/Parallelism/Pipeline.lf +++ b/C/src/Parallelism/Pipeline.lf @@ -36,7 +36,7 @@ reactor SendCount( output out:int; timer t(offset, period); reaction(t) -> out {= - SET(out, self->count); + lf_set(out, self->count); self->count += self->increment; =} } @@ -50,7 +50,7 @@ reactor Receive { input in:int; reaction(in) {= info_print("At elapsed tag (%lld, %d), received %d.", - get_elapsed_logical_time(), get_microstep(), + lf_time_logical_elapsed(), get_microstep(), in->value ); if (in->value >= 10) { @@ -76,11 +76,11 @@ reactor TakeTime( input in:int; output out:int; reaction(in) -> out {= - instant_t start_time = get_physical_time(); - while (get_physical_time() < start_time + self->approximate_time) { + instant_t start_time = lf_time_physical(); + while (lf_time_physical() < start_time + self->approximate_time) { // Do nothing. } - SET(out, in->value); + lf_set(out, in->value); =} } diff --git a/C/src/Patterns/FullyConnected_00_Broadcast.lf b/C/src/Patterns/FullyConnected_00_Broadcast.lf index 975b89ca..4f018cfa 100644 --- a/C/src/Patterns/FullyConnected_00_Broadcast.lf +++ b/C/src/Patterns/FullyConnected_00_Broadcast.lf @@ -20,7 +20,7 @@ reactor Node( reaction (startup) -> out{= info_print("Hello from node %d!", self->bank_index); // broadcast my ID to everyone - SET(out, self->bank_index); + lf_set(out, self->bank_index); =} reaction (in) {= diff --git a/C/src/Patterns/FullyConnected_01_Addressable.lf b/C/src/Patterns/FullyConnected_01_Addressable.lf index 0e6dc97b..027ca6f5 100644 --- a/C/src/Patterns/FullyConnected_01_Addressable.lf +++ b/C/src/Patterns/FullyConnected_01_Addressable.lf @@ -22,7 +22,7 @@ reactor Node( reaction (startup) -> out{= info_print("Hello from node %d!", self->bank_index); // broadcast my ID to everyone - SET(out[(self->bank_index + 1) % self->num_nodes], self->bank_index); + lf_set(out[(self->bank_index + 1) % self->num_nodes], self->bank_index); =} reaction (in) {= diff --git a/C/src/Patterns/lib/SendersAndReceivers.lf b/C/src/Patterns/lib/SendersAndReceivers.lf index 0d6c9b54..1d0fee12 100644 --- a/C/src/Patterns/lib/SendersAndReceivers.lf +++ b/C/src/Patterns/lib/SendersAndReceivers.lf @@ -11,7 +11,7 @@ target C; reactor SendOnce { output out:int; reaction(startup) -> out {= - SET(out, 42); + lf_set(out, 42); =} } @@ -33,7 +33,7 @@ reactor SendCount( output out:int; timer t(offset, period); reaction(t) -> out {= - SET(out, self->count); + lf_set(out, self->count); self->count += self->increment; =} } @@ -46,7 +46,7 @@ reactor Receive { input in:int; reaction(in) {= info_print("At elapsed tag (%lld, %d), received %d.", - get_elapsed_logical_time(), get_microstep(), + lf_time_logical_elapsed(), get_microstep(), in->value ); =} @@ -56,18 +56,18 @@ reactor ReceiveAndSend { input in:int; output out:int; reaction(in) -> out {= - SET(out, in->value); + lf_set(out, in->value); =} } reactor SendOnceAndReceive { input in:int; output out:int; reaction(startup) -> out {= - SET(out, 42); + lf_set(out, 42); =} reaction(in) {= info_print("At tag (%lld, %d), received %d.", - get_elapsed_logical_time(), + lf_time_logical_elapsed(), get_microstep(), in->value ); @@ -130,12 +130,12 @@ reactor SendPeriodicallyAndReceiveMultiport ( state count:int(start); reaction(t) -> out {= - SET(out, self->count); + lf_set(out, self->count); self->count += self->increment; =} reaction(in) {= info_print("At tag (%lld, %d), received:", - get_elapsed_logical_time(), get_microstep() + lf_time_logical_elapsed(), get_microstep() ); for (int i = 0; i < self->width; i++) { info_print(" On channel %d: %d", i, in[i]->value); @@ -161,13 +161,13 @@ reactor LocalRemoteUpdates( state count:int(0); reaction(t) -> out {= - SET(out, self->increment); + lf_set(out, self->increment); self->count += self->increment; =} reaction(in) {= self->count += in->value; info_print("At tag (%lld, %d), count is %d", - get_elapsed_logical_time(), get_microstep(), + lf_time_logical_elapsed(), get_microstep(), self->count ); =} @@ -182,7 +182,7 @@ reactor SendAndReceiveWithLocalQuery( period = query_period ); reaction(local_query.out) -> local_query.in {= - SET(local_query.in, self->count); + lf_set(local_query.in, self->count); =} } // @label Accumulate local/remote increments, delayed query. @@ -197,9 +197,9 @@ reactor SendAndReceiveWithDelayedQuery( ); logical action a(query_delay); reaction(local_query.out) -> a {= - schedule(a, 0); + lf_schedule(a, 0); =} reaction(a) -> local_query.in {= - SET(local_query.in, self->count); + lf_set(local_query.in, self->count); =} } diff --git a/C/src/Patterns/lib/TakeTime.lf b/C/src/Patterns/lib/TakeTime.lf index 47f34f72..77c5ab8c 100644 --- a/C/src/Patterns/lib/TakeTime.lf +++ b/C/src/Patterns/lib/TakeTime.lf @@ -21,11 +21,11 @@ reactor TakeTime( input in:int; output out:int; reaction(in) -> out {= - instant_t start_time = get_physical_time(); + instant_t start_time = lf_time_physical(); int f0 = 0; int f1 = 1; int count = 0; - while (get_physical_time() < start_time + self->approximate_time) { + while (lf_time_physical() < start_time + self->approximate_time) { int next_term = f0 + f1; if (next_term < 0LL) { // Overflow has occurred. Start over. @@ -38,7 +38,7 @@ reactor TakeTime( count++; } } - SET(out, f1); + lf_set(out, f1); info_print("The %d-th Fibonacci number is %d.", count, f0); =} } \ No newline at end of file diff --git a/C/src/ROS/BasicROS.lf b/C/src/ROS/BasicROS.lf index b8989741..06333290 100644 --- a/C/src/ROS/BasicROS.lf +++ b/C/src/ROS/BasicROS.lf @@ -127,11 +127,11 @@ reactor MessageReceiver { strcpy(writable_string, msg->data.c_str()); // writable_string[msg->data.length()] = '\0'; // Terminate with 0 RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data.c_str()); - std::cout << "At tag (" << get_elapsed_logical_time() << "," + std::cout << "At tag (" << lf_time_logical_elapsed() << "," << get_microstep() << ") calling schedule_value with value " << writable_string << " and length " << msg->data.length() << "." << std::endl; - schedule_copy(physical_action_, 0, &(writable_string), msg->data.length() + 1); + lf_schedule_copy(physical_action_, 0, &(writable_string), msg->data.length() + 1); // std::cout << "Done calling schedule_value." << std::endl; } rclcpp::Subscription::SharedPtr subscription_; @@ -145,7 +145,7 @@ reactor MessageReceiver { self->minimal_subscriber = std::make_shared(ros_message_a); =} - reaction(ros_message_a){= + reaction(ros_message_a){= std::cout << "Physical action triggered." << std::endl; printf("Received: %s.\n", ros_message_a->value); =} diff --git a/C/src/ROS/PTIDES-ROS.lf b/C/src/ROS/PTIDES-ROS.lf index 11b2d275..9b84ef32 100644 --- a/C/src/ROS/PTIDES-ROS.lf +++ b/C/src/ROS/PTIDES-ROS.lf @@ -98,7 +98,7 @@ reactor MessageGenerator { reaction(t) {= auto message = std_msgs::msg::Int64(); // std::cout << "Executing timer reaction." << std::endl; - message.data = get_logical_time() + MSEC(25); // Add a 25 msec delay + message.data = lf_time_logical() + MSEC(25); // Add a 25 msec delay // RCLCPP_INFO(self->minimal_publisher->get_logger(), // "Sender publishing: '%lld'", message.data); self->minimal_publisher->publisher_->publish(message); @@ -126,10 +126,10 @@ reactor MessageReceiver { void topic_callback(const std_msgs::msg::Int64::SharedPtr msg) const { // writable_string[msg->data.length()] = '\0'; // Terminate with 0 // RCLCPP_INFO(this->get_logger(), "I heard: '%lld'", msg->data); - // std::cout << "At tag (" << get_elapsed_logical_time() << "," + // std::cout << "At tag (" << lf_time_logical_elapsed() << "," // << get_microstep() << ") calling schedule_copy with value " // << msg->data << "." << std::endl; - schedule_copy(physical_action_, 0, &(msg->data), sizeof(instant_t)); + lf_schedule_copy(physical_action_, 0, &(msg->data), sizeof(instant_t)); // std::cout << "Done calling schedule_value." << std::endl; } rclcpp::Subscription::SharedPtr subscription_; @@ -144,16 +144,16 @@ reactor MessageReceiver { self->minimal_subscriber = std::make_shared(ros_message_a); =} - reaction(ros_message_a) -> ros_message_l {= + reaction(ros_message_a) -> ros_message_l {= // std::cout << "Physical action triggered." << std::endl; // printf("Received: %lld.\n", ros_message_a->value); - schedule(ros_message_l, ros_message_a->value - get_logical_time()); + lf_schedule(ros_message_l, ros_message_a->value - lf_time_logical()); =} - reaction(ros_message_l) {= - printf("PTIDES reaction called at tag (%lld, %u).\n", - get_elapsed_logical_time(), - get_microstep()); + reaction(ros_message_l) {= + printf("PTIDES reaction called at tag (%lld, %u).\n", + lf_time_logical_elapsed(), + get_microstep()); =} diff --git a/C/src/ROS/ROSBuiltInSerialization.lf b/C/src/ROS/ROSBuiltInSerialization.lf index b9e588a1..9ecff54f 100644 --- a/C/src/ROS/ROSBuiltInSerialization.lf +++ b/C/src/ROS/ROSBuiltInSerialization.lf @@ -42,7 +42,7 @@ reactor Sender { reaction (t) -> out {= std_msgs::msg::Int32 ros_message; ros_message.data = self->count++; - SET(out, ros_message); + lf_set(out, ros_message); =} } diff --git a/C/src/ReflexGame.lf b/C/src/ReflexGame.lf index 16a65b05..65ef59ca 100644 --- a/C/src/ReflexGame.lf +++ b/C/src/ReflexGame.lf @@ -45,17 +45,17 @@ reactor RandomSource(min_time:time(2 sec), max_time:time(8 sec)) { srand(time(0)); // Schedule the first event. - schedule(prompt, additional_time(0, self->max_time - self->min_time)); + lf_schedule(prompt, additional_time(0, self->max_time - self->min_time)); =} reaction(prompt) -> out {= self->count++; printf("%d. Hit Return or Enter!", self->count); fflush(stdout); - SET(out, self->count); + lf_set(out, self->count); =} reaction(another) -> prompt {= // Schedule the next event. - schedule(prompt, additional_time(0, self->max_time - self->min_time)); + lf_schedule(prompt, additional_time(0, self->max_time - self->min_time)); =} } /** @@ -74,7 +74,7 @@ reactor GetUserInput { while((c = getchar()) != '\n') { if (c == EOF) break; } - schedule_copy(user_response, 0, &c, 1); + lf_schedule_copy(user_response, 0, &c, 1); if (c == EOF) break; } return NULL; @@ -96,7 +96,7 @@ reactor GetUserInput { =} reaction(prompt) {= - self->prompt_time = get_logical_time(); + self->prompt_time = lf_time_logical(); =} reaction(user_response) -> another {= @@ -110,14 +110,14 @@ reactor GetUserInput { printf("YOU CHEATED!\n"); request_stop(); } else { - int time_in_ms = (get_logical_time() - self->prompt_time) / 1000000LL; + int time_in_ms = (lf_time_logical() - self->prompt_time) / 1000000LL; printf("Response time in milliseconds: %d\n", time_in_ms); self->count++; self->total_time_in_ms += time_in_ms; // Reset the prompt_time to indicate that there is no new prompt. self->prompt_time = 0LL; // Trigger another prompt. - SET(another, 42); + lf_set(another, 42); } =} diff --git a/C/src/ReflexGame/ReflexGameTest.lf b/C/src/ReflexGame/ReflexGameTest.lf index b959c39c..cdaac9ae 100644 --- a/C/src/ReflexGame/ReflexGameTest.lf +++ b/C/src/ReflexGame/ReflexGameTest.lf @@ -11,7 +11,7 @@ main reactor { while(1) { char* c = (char*)malloc(sizeof(char)); *c = getchar(); - schedule_value(a, 0, c, 1); + lf_schedule_value(a, 0, c, 1); if (*c == EOF) break; } return NULL; @@ -29,7 +29,7 @@ main reactor { // Note that these will not be received until Enter. lf_thread_create(&self->thread_id, &read_char, a); printf("Enter character(s) followed by return: "); - self->request_time = get_logical_time(); + self->request_time = lf_time_logical(); =} reaction(a) {= @@ -38,10 +38,10 @@ main reactor { request_stop(); } else if (*a->value == '\n') { printf("Enter character(s) followed by return: "); - self->request_time = get_logical_time(); + self->request_time = lf_time_logical(); fflush(stdout); } else { - interval_t elapsed = get_logical_time() - self->request_time; + interval_t elapsed = lf_time_logical() - self->request_time; printf("Character entered: %c after %lld nsec.\n", *a->value, elapsed); } =} diff --git a/C/src/Rhythm/PlayWaveform.lf b/C/src/Rhythm/PlayWaveform.lf index 82f36196..d6089748 100644 --- a/C/src/Rhythm/PlayWaveform.lf +++ b/C/src/Rhythm/PlayWaveform.lf @@ -93,7 +93,7 @@ reactor PlayWaveform ( // Start an audio loop that will become ready to receive // amplitude samples of audio data. - lf_start_audio_loop(get_logical_time()); + lf_start_audio_loop(lf_time_logical()); =} reaction(waveform) {= @@ -102,9 +102,9 @@ reactor PlayWaveform ( reaction(note) {= if (self->waveform_id < 0 || self->waveform_id > NUM_WAVEFORMS) { - lf_play_audio_waveform(NULL, note->value, get_logical_time()); + lf_play_audio_waveform(NULL, note->value, lf_time_logical()); } else { - lf_play_audio_waveform(waveforms[self->waveform_id], note->value, get_logical_time()); + lf_play_audio_waveform(waveforms[self->waveform_id], note->value, lf_time_logical()); } =} diff --git a/C/src/Rhythm/Rhythm.lf b/C/src/Rhythm/Rhythm.lf index 49b93f2f..60c9e520 100644 --- a/C/src/Rhythm/Rhythm.lf +++ b/C/src/Rhythm/Rhythm.lf @@ -170,9 +170,9 @@ reactor RhythmSource( mkdir("log", 0755); int fed_id = get_fed_id(); if (fed_id < 0) { - sprintf(log_file_name, "log/Rhythm_%lld.log", get_logical_time()); + sprintf(log_file_name, "log/Rhythm_%lld.log", lf_time_logical()); } else { - sprintf(log_file_name, "log/Rhythm_%d_%lld.log", fed_id, get_logical_time()); + sprintf(log_file_name, "log/Rhythm_%d_%lld.log", fed_id, lf_time_logical()); } } if (start_sensor_simulator( @@ -184,7 +184,7 @@ reactor RhythmSource( // Register action to trigger on key press. register_sensor_key('\0', key); - schedule(tick, self->tick_duration); + lf_schedule(tick, self->tick_duration); =} /** @@ -194,30 +194,30 @@ reactor RhythmSource( int numeric; switch (key->value) { case '0': - SET(instrument, 0); + lf_set(instrument, 0); break; case 'd': self->rhythm = DOWNBEAT; self->emphasis = DOWNBEAT; - SET(rhythm_change, 'd'); + lf_set(rhythm_change, 'd'); info_print("Changing rhythm to downbeat only."); break; case 'm': self->rhythm = MERENGUE; self->emphasis = MERENGUE_EMPHASIS; - SET(rhythm_change, 'm'); + lf_set(rhythm_change, 'm'); info_print("Changing rhythm to merengue."); break; case 'b': self->rhythm = BOSSA_NOVA; self->emphasis = BOSSA_NOVA_EMPHASIS; - SET(rhythm_change, 'b'); + lf_set(rhythm_change, 'b'); info_print("Changing rhythm to bossa nova."); break; case 's': self->rhythm = SAMBA; self->emphasis = SAMBA_EMPHASIS; - SET(rhythm_change, 's'); + lf_set(rhythm_change, 's'); info_print("Changing rhythm to samba."); break; case 'x': @@ -228,19 +228,19 @@ reactor RhythmSource( if (self->tick_duration < self->delta) { self->tick_duration = self->delta; } - SET(tempo_change, self->delta); + lf_set(tempo_change, self->delta); info_print("Speeding up tempo."); break; case '-': self->tick_duration += self->delta; - SET(tempo_change, -self->delta); + lf_set(tempo_change, -self->delta); info_print("Slowing down tempo."); break; default: numeric = (int)key->value; if (numeric >= 49 && numeric <= 57) { // A digit between 1 and 9. - SET(instrument, numeric - 48); + lf_set(instrument, numeric - 48); info_print("Changing instrument to %c.", numeric); } } @@ -290,7 +290,7 @@ reactor RhythmSource( if (position & self->active_emphasis) { emphasis = 1.0; } - SET(note, emphasis); + lf_set(note, emphasis); beeped++; } if (beeped > 0) { @@ -309,7 +309,7 @@ reactor RhythmSource( self->count = 0; } - schedule(tick, self->tick_duration); + lf_schedule(tick, self->tick_duration); =} reaction(shutdown) {= diff --git a/C/src/Rhythm/RhythmDistributedNoUI.lf b/C/src/Rhythm/RhythmDistributedNoUI.lf index 3d268a20..febde4cf 100644 --- a/C/src/Rhythm/RhythmDistributedNoUI.lf +++ b/C/src/Rhythm/RhythmDistributedNoUI.lf @@ -59,7 +59,7 @@ reactor BeatSource(period:time(1600 msec)) { timer tick(0, period); reaction(tick) -> note {= - SET(note, 1.0f); + lf_set(note, 1.0f); =} } diff --git a/C/src/Rhythm/SensorSimulator.lf b/C/src/Rhythm/SensorSimulator.lf index 8eb63837..46b2d283 100644 --- a/C/src/Rhythm/SensorSimulator.lf +++ b/C/src/Rhythm/SensorSimulator.lf @@ -31,10 +31,10 @@ main reactor { show_tick("*"); =} reaction(r) {= - info_print("Elapsed logical time: %lld.", get_elapsed_logical_time()); + info_print("Elapsed logical time: %lld.", lf_time_logical_elapsed()); show_tick("."); =} reaction(key) {= - info_print("You typed '%s' at elapsed time %lld.", key->value, get_elapsed_logical_time()); + info_print("You typed '%s' at elapsed time %lld.", key->value, lf_time_logical_elapsed()); =} } diff --git a/C/src/RockPaperScissors.lf b/C/src/RockPaperScissors.lf index a41057b9..8ff99d32 100644 --- a/C/src/RockPaperScissors.lf +++ b/C/src/RockPaperScissors.lf @@ -35,19 +35,19 @@ reactor Player(id:char(0)) { reaction(startup) {= // Seed the random number generator. // Use the ID to ensure each player has a different seed. - srand((unsigned) get_logical_time() / self->id); + srand((unsigned) lf_time_logical() / self->id); =} reaction(startup, repeat) -> reveal {= self->choice = rand() % 3; - SET(reveal, self->choice); + lf_set(reveal, self->choice); printf("Player %d chose '%s'\n", self->id, symbol_names[self->choice]); =} reaction(observe) -> repeat {= if (observe->value == self->choice) { printf("Player %d declares a tie.\n", self->id); - schedule(repeat, 0); + lf_schedule(repeat, 0); } else if (observe->value == (self->choice + 1) % 3) { printf("Player %d won!\n", self->id); } diff --git a/C/src/SleepingBarber.lf b/C/src/SleepingBarber.lf index db684965..d811dbbe 100644 --- a/C/src/SleepingBarber.lf +++ b/C/src/SleepingBarber.lf @@ -85,19 +85,19 @@ reactor CustomerFactory( reaction(startup, next) -> send_customer, next {= // send the new customer to the waiting room self->attempts++; - SET(send_customer, self->next_customer_id++); + lf_set(send_customer, self->next_customer_id++); if (self->next_customer_id < self->num_customers) { // Schedule again. interval_t delay = random_time(self->max_time_between_customers); - schedule(next, delay); + lf_schedule(next, delay); } =} reaction (again) -> send_customer {= size_t customer_id = again->value; self->attempts++; - SET(send_customer, customer_id); + lf_set(send_customer, customer_id); =} reaction (customer_returned) -> again {= @@ -106,7 +106,7 @@ reactor CustomerFactory( // The customer returned because the waiting room is full. // Schedule again. interval_t delay = random_time(self->max_time_between_customers); - schedule_int(again, delay, i); + lf_schedule_int(again, delay, i); } } =} @@ -122,7 +122,7 @@ reactor CustomerFactory( reaction (shutdown) {= char buffer[LF_TIME_BUFFER_LENGTH]; - lf_readable_time(buffer, get_elapsed_logical_time()); + lf_readable_time(buffer, lf_time_logical_elapsed()); info_print("Finished: %d customers got haircuts in %d attempts over %s.", self->done_customers, self->attempts, buffer ); @@ -158,11 +158,11 @@ reactor WaitingRoom(capacity:size_t(1000), num_customers:size_t(2000)) { size_t customer_id = customer_enters->value; if (deque_size(&self->queue) == self->capacity) { - SET(full[customer_id], true); + lf_set(full[customer_id], true); } else { if (self->barber_asleep) { self->barber_asleep = false; - SET(barber_leaves_with_customer, customer_id); + lf_set(barber_leaves_with_customer, customer_id); } else { // Note that the customer_id is being cast to a pointer // because the payload of a queue element is a pointer. @@ -170,7 +170,7 @@ reactor WaitingRoom(capacity:size_t(1000), num_customers:size_t(2000)) { // to recast it to size_t, assuming void* has at least as // many bits as size_t, which it must. deque_push_back(&self->queue, (void*)customer_id); - SET(wait[customer_id], true); + lf_set(wait[customer_id], true); } } =} @@ -179,7 +179,7 @@ reactor WaitingRoom(capacity:size_t(1000), num_customers:size_t(2000)) { if (deque_is_empty(&self->queue)) { self->barber_asleep = true; } else { - SET(barber_leaves_with_customer, (size_t)deque_pop_front(&self->queue)); + lf_set(barber_leaves_with_customer, (size_t)deque_pop_front(&self->queue)); } =} } @@ -201,16 +201,16 @@ reactor Customer(bank_index:size_t(0)) { reaction (room_full) -> returned {= char buffer[LF_TIME_BUFFER_LENGTH]; - lf_readable_time(buffer, get_elapsed_logical_time()); + lf_readable_time(buffer, lf_time_logical_elapsed()); info_print("Customer %d: Turned away at %s. Will try later.", self->bank_index, buffer ); - SET(returned, true); + lf_set(returned, true); =} reaction (wait) {= char buffer[LF_TIME_BUFFER_LENGTH]; - lf_readable_time(buffer, get_elapsed_logical_time()); + lf_readable_time(buffer, lf_time_logical_elapsed()); info_print("Customer %d: Entered waiting room at %s. Waiting.", self->bank_index, buffer ); @@ -218,7 +218,7 @@ reactor Customer(bank_index:size_t(0)) { reaction (start_cutting) {= char buffer[LF_TIME_BUFFER_LENGTH]; - lf_readable_time(buffer, get_elapsed_logical_time()); + lf_readable_time(buffer, lf_time_logical_elapsed()); info_print("Customer %d: Started a haircut at %s.", self->bank_index, buffer ); @@ -226,11 +226,11 @@ reactor Customer(bank_index:size_t(0)) { reaction (done_cutting) -> done {= char buffer[LF_TIME_BUFFER_LENGTH]; - lf_readable_time(buffer, get_elapsed_logical_time()); + lf_readable_time(buffer, lf_time_logical_elapsed()); info_print("Customer %d: Finished a haircut at %s.", self->bank_index, buffer ); - SET(done, true); + lf_set(done, true); =} } @@ -260,20 +260,20 @@ reactor Barber( reaction (done) -> done_cutting, next {= int customer_id = done->value; - SET(done_cutting[customer_id], true); - SET(next, true); + lf_set(done_cutting[customer_id], true); + lf_set(next, true); =} reaction (enter) -> start_cutting, done {= int customer_id = enter->value; - SET(start_cutting[customer_id], true); + lf_set(start_cutting[customer_id], true); // Calculate a random delay. interval_t delay = self->min_cut_time + random_time(self->max_cut_time - self->min_cut_time); // Notify the customer - schedule_int(done, delay, customer_id); + lf_schedule_int(done, delay, customer_id); =} } diff --git a/C/src/Smokers.lf b/C/src/Smokers.lf index 9106dc48..87860c84 100644 --- a/C/src/Smokers.lf +++ b/C/src/Smokers.lf @@ -108,21 +108,21 @@ reactor Agent { output matches:bool; reaction(startup) {= // At start, seed the random number. - srand((unsigned)get_logical_time()); + srand((unsigned)lf_time_logical()); =} reaction(startup, trigger) -> tobacco, paper, matches {= int choice = rand() % 3; if (choice == 0) { - SET(tobacco, true); - SET(paper, true); + lf_set(tobacco, true); + lf_set(paper, true); info_print("Agent putting tobacco and paper on the table."); } else if (choice == 1) { - SET(tobacco, true); - SET(matches, true); + lf_set(tobacco, true); + lf_set(matches, true); info_print("Agent putting tobacco and matches on the table."); } else { - SET(paper, true); - SET(matches, true); + lf_set(paper, true); + lf_set(matches, true); info_print("Agent putting paper and matches on the table."); } =} @@ -141,18 +141,18 @@ reactor Smoker( reaction(smoke) -> done {= info_print("Smoker is done smoking."); - SET(done, true); + lf_set(done, true); =} reaction(tobacco, paper, matches) -> smoke {= if (self->has == 0 && paper->is_present && matches->is_present) { info_print("Smoker with tobacco starts smoking."); - schedule(smoke, self->smoke_time); + lf_schedule(smoke, self->smoke_time); } else if (self->has == 1 && tobacco->is_present && matches->is_present) { info_print("Smoker with paper starts smoking."); - schedule(smoke, self->smoke_time); + lf_schedule(smoke, self->smoke_time); } else if (self->has == 2 && tobacco->is_present && paper->is_present) { info_print("Smoker with matches starts smoking."); - schedule(smoke, self->smoke_time); + lf_schedule(smoke, self->smoke_time); } =} } diff --git a/C/src/TrainDoor/TrainDoor.lf b/C/src/TrainDoor/TrainDoor.lf index 5aafee3f..cacf203e 100644 --- a/C/src/TrainDoor/TrainDoor.lf +++ b/C/src/TrainDoor/TrainDoor.lf @@ -24,13 +24,13 @@ preamble {= while(1) { int c = getchar(); if (c == 'm') { - schedule(buttons.move, 0); + lf_schedule(buttons.move, 0); } if (c == 'o') { - schedule(buttons.open, 0); + lf_schedule(buttons.open, 0); } if (c == 'c') { - schedule(buttons.close, 0); + lf_schedule(buttons.close, 0); } if (c == EOF) { break; @@ -53,13 +53,13 @@ reactor MotionDetector { =} reaction(movement) {= printf("Motion detected!\n"); - self->timestamp = get_logical_time(); + self->timestamp = lf_time_logical(); =} reaction(check) -> ok {= - if (self->timestamp == 0L || (get_logical_time() - self->timestamp) > SECS(2)) { - SET(ok, true); + if (self->timestamp == 0L || (lf_time_logical() - self->timestamp) > SECS(2)) { + lf_set(ok, true); } else { - SET(ok, false); + lf_set(ok, false); } =} } @@ -83,7 +83,7 @@ reactor DoorController { printf("The door is already open\n"); } else { printf("Checking the motion sensor\n"); - SET(check, false); + lf_set(check, false); self->requested = true; } =} diff --git a/C/src/TrainDoor/TrainDoorAsymmetric.lf b/C/src/TrainDoor/TrainDoorAsymmetric.lf index ddb892b3..cc28373f 100644 --- a/C/src/TrainDoor/TrainDoorAsymmetric.lf +++ b/C/src/TrainDoor/TrainDoorAsymmetric.lf @@ -11,9 +11,9 @@ reactor Controller { =} reaction(external)->lock, unlock, move, stop {= if (external->value) { - SET(lock, true); SET(move, true); + lf_set(lock, true); lf_set(move, true); } else { - SET(unlock, true); SET(stop, true); + lf_set(unlock, true); lf_set(stop, true); } =} } diff --git a/C/src/TrainDoor/TrainDoorSimplest.lf b/C/src/TrainDoor/TrainDoorSimplest.lf index 0a43d2c8..a5de1be3 100644 --- a/C/src/TrainDoor/TrainDoorSimplest.lf +++ b/C/src/TrainDoor/TrainDoorSimplest.lf @@ -10,8 +10,8 @@ reactor Controller { // ... Set up sensing. =} reaction(external_move)->lock, move {= - SET(lock, external_move->value); - SET(move, external_move->value); + lf_set(lock, external_move->value); + lf_set(move, external_move->value); =} } reactor Train { diff --git a/C/src/TrainDoor/TrainDoorWithDeadlines.lf b/C/src/TrainDoor/TrainDoorWithDeadlines.lf index fd312f5c..20a7645d 100644 --- a/C/src/TrainDoor/TrainDoorWithDeadlines.lf +++ b/C/src/TrainDoor/TrainDoorWithDeadlines.lf @@ -12,8 +12,8 @@ reactor Controller { // ... Set up sensing. =} reaction(external_move)->lock, move, unlock, stop {= - SET(lock, external_move->value); - SET(move, external_move->value); + lf_set(lock, external_move->value); + lf_set(move, external_move->value); =} } realtime reactor Train { diff --git a/C/src/TrainDoor/TrainDoorWithDoorOpenState.lf b/C/src/TrainDoor/TrainDoorWithDoorOpenState.lf index b75694c9..1c52743c 100644 --- a/C/src/TrainDoor/TrainDoorWithDoorOpenState.lf +++ b/C/src/TrainDoor/TrainDoorWithDoorOpenState.lf @@ -10,8 +10,8 @@ reactor Controller { // ... Set up sensing. =} reaction(external_move)->lock, move {= - SET(lock, external_move->value); - SET(move, external_move->value); + lf_set(lock, external_move->value); + lf_set(move, external_move->value); =} } reactor Train { diff --git a/C/src/TrainDoor/TrainDoorWithOpen.lf b/C/src/TrainDoor/TrainDoorWithOpen.lf index 96610904..286659e6 100644 --- a/C/src/TrainDoor/TrainDoorWithOpen.lf +++ b/C/src/TrainDoor/TrainDoorWithOpen.lf @@ -11,9 +11,9 @@ reactor Controller { =} reaction(external)->close, lock, open, unlock {= if (external->value) { - SET(close, true); SET(lock, true); + lf_set(close, true); lf_set(lock, true); } else { - SET(open, true); SET(unlock, true); + lf_set(open, true); lf_set(unlock, true); } =} } diff --git a/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf b/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf index 28467318..6f1c45f5 100644 --- a/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf +++ b/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf @@ -84,8 +84,8 @@ reactor DoubleUnlockKeyFob(auto_lock_duration(5)) { # log structure: (elapsed_physical_time:int, tag:int, remote:bool, do_lock:bool, auto:bool) def append_log(self, auto, remote, do_lock): - elapsed_tag = Tag(get_elapsed_logical_time(), get_microstep()) - log_entry = (get_elapsed_physical_time(), elapsed_tag, remote, do_lock, auto) + elapsed_tag = Tag(lf.time.logical_elapsed(), get_microstep()) + log_entry = (lf.time.physical_elapsed(), elapsed_tag, remote, do_lock, auto) self.logger.append_log(self.format_log_message(log_entry)) def listen_for_keypress(self, press_lock, press_unlock): diff --git a/Python/src/DigitalTwin/DoubleUnlock/Simulator.lf b/Python/src/DigitalTwin/DoubleUnlock/Simulator.lf index 38749705..c9ace130 100644 --- a/Python/src/DigitalTwin/DoubleUnlock/Simulator.lf +++ b/Python/src/DigitalTwin/DoubleUnlock/Simulator.lf @@ -40,13 +40,13 @@ reactor DoubleUnlockKeyFobTester(initial_delay(5)) { =} reaction(simulate_press_fob) -> send_lock_press_to_fob {= - tag = get_current_tag() + tag = lf.tag() print(f"Sent lock press {simulate_press_fob.value} to fob at ({tag.time}, {tag.microstep})") send_lock_press_to_fob.set(simulate_press_fob.value) =} reaction(simulate_press_twin) -> send_lock_press_to_twin {= - tag = get_current_tag() + tag = lf.tag() print(f"Sent lock press {simulate_press_twin.value} to twin at ({tag.time}, {tag.microstep})") send_lock_press_to_twin.set(simulate_press_twin.value) =} diff --git a/Python/src/DigitalTwin/KeyFob/KeyFobDemo.lf b/Python/src/DigitalTwin/KeyFob/KeyFobDemo.lf index 6272976a..9658df98 100644 --- a/Python/src/DigitalTwin/KeyFob/KeyFobDemo.lf +++ b/Python/src/DigitalTwin/KeyFob/KeyFobDemo.lf @@ -57,8 +57,8 @@ reactor KeyFob { # log structure: (elapsed_physical_time:int, tag:int, remote:bool, locked:bool) def append_log(self, remote, locked): - elapsed_tag = Tag(get_elapsed_logical_time(), get_microstep()) - log_entry = (get_elapsed_physical_time(), elapsed_tag, remote, locked) + elapsed_tag = Tag(lf.time.logical_elapsed(), get_microstep()) + log_entry = (lf.time.physical_elapsed(), elapsed_tag, remote, locked) self.logger.append_log(self.format_log_message(log_entry)) def listen_for_keypress(self, press_lock, press_unlock): diff --git a/Python/src/ReflexGame/ReflexGame.lf b/Python/src/ReflexGame/ReflexGame.lf index 337b9a1e..dc433d25 100644 --- a/Python/src/ReflexGame/ReflexGame.lf +++ b/Python/src/ReflexGame/ReflexGame.lf @@ -100,7 +100,7 @@ reactor UpdateGraphics { self.update_graphics.send(((152,251,152), (0, 0, 0), "{}. Press any key!".format(prompt.value))) - self.prompt_time = get_physical_time() + self.prompt_time = lf.time.physical() =} reaction(user_input) -> another {= @@ -126,7 +126,7 @@ reactor UpdateGraphics { "Average response time: undefined")) request_stop() else: - time_in_ms = (get_logical_time() - self.prompt_time) // MSEC(1) + time_in_ms = (lf.time.logical() - self.prompt_time) // MSEC(1) self.update_graphics.send(((205,92,92), (0, 0, 0), "Response time in milliseconds: {}".format(time_in_ms), diff --git a/Python/src/YOLOv5/YOLOv5_Webcam.lf b/Python/src/YOLOv5/YOLOv5_Webcam.lf index 947d091e..15ee3f3b 100644 --- a/Python/src/YOLOv5/YOLOv5_Webcam.lf +++ b/Python/src/YOLOv5/YOLOv5_Webcam.lf @@ -35,7 +35,7 @@ reactor WebCam(webcam_id(0)) { while running.is_set(): if ret is True: # If got a frame, schedule the physical action - frame_action.schedule(0, (get_elapsed_physical_time(), frame)) + frame_action.schedule(0, (lf.time.physical_elapsed(), frame)) ret, frame = self.stream.read() return None =} @@ -139,7 +139,7 @@ reactor Plotter(label_deadline(100 msec)) { reaction(labels) {= # DNN output was on time =} deadline(label_deadline) {= - print(f"Received the DNN output late by about {(get_physical_time() - get_logical_time())/1000000}ms.") + print(f"Received the DNN output late by about {(lf.time.physical() - lf.time.logical())/1000000}ms.") =} /** diff --git a/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf b/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf index 13c6e628..cd40843b 100644 --- a/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf +++ b/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf @@ -42,7 +42,7 @@ reactor WebCam { reaction(camera_tick) -> camera_frame {= ret, frame = self.stream.read() if ret is True: - camera_frame.set((get_elapsed_physical_time(), frame)) + camera_frame.set((lf.time.physical_elapsed(), frame)) =} reaction(shutdown) {=