class Workspace2(Workspace): """Interface that controls the running state of the system and accesses the channels in the system.""" def __init__(self, gatewayIPAddress=None): if (gatewayIPAddress is None): self.iwks = Factory().GetIWorkspace2("") else: self.iwks = Factory().GetIWorkspace2(gatewayIPAddress) def GetSystemState(self): """Returns the current state of the system.""" data = self.iwks.GetSystemState(0, "", None) _RaiseException_(data[0]) targets = [] for target in data[3]: targets.append(target) return { 'state': self._NetSystemStateToPy_(data[1]), 'systemdefinition_file': data[2], 'targets': tuple(targets) } def ConnectToSystem(self, systemdefinition_file, deploy, timeout): """Connects the VeriStand Gateway to one or more targets running on the System Definition file you specify.""" _RaiseException_( self.iwks.ConnectToSystem(systemdefinition_file, System.Boolean(deploy), System.UInt32(timeout))) def DisconnectFromSystem(self, password, undeploy_system_definition): """Disconnects the VeriStand Gateway from the targets.""" _RaiseException_( self.iwks.DisconnectFromSystem(password, undeploy_system_definition)) def LockConnection(self, old_password, new_password): """ Locks the current VeriStand Gateway connection. If the connection was locked previously, you must enter the previous password in `old_password`. """ _RaiseException_(self.iwks.LockConnection(old_password, new_password)) def UnlockConnection(self, password): """Unlocks the current VeriStand Gateway connection.""" _RaiseException_(self.iwks.UnlockConnection(password)) def StartDataLogging(self, configuration_name, logInfo): """Starts logging data to the configuration you specify.""" _RaiseException_( self.iwks.StartDataLogging(configuration_name, logInfo)) def StopDataLogging(self, configuration_name): """Terminates data logging for the configuration you specify.""" _RaiseException_(self.iwks.StopDataLogging(configuration_name)) def SetChannelValues(self, channels, newValues): """Sets the value for the channels you specify. The `newValues` parameter accepts scalar, vector, and matrix data types. """ tupleChannelNames = _ConvertListParamToTuple_(channels) tupleArray = _ConvertMATRIXARRToDataArray_(newValues) _RaiseException_( self.iwks.SetChannelValues(tupleChannelNames, tupleArray))
################################################# ###Changes channel values, wait and reset ### #Prepare values that will be assigned engine_power = BooleanValue(True) desired_rpm = DoubleValue(3000) wait_time = DoubleValue(10) # You can access a channel with a ChannelReference engine_power_chan = ChannelReference('Aliases/EnginePower') desired_rpm_chan = ChannelReference('Aliases/DesiredRPM') engine_power_chan.value = engine_power.value desired_rpm_chan.value = desired_rpm.value wait(wait_time.value) engine_power_chan.value = False desired_rpm_chan.value = 0 ############################################### #Stop Data Logging Session logs_array = ["logs"] Data_Logging_Manager_Ref.StopDataLoggingSession("myLoggingSession", True, Array[str](logs_array)) wait(10) #Disconnect from System password = "" undeploySystemDefinition = True Workspace_Ref.DisconnectFromSystem(password, undeploySystemDefinition)