Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
SampleScripts
SampleScripts
Sample Script


Warning
Cirrus Link provides these scripts as examples only, they are not supported or guaranteed to meet any particular functionality. Cirrus Link cannot provide any assistance to modify these scripts to meet a particular need.


Code Block
languagepy
# Cirrus Link provides these scripts as examples only, they are not supported or guaranteed to meet any particular functionality. Cirrus Link cannot provide any assistance to modify these scripts to meet a particular need.
# MQTT Transmission Create Transmitter
logger = system.util.logger("com.cirruslink.examples.transmitter.customtransmitters")

# Get the Default Set ID
sets = system.cirruslink.transmission.readConfig("Sets")
for config in sets:
  if config["Name"] == "Default":
    setId = config["Id"]
    logger.debug("New Set ID: " + str(setId))

# Create Transmitter One
transmitterProps = {}
transmitterProps["Name"] = "Custom One"
transmitterProps["Enabled"] = True
transmitterProps["TagProvider"] = "default"
transmitterProps["TagPath"] = ""
transmitterProps["TagPacingPeriod"] = 1000
transmitterProps["ServerSetId"] = setId
transmitterProps["DiscoveryDelay"] = 0
transmitterProps["AliasedTags"] = False
transmitterProps["CompressionTypeWrapper"] = "NONE"
transmitterProps["BlockCommands"] = False
transmitterProps["ConvertUdts"] = True
transmitterProps["PublishUdtDefinitions"] = True
transmitterProps["OptimizeUdts"] = True
transmitterProps["CacheBirthsEnabled"] = False
#transmitterProps["HistoryStore"] = None
transmitterProps["EnableStoreForwardByDefault"] = True
transmitterProps["InOrderHistory"] = False
transmitterProps["GroupId"] = "Test1G"
transmitterProps["EdgeNodeId"] = "Test1E"
transmitterProps["DeviceId"] = None
transmitterProps["FilteredProperties"] = "accessRights;clampMode;deadband;deadbandMode;formatString;historicalDeadband;historicalDeadbandMode;historicalDeadbandStyle;historyEnabled;historyMaxAge;historyMaxAgeUnits;historyProvider;historySampleRate;historySampleRateUnits;historyTagGroup;historyTimeDeadband;historyTimeDeadbandUnits;opcItemPath;opcServer;permissionModel;rawHigh;rawLow;sampleMode;scaleFactor;scaleMode;scaledHigh;scaledLow;tagGroup;valueSource;expression;expressionType;ConfiguredTagPath;eventScripts;readPermissions;writePermissions;eventScripts"
transmitterProps["RebirthDebounceDelay"] = 5000
system.cirruslink.transmission.createConfig("Transmitters", transmitterProps)

# Read Config
savedTransmitters = system.cirruslink.transmission.readConfig("Transmitters")
for config in savedTransmitters:
  if config["Name"] == "Custom One":
    logger.info("Transmitter Config: " + str(config))
    customOneId = config["Id"]

# Update Config using MergeOverwrite
transmitterProps = {}
transmitterProps["GroupId"] = "Test2G"
transmitterProps["EdgeNodeId"] = "Test2E"
system.cirruslink.transmission.updateConfig(“Transmitters”, customOneId, “MergeOverwrite”, transmitterProps)

# Update Config using Overwrite
transmitterProps = {}
transmitterProps["Name"] = "Custom One"
transmitterProps["Enabled"] = True
transmitterProps["TagProvider"] = "default"
transmitterProps["TagPath"] = ""
transmitterProps["TagPacingPeriod"] = 1000
transmitterProps["ServerSetId"] = setId
transmitterProps["DiscoveryDelay"] = 0
transmitterProps["AliasedTags"] = False
transmitterProps["CompressionTypeWrapper"] = "NONE"
transmitterProps["BlockCommands"] = False
transmitterProps["ConvertUdts"] = True
transmitterProps["PublishUdtDefinitions"] = True
transmitterProps["OptimizeUdts"] = True
transmitterProps["CacheBirthsEnabled"] = False
#transmitterProps["HistoryStore"] = None
transmitterProps["EnableStoreForwardByDefault"] = True
transmitterProps["InOrderHistory"] = False
transmitterProps["GroupId"] = "Test2G"
transmitterProps["EdgeNodeId"] = "Test2E"
transmitterProps["DeviceId"] = None
transmitterProps["FilteredProperties"] = "accessRights;clampMode;deadband;deadbandMode;formatString;historicalDeadband;historicalDeadbandMode;historicalDeadbandStyle;historyEnabled;historyMaxAge;historyMaxAgeUnits;historyProvider;historySampleRate;historySampleRateUnits;historyTagGroup;historyTimeDeadband;historyTimeDeadbandUnits;opcItemPath;opcServer;permissionModel;rawHigh;rawLow;sampleMode;scaleFactor;scaleMode;scaledHigh;scaledLow;tagGroup;valueSource;expression;expressionType;ConfiguredTagPath;eventScripts;readPermissions;writePermissions;eventScripts"
transmitterProps["RebirthDebounceDelay"] = 5000
system.cirruslink.transmission.updateConfig(“Transmitters”, customOneId, “Overwrite”, transmitterProps)

# Delete Config
#systemsystem.cirruslink.transmission.deleteConfig("Transmitters", customOneId)

...