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))
wait(30) #Open Workspace Reference. We use localhost because logging takes place in the local computer Workspace_Ref = Factory().GetIWorkspace2("localhost") #New DeployOptions Reference DeployOptions_Ref = DeployOptions() DeployOptions_Ref.DeploySystemDefinition = True DeployOptions_Ref.Timeout = 60000 DeployOptions_Ref.CalibrationFilePath = r"C:\Users\chericks\Documents\VeriStand Projects\Engine Demo\Engine Demo.nivscf" DeployOptions_Ref.FilteredTargets = "" #Connect to System systemDefinitionFilePath = r"C:\Users\chericks\Documents\VeriStand Projects\Engine Demo\Engine Demo.nivssdf" Workspace_Ref.ConnectToSystem(systemDefinitionFilePath, DeployOptions_Ref) #################### ###Setup logging ### #Open Data Logging Manager Reference. We use localhost because logging takes place in the local computer Data_Logging_Manager_Ref = Factory().GetIDataLogging("localhost") #New TDMS Log File. First input is path to logging file. Second input is fileConflictOperation. 0 means create a new file with unique name TDMSLogFile_Ref = TdmsLogFile( r"C:\Users\chericks\Documents\VeriStand Projects\Engine Demo\Logs\myLog.tdms", 0) #Add TDMS Group and one channel. Repeat for as many groups and channels. Group_ref = TdmsChannelGroup("myGroup") Channel_ref = TdmsChannel("myChannel", "Aliases/ActualRPM")