static void Main(string[] args) { /* * See the configuration example for how a typical application * might obtain a configuration. */ var configuration = ExampleConfiguration.Obtain(args, allowCloud: false); /* * Create the TestDataManager for communicating with the server. */ var testDataManager = new TestDataManager(configuration); // Initialize a ResultData object. var resultData = new ResultData() { Operator = "John Smith", ProgramName = "File Attachment Test", Status = new Status(StatusType.Running), SerialNumber = Guid.NewGuid().ToString(), PartNumber = "NI-ABC-234-FILE", FileIds = new List <string>() }; // Create the test result on the SystemLink server. var testResult = testDataManager.CreateResult(resultData); // Upload some sample data as the file contents. var fileId = UploadFileData( configuration, "stream.txt", Encoding.UTF8.GetBytes("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); // Add the file ID to the test result's list of attached files. resultData.FileIds.Add(fileId); // Set the test result status to done. resultData.Status = new Status(StatusType.Done); // Update the test result on the SystemLink server. testResult.Update(resultData); }
static void Main(string[] args) { /* * See the configuration example for how a typical application * might obtain a configuration. */ var configuration = ExampleConfiguration.Obtain(args); /* * Create the TestDataManager for communicating with the server. */ var testDataManager = new TestDataManager(configuration); // Intialize the random number generator. var random = new Random(); // Set test limits var lowLimit = 0; var highLimit = 70; // Initialize a ResultData object. var resultData = new ResultData() { Operator = "John Smith", ProgramName = "Power Test", Status = new Status(StatusType.Running), SerialNumber = Guid.NewGuid().ToString(), PartNumber = "NI-ABC-123-PWR" }; // Create the test result on the SystemLink server. var testResult = testDataManager.CreateResult(resultData); // Automatically sync the result's runtime with its test steps. testResult.AutoUpdateTotalTime = true; /* * Simulate a sweep across a range of electrical current and voltage. * For each value, calculate the electrical power (P=IV). */ for (var current = 0; current < 10; current++) { // Generate a parent step to represent a sweep of voltages at a given current. var voltageSweepStepData = GenerateStepData("Voltage Sweep", "SequenceCall"); // Create the step on the SystemLink server. var voltageSweepStep = testResult.CreateStep(voltageSweepStepData); for (var voltage = 0; voltage < 10; voltage++) { // Simulate obtaining a power measurement. var(power, inputs, outputs) = MeasurePower(current, voltage); // Test the power measurement. var status = (power <lowLimit || power> highLimit) ? new Status(StatusType.Failed) : new Status(StatusType.Passed); var testParameters = BuildPowerMeasurementParams(power, lowLimit, highLimit, status); // Generate a child step to represent the power output measurement. var measurePowerOutputStepData = GenerateStepData( "Measure Power Output", "NumericLimit", inputs, outputs, testParameters, status); // Create the step on the SystemLink server. var measurePowerOutputStep = voltageSweepStep.CreateStep(measurePowerOutputStepData); // If a test in the sweep fails, the entire sweep failed. Mark the parent step accordingly. if (status.StatusType == StatusType.Failed) { voltageSweepStepData.Status = new Status(StatusType.Failed); // Update the parent test step's status on the SystemLink server. voltageSweepStep.Update(voltageSweepStepData); } } // If none of the child steps failed, mark the step as passed. if (voltageSweepStepData.Status.StatusType == StatusType.Running) { voltageSweepStepData.Status = new Status(StatusType.Passed); // Update the test step's status on the SystemLink server. voltageSweepStep.Update(voltageSweepStepData); } } // Update the top-level test result's status based on the most severe child step's status. testResult = testResult.DetermineStatusFromSteps(); }
static void Main(string[] args) { System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); var serverUri = new Uri("https://localhost"); var testDataManager = new TestDataManager(); var fileUploader = new FileUploader(); var lowLimit = 0; var highLimit = 70; for (var resultIndex = 0; resultIndex < 10; resultIndex++) { var fileId = fileUploader.UploadFile("C:\\Broadway.tdms"); var resultData = new ResultData() { Operator = "mvaterla", ProgramName = "A C# App", Status = new Status(StatusType.Running), SerialNumber = Guid.NewGuid().ToString(), Product = "Some Software", FileIds = new List <string> { fileId } }; var testResult = testDataManager.CreateResult(resultData); testResult.AutoUpdateTotalTime = true; Random random = new Random(); var stepDatas = new List <StepData>(); var current = 0; var voltage = 0; var currentLoss = 1 - random.NextDouble(); var voltageLoss = 1 - random.NextDouble(); var power = current * currentLoss * voltage * voltageLoss; for (current = 0; current < 10; current++) { currentLoss = 1 - random.NextDouble() * 0.25; power = current * currentLoss * voltage * voltageLoss; var currentStepData = GenerateStepData($"Current Sweep {current}A", "SequenceCall", current, voltage, power, lowLimit, highLimit); var currentStep = testResult.CreateStep(currentStepData); for (voltage = 0; voltage < 10; voltage++) { voltageLoss = 1 - random.NextDouble() * 0.25; power = current * currentLoss * voltage * voltageLoss; var voltageStepData = GenerateStepData($"Voltage Sweep {voltage}V", "NumericLimit", current, voltage, power, lowLimit, highLimit); var voltageStep = currentStep.CreateStep(voltageStepData); if (voltageStep.Data.Status.StatusType.Equals(StatusType.Failed)) { currentStepData.Status = new Status(StatusType.Failed); currentStep.Update(currentStepData); } } if (currentStepData.Status.StatusType.Equals(StatusType.Running)) { currentStepData.Status = new Status(StatusType.Passed); currentStep.Update(currentStepData); } } testResult = testResult.DetermineStatusFromSteps(); } }