-
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 #27 from ni/configure-data-rate-save-project
Add get/set data rate and save project functions.
- Loading branch information
Showing
11 changed files
with
347 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,43 @@ | ||
import os | ||
import sys | ||
|
||
from flexlogger.automation import Application | ||
from flexlogger.automation import DataRateLevel | ||
|
||
|
||
DATA_RATE_LEVEL_LOOKUP = { | ||
"Slow": DataRateLevel.SLOW, | ||
"Medium": DataRateLevel.MEDIUM, | ||
"Fast": DataRateLevel.FAST | ||
} | ||
|
||
|
||
def main(project_path): | ||
"""Launch FlexLogger, open a project, and sets the data rate values.""" | ||
with Application.launch() as app: | ||
project = app.open_project(path=project_path) | ||
channel_specification = project.open_channel_specification_document() | ||
slow_date_rate = input("Specify the data rate value for the Slow level in Hertz: ") | ||
channel_specification.set_data_rate(DataRateLevel.SLOW, float(slow_date_rate)) | ||
medium_date_rate = input("Specify the data rate value for the Medium level in Hertz: ") | ||
channel_specification.set_data_rate(DataRateLevel.MEDIUM, float(medium_date_rate)) | ||
fast_date_rate = input("Specify the data rate value for the Fast level in Hertz: ") | ||
channel_specification.set_data_rate(DataRateLevel.FAST, float(fast_date_rate)) | ||
channel_name = input("Enter the name of the channel you want to set the data rate level of: ") | ||
data_rate_level = input("Enter the data rate level you want to set (Slow, Medium or Fast: ") | ||
channel_specification.set_data_rate_level(channel_name, DATA_RATE_LEVEL_LOOKUP.get(data_rate_level)) | ||
|
||
print("Data rate set. Press Enter to save and close the project...") | ||
input() | ||
project.save() | ||
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
19 changes: 19 additions & 0 deletions
19
...onBasedSoftware/FlexLogger/Automation/FlexLogger.Automation.Protocols/DataRateLevel.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,19 @@ | ||
syntax = "proto3"; | ||
|
||
package national_instruments.flex_logger.automation.protocols; | ||
|
||
enum DataRateLevel { | ||
DATA_RATE_LEVEL_NONE = 0; | ||
// The slow analog input rate | ||
DATA_RATE_LEVEL_SLOW = 1; | ||
// The medium analog input rate | ||
DATA_RATE_LEVEL_MEDIUM = 2; | ||
// The fast analog input rate | ||
DATA_RATE_LEVEL_FAST = 3; | ||
// The counter input rate | ||
DATA_RATE_LEVEL_COUNTER = 4; | ||
// The digital input rate | ||
DATA_RATE_LEVEL_DIGITAL = 6; | ||
// On demand sample rate | ||
DATA_RATE_LEVEL_ON_DEMAND = 7; | ||
} |
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
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.