-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from ni/v0_1_7_get_set_trigger_settings
Add functions to get and set the trigger settings in the logging specification document and support of a timeout when opening a project.
- Loading branch information
Showing
19 changed files
with
1,103 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import sys | ||
|
||
from flexlogger.automation import Application | ||
from flexlogger.automation import StartTriggerCondition | ||
from flexlogger.automation import StopTriggerCondition | ||
|
||
|
||
def main(project_path): | ||
"""Launch FlexLogger, open a project, and get the trigger settings.""" | ||
with Application.launch() as app: | ||
project = app.open_project(path=project_path) | ||
logging_specification = project.open_logging_specification_document() | ||
|
||
# Get and print the start trigger settings | ||
start_trigger_condition, start_trigger_settings = logging_specification.get_start_trigger_settings() | ||
print("Start Trigger Condition: " + str(start_trigger_condition)) | ||
if start_trigger_condition == StartTriggerCondition.CHANNEL_VALUE_CHANGE: | ||
print("Channel Value Change Condition :") | ||
print(start_trigger_settings) | ||
elif start_trigger_condition == StartTriggerCondition.ABSOLUTE_TIME: | ||
print("Start Time: " + start_trigger_settings.strftime("%x, %X")) | ||
|
||
# Get and print the stop trigger settings | ||
stop_trigger_condition, stop_trigger_settings = logging_specification.get_stop_trigger_settings() | ||
print("Stop Trigger Condition: " + str(stop_trigger_condition)) | ||
if stop_trigger_condition == StopTriggerCondition.CHANNEL_VALUE_CHANGE: | ||
print("Channel Value Change Condition :") | ||
print(stop_trigger_settings) | ||
elif stop_trigger_condition == StopTriggerCondition.TEST_TIME_ELAPSED: | ||
print("Time Elapsed: " + stop_trigger_settings) | ||
|
||
print("Press Enter to close the project...") | ||
input() | ||
project.close() | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
argv = sys.argv | ||
if len(argv) < 2: | ||
print("Usage: %s <path of project to open>" % os.path.basename(__file__)) | ||
sys.exit() | ||
project_path_arg = argv[1] | ||
sys.exit(main(project_path_arg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import sys | ||
|
||
from datetime import datetime | ||
from datetime import timedelta | ||
from flexlogger.automation import Application | ||
|
||
|
||
def main(project_path): | ||
"""Launch FlexLogger, open a project, and set the trigger settings.""" | ||
with Application.launch() as app: | ||
project = app.open_project(path=project_path) | ||
logging_specification = project.open_logging_specification_document() | ||
|
||
# Set the start trigger settings. | ||
# test_start_time is treated as UTC unless a timezone is explicitly specified | ||
test_start_time = datetime.utcnow() | ||
logging_specification.set_start_trigger_settings_to_absolute_time(test_start_time) | ||
# Set the stop trigger settings | ||
duration = timedelta(seconds=100) | ||
logging_specification.set_stop_trigger_settings_to_duration(duration) | ||
|
||
print("Press Enter to close the project...") | ||
input() | ||
project.close() | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
argv = sys.argv | ||
if len(argv) < 2: | ||
print("Usage: %s <path of project to open>" % os.path.basename(__file__)) | ||
sys.exit() | ||
project_path_arg = argv[1] | ||
sys.exit(main(project_path_arg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import sys | ||
|
||
from flexlogger.automation import Application | ||
from flexlogger.automation import ValueChangeCondition | ||
from flexlogger.automation import ValueChangeType | ||
|
||
|
||
def main(project_path): | ||
"""Launch FlexLogger, open a project, and set the trigger settings.""" | ||
with Application.launch() as app: | ||
project = app.open_project(path=project_path) | ||
logging_specification = project.open_logging_specification_document() | ||
|
||
start_value_change_condition = ValueChangeCondition() | ||
start_value_change_condition.value_change_type = ValueChangeType.ENTER_RANGE | ||
start_value_change_condition.channel_name = 'Replace this string with the channel name to monitor.' | ||
start_value_change_condition.min_value = 1.0 | ||
start_value_change_condition.max_value = 2.0 | ||
start_value_change_condition.time = 0.0 | ||
|
||
stop_value_change_condition = ValueChangeCondition() | ||
stop_value_change_condition.value_change_type = ValueChangeType.FALL_BELOW_VALUE | ||
stop_value_change_condition.channel_name = 'Replace this string with the channel name to monitor.' | ||
stop_value_change_condition.threshold = 1.0 | ||
stop_value_change_condition.time = 0.0 | ||
|
||
logging_specification.set_start_trigger_settings_to_value_change(start_value_change_condition) | ||
logging_specification.set_stop_trigger_settings_to_value_change(stop_value_change_condition) | ||
|
||
print("Press Enter to close the project...") | ||
input() | ||
project.close() | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
argv = sys.argv | ||
if len(argv) < 2: | ||
print("Usage: %s <path of project to open>" % os.path.basename(__file__)) | ||
sys.exit() | ||
project_path_arg = argv[1] | ||
sys.exit(main(project_path_arg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...oftware/FlexLogger/Automation/FlexLogger.Automation.Protocols/StartTriggerCondition.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
|
||
package national_instruments.flex_logger.automation.protocols; | ||
|
||
enum StartTriggerCondition { | ||
START_TRIGGER_CONDITION_TEST_START = 0; | ||
START_TRIGGER_CONDITION_CHANNEL_VALUE_CHANGE = 1; | ||
START_TRIGGER_CONDITION_TIME = 2; | ||
} |
9 changes: 9 additions & 0 deletions
9
...Software/FlexLogger/Automation/FlexLogger.Automation.Protocols/StopTriggerCondition.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
|
||
package national_instruments.flex_logger.automation.protocols; | ||
|
||
enum StopTriggerCondition { | ||
STOP_TRIGGER_CONDITION_TEST_STOP = 0; | ||
STOP_TRIGGER_CONDITION_CHANNEL_VALUE_CHANGE = 1; | ||
STOP_TRIGGER_CONDITION_TIME_ELAPSED = 2; | ||
} |
13 changes: 13 additions & 0 deletions
13
...BasedSoftware/FlexLogger/Automation/FlexLogger.Automation.Protocols/ValueChangeType.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
|
||
package national_instruments.flex_logger.automation.protocols; | ||
|
||
enum ValueChangeType { | ||
TYPE_NONE = 0; | ||
TYPE_RISE_ABOVE_VALUE = 1; | ||
TYPE_RISE_ABOVE_VALUE_INCLUSIVE = 2; | ||
TYPE_FALL_BELOW_VALUE = 3; | ||
TYPE_FALL_BELOW_VALUE_INCLUSIVE = 4; | ||
TYPE_ENTER_RANGE = 5; | ||
TYPE_LEAVE_RANGE = 6; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.