public void Raise_ValueGenerated_Event_And_Check_Value_Interval() { // Arrange const int intervalBoundary = -112; int? result = null; var generator = new Generator(); var resetEvent = new ManualResetEventSlim(false); void ValueGeneratedHandler(object sender, int value) { result = value; resetEvent.Set(); (sender as Generator)?.Stop(); } generator.ValueGenerated += ValueGeneratedHandler; // Act generator.Start(intervalBoundary, intervalBoundary, 1, 1); // Assert Assert.AreEqual(resetEvent.Wait(TimeSpan.FromMilliseconds(500)), true); Assert.AreEqual(intervalBoundary, result); generator.ValueGenerated -= ValueGeneratedHandler; }
public override void Render(PostProcessRenderContext context) { var cmd = context.command; cmd.BeginSample("Pix2Pix"); var sheet = context.propertySheets.Get(_shader); var props = sheet.properties; props.SetVector(ShaderIDs.EdgeParams, new Vector3( settings.edgeThreshold, settings.edgeIntensity, settings.edgeOpacity )); // Edge detection pass cmd.BlitFullscreenTriangle(context.source, _sourceRT, sheet, 0); // Pix2Pix generator pass GpuBackend.UseCommandBuffer(cmd); _generator.Start(_sourceRT); _generator.Step(); while (_generator.Running) { _generator.Step(); } _generator.GetResult(_resultRT); GpuBackend.ResetToDefaultCommandBuffer(); // Composite pass props.SetTexture(ShaderIDs.EdgeTex, _sourceRT); cmd.BlitFullscreenTriangle(_resultRT, context.destination, sheet, 1); cmd.EndSample("Pix2Pix"); }
// // We want to generate the report // private void button_GenerateReport_Click(object sender, EventArgs e) { // We need a report name string expectedTextRegEx = @"^[a-zA-Z0-9][A-Za-z0-9_. -]*$"; if (string.IsNullOrWhiteSpace(textBox_ReportName.Text) == true || Regex.IsMatch(textBox_ReportName.Text, expectedTextRegEx) == false) { m_logger.Log(@"No file name provided when generating report"); MessageBox.Show("You need to provide a valid Report Name before generating the stats.\n\nValid characters are 'a-z', 'A-Z', '0-9', _, ., [space] and -. The name must start with either a-z or 0-9", @"Stats Generation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Format the report name string reportName = textBox_ReportName.Text.Trim(); // Kick it off and we're done Display.SetDisplayProperties(this, label_Progress, progressBar_Progress, button_GenerateReport, m_logger); Generator.Start(this, m_fileList, reportName, m_logger, m_injectPaths, () => { // Lose our dialog m_logger.Log("Closing dialog - work done"); this.Close(); }); }
public MMnQueue_Modular(double hourlyArrivalRate, double hourlyServiceRate, int nServers, int seed = 0) : base(seed) { HourlyArrivalRate = hourlyArrivalRate; HourlyServiceRate = hourlyServiceRate; Generator = AddChild(new Generator(new Generator.Statics { InterArrivalTime = rs => Exponential.Sample(rs, TimeSpan.FromHours(1 / HourlyArrivalRate)) }, DefaultRS.Next())); Queue = AddChild(new Queue(double.PositiveInfinity, DefaultRS.Next())); Server = AddChild(new Server(new Server.Statics { Capacity = nServers, ServiceTime = (rs, load) => Exponential.Sample(rs, TimeSpan.FromHours(1 / HourlyServiceRate)), }, DefaultRS.Next())); Generator.OnArrive += () => Queue.RqstEnqueue(new Load()); Generator.OnArrive += Arrive; Queue.OnEnqueued += Server.RqstStart; Server.OnStarted += Queue.Dequeue; Server.OnReadyToDepart += Server.Depart; Server.OnReadyToDepart += load => Depart(); HC_InSystem = AddHourCounter(); /// Initial event Generator.Start(); }
public void MinTimeInterval_Argument_Must_Be_Greater_Than_Zero() { // Arrange var generator = new Generator(); // Act generator.Start(0, 0, minTimeInterval: -1, maxTimeInterval: 100); // Assert }
static void Main(string[] args) { var gen = new Generator(); gen.Start(); var serv = new Server(gen); serv.Start(); }
public void Start() { if (Generator.ThreadState == ThreadState.Suspended) { Generator.Resume(); } else { Generator.Start(); } }
public Network(Statics config, int seed, string tag = null) : base(config, seed, tag) { Name = "Network"; Display = true; for (int i = 0; i < Config.NNodes; i++) { for (int j = 0; j < Config.NNodes; j++) { if (i != j && Config.DemandRates[i, j] > 0) { int o = i, d = j; var g = new Generator <Order>( new Generator <Order> .Statics { Create = rs => new Order(new Order.Statics { Origin = o, Destination = d, }, rs.Next()), InterArrivalTime = rs => TimeSpan.FromDays( Exponential.Sample(rs, 1 / Config.DemandRates[o, d])), SkipFirst = true, }, DefaultRS.Next()); g.OnArrive.Add(order => new DemandArriveEvent { This = this, Order = order }); Generators.Add(new Tuple <int, int>(i, j), g); InitEvents.Add(g.Start()); } } } Transporters.AddRange(Enumerable.Range(0, Config.NTransporters) .Select(i => new Transporter(new Transporter.Statics(), DefaultRS.Next()) { Display = Display, Tag = "Transporter#" + i, })); foreach (var t in Transporters) { t.OnFinishTransport.Add(order => new DeliverEvent { This = this, Order = order }); } InitEvents.AddRange(Transporters.Select(t => t.Init(this))); }
private void SetTimer() { uint t = 0; if (uint.TryParse(IntervalBox.Text, out t)) { if (t > 0) { Generator.Stop(); Generator.Interval = TimeSpan.FromMilliseconds(t); Generator.Start(); } else { IntervalBox.Text = "1"; } } }
void Start() { Debug.Log(get_number()); Debug.Log(get_string()); call_callback((msg) => { Debug.Log(msg); }); generator = new Generator(); generator.OnUpdate .Subscribe((v) => { Debug.Log(v); }) .AddTo(gameObject); generator.OnUpdate .BatchFrame(0, FrameCountType.Update) .Subscribe((v) => { textField.text = v.Last(); }) .AddTo(gameObject); generator.Start(); }
static void Main(string[] args) { // Configure cancel key press handler (to stop the app) Console.CancelKeyPress += new ConsoleCancelEventHandler( CancelKeyPressHandler); // Connect to the cloud var deviceClient = DeviceClientHelper.Init(); // Telemetry generator produces random temperature // and humidity, and then sends them both to the cloud var telemetryGenerator = new Generator( deviceClient, cancellationTokenSource.Token); // Associate handler to update device properties according to cloud requests deviceClient.SetDesiredPropertyUpdateCallbackAsync( PropertyUpdateCallback, telemetryGenerator).Wait(); // Start telemetry telemetryGenerator.Start().Wait(); }
void Start() { Generator.Start(); }
public static void Main() { // Print library information: PrintInfo.PrintLibraryInfo(); // Enable network search: Network.AutoDetectEnabled = true; // Update device list: DeviceList.Update(); // Try to open a generator with burst support: Generator gen = null; for (UInt32 i = 0; i < DeviceList.Count; i++) { DeviceListItem item = DeviceList.GetItemByIndex(i); if (item.CanOpen(DeviceType.Generator)) { gen = item.OpenGenerator(); // Check for burst support: if ((gen.ModesNative & Constants.GM_BURST_COUNT) != 0) { break; } else { gen.Dispose(); gen = null; } } } if (gen != null) { try { // Set signal type: gen.SignalType = SignalType.Sine; // Set frequency: gen.Frequency = 50; // 50 Hz // Set amplitude: gen.Amplitude = 2; // 2 V // Set offset: gen.Offset = 0; // 0 V // Set burst mode: gen.Mode = GeneratorMode.BurstCount; // Set burst count: gen.BurstCount = 100; // 100 periods // Enable output: gen.OutputOn = true; // Print Generator info: PrintInfo.PrintDeviceInfo(gen); // Start signal generation gen.Start(); // Wait for burst to complete: while (gen.IsBurstActive) { Thread.Sleep(10); // 10 ms delay, to save CPU time. } // Disable output: gen.OutputOn = false; } catch (System.Exception e) { Console.WriteLine("Exception: " + e.Message); Environment.Exit(1); } // Close generator: gen.Dispose(); gen = null; } else { Console.WriteLine("No generator available with burst support!"); Environment.Exit(1); } Environment.Exit(0); }
public static void Main() { // Print library information: PrintInfo.PrintLibraryInfo(); // Enable network search: Network.AutoDetectEnabled = true; // Update device list: DeviceList.Update(); // Try to open a generator with triggered burst support: Generator gen = null; for (UInt32 i = 0; i < DeviceList.Count; i++) { DeviceListItem item = DeviceList.GetItemByIndex(i); if (item.CanOpen(DeviceType.Generator)) { gen = item.OpenGenerator(); // Check for triggered burst support: if ((gen.ModesNative & Constants.GM_BURST_COUNT) != 0 && gen.TriggerInputs.Count > 0) { break; } else { gen.Dispose(); gen = null; } } } if (gen != null) { try { // Set signal type: gen.SignalType = SignalType.Square; // Set frequency: gen.Frequency = 100e3; // 100 kHz // Set amplitude: gen.Amplitude = 2.5; // 2.5 V // Set offset: gen.Offset = 2.5; // 2.5 V // Set symmetry (duty cycle): gen.Symmetry = 0.25; // 25 % // Set burst mode: gen.Mode = GeneratorMode.BurstCount; // Set burst count: gen.BurstCount = 20; // 20 periods // Locate trigger input: TriggerInput triggerInput = gen.TriggerInputs.GetById(Constants.TIID_EXT1); if (triggerInput == null) { triggerInput = gen.TriggerInputs.GetById(Constants.TIID_EXT2); } if (triggerInput == null) { throw new System.Exception("Unknown trigger input!"); } // Enable trigger input: triggerInput.Enabled = true; // Set trigger input kind: triggerInput.Kind = TriggerKind.FallingEdge; // Enable output: gen.OutputOn = true; // Print generator info: PrintInfo.PrintDeviceInfo(gen); // Start signal generation gen.Start(); // Wait for keystroke: Console.WriteLine("Press Enter to stop signal generation..."); Console.ReadLine(); // Stop generator: gen.Stop(); // Disable output: gen.OutputOn = false; } catch (System.Exception e) { Console.WriteLine("Exception: " + e.Message); Environment.Exit(1); } // Close generator: gen.Dispose(); gen = null; } else { Console.WriteLine("No generator available with triggered burst support!"); Environment.Exit(1); } Environment.Exit(0); }
public static void Main() { // Print library information: PrintInfo.PrintLibraryInfo(); // Enable network search: Network.AutoDetectEnabled = true; // Update device list: DeviceList.Update(); // Try to open an oscilloscope with block measurement support and a generator in the same device: Oscilloscope scp = null; Generator gen = null; for (UInt32 i = 0; i < DeviceList.Count; i++) { DeviceListItem item = DeviceList.GetItemByIndex(i); if (item.CanOpen(DeviceType.Oscilloscope) && item.CanOpen(DeviceType.Generator)) { scp = item.OpenOscilloscope(); if ((scp.MeasureModes & Constants.MM_BLOCK) != 0) { gen = item.OpenGenerator(); break; } else { scp.Dispose(); scp = null; } } } if (scp != null && gen != null) { try { // Oscilloscope settings: // Get the number of channels: UInt16 channelCount = Convert.ToUInt16(scp.Channels.Count); // Set measure mode: scp.MeasureMode = MeasureMode.Block; // Set sample frequency: scp.SampleFrequency = 1e6; // 1 MHz // Set record length: scp.RecordLength = 10000; // 10 kS UInt64 recordLength = scp.RecordLength; // Read actual record length. // Set pre sample ratio: scp.PreSampleRatio = 0; // 0 % // For all channels: for (UInt16 ch = 0; ch < channelCount; ch++) { OscilloscopeChannel channel = scp.Channels[ch]; // Enable channel to measure it: channel.Enabled = true; // Set range: channel.Range = 8; // 8 V // Set coupling: channel.Coupling = Coupling.DCV; // DC Volt } // Set trigger timeout: scp.TriggerTimeOut = 1; // 1 s // Disable all channel trigger sources: for (UInt16 ch = 0; ch < channelCount; ch++) { scp.Channels[ch].Trigger.Enabled = false; } // Locate trigger input: TriggerInput triggerInput = scp.TriggerInputs.GetById(Constants.TIID_GENERATOR_NEW_PERIOD); // or Constants.TIID_GENERATOR_START or Constants.TIID_GENERATOR_STOP if (triggerInput == null) { throw new System.Exception("Unknown trigger input!"); } // Enable trigger input: triggerInput.Enabled = true; // Generator settings: // Set signal type: gen.SignalType = SignalType.Triangle; // Set frequency: gen.Frequency = 1e3; // 1 kHz // Set amplitude: gen.Amplitude = 2; // 2 V // Set offset: gen.Offset = 0; // 0 V // Enable output: gen.OutputOn = true; // Print oscilloscope info: PrintInfo.PrintDeviceInfo(scp); // Print generator info: PrintInfo.PrintDeviceInfo(gen); // Start measurement: scp.Start(); // Start signal generation: gen.Start(); // Wait for measurement to complete: while (!scp.IsDataReady) { Thread.Sleep(10); // 10 ms delay, to save CPU time. } // Stop generator: gen.Stop(); // Disable output: gen.OutputOn = false; // Get data: float[][] data = scp.GetData(); // Open file with write/update permissions: string filename = "OscilloscopeGeneratorTrigger.csv"; StreamWriter file = new StreamWriter(filename, false); // Output CSV data: if (File.Exists(filename)) { // Write csv header: file.Write("Sample"); for (UInt16 i = 0; i < channelCount; i++) { file.Write(string.Format(";Ch{0}", i + 1)); } file.Write(Environment.NewLine); // Write the data to csv: for (UInt64 i = 0; i < recordLength; i++) { file.Write(i.ToString()); for (UInt16 ch = 0; ch < channelCount; ch++) { file.Write(";" + data[ch][i].ToString()); } file.Write(Environment.NewLine); } Console.WriteLine("Data written to: " + filename); // Close file: file.Close(); } else { Console.WriteLine("Couldn't open file: " + filename); Environment.Exit(1); } } catch (System.Exception e) { Console.WriteLine("Exception: " + e.Message); Environment.Exit(1); } // Close oscilloscope: scp.Dispose(); scp = null; // Close generator: gen.Dispose(); gen = null; } else { Console.WriteLine("No oscilloscope available with block measurement support!"); Environment.Exit(1); } Environment.Exit(0); }
// -------------------------------------------------------------------------------- // Event Handlers private void buttonGenerate_Click(object sender, EventArgs e) { this.buttonGenerate.Enabled = false; this.checkBoxRealTime.Enabled = false; this.buttonViewFloorDown.Enabled = false; this.buttonViewFloorUp.Enabled = false; // initialize a new maze using sizes specified this.maze = new Maze3D((int)this.numericUpDownWidth.Value, (int)this.numericUpDownHeight.Value, (int)this.numericUpDownLevels.Value); // create the bitmaps for rendering each level of the maze this.floorLevelBitmap = new Bitmap[this.maze.Levels]; for (int floorIndex = 0; floorIndex < this.maze.Levels; floorIndex++) { this.floorLevelBitmap[floorIndex] = new Bitmap(this.maze.Width * cellSize + 2 * offsetX, this.maze.Height * cellSize + 2 * offsetY); } // create the ungenerated floors of the maze InitializeMazeLevelBitmaps(); this.viewLevel = 1; this.pictureBoxCanvas.Image = this.floorLevelBitmap[this.viewLevel - 1]; if (this.checkBoxRealTime.Checked) { this.labelViewingFloor.Enabled = true; this.pictureBoxCanvas.Visible = true; this.setLevelViewButtons(); } else { this.labelViewingFloor.Enabled = false; this.pictureBoxCanvas.Visible = false; this.labelViewingFloor.Text = "Viewing Floor: none"; } // set up the tool strip lable and progress bar int generatorSteps = this.maze.Width * this.maze.Height * this.maze.Levels; this.toolStripProgressBar1.Maximum = generatorSteps; this.toolStripProgressBar1.Value = 0; this.toolStripProgressBar1.Visible = true; int generatorStepCount = 1; this.toolStripStatusLabel2.Visible = true; this.toolStripStatusLabel2.Text = "Generating maze...0%"; // create the maze generator and provide it a reference to the maze it will operate upon Generator generator = new Generator(this.maze); // start the maze generator in manual step mode bool generating = generator.Start(); while (generating) { var stepResult = generator.Step(); Cell changedCell = stepResult.Item1; string changedWall = stepResult.Item2; if (changedCell != null) this.toolStripStatusLabel1.Text = String.Format("Cell: ({0}, {1}, {2})", changedCell.X, changedCell.Y, changedCell.Z); switch (changedWall) { case "Floor": using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z])) { bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4); bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 - 3, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4 - 3); bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 + 3, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4 - 3); } using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z - 1])) { bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4); bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 - 3, this.offsetY + cellSize * changedCell.Y + cellSize / 4 + 3); bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 + 3, this.offsetY + cellSize * changedCell.Y + cellSize / 4 + 3); } break; case "North": using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z])) { bitmapGraphics.DrawLine(Pens.LightGray, this.offsetX + (cellSize * changedCell.X) + 1, this.offsetY + (cellSize * changedCell.Y), this.offsetX + (cellSize * changedCell.X) + cellSize - 1, this.offsetY + (cellSize * changedCell.Y)); } break; case "South": using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z])) { bitmapGraphics.DrawLine(Pens.LightGray, this.offsetX + (cellSize * changedCell.X) + 1, this.offsetY + (cellSize * changedCell.Y) + cellSize, this.offsetX + (cellSize * changedCell.X) + cellSize - 1, this.offsetY + (cellSize * changedCell.Y) + cellSize); } break; case "East": using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z])) { bitmapGraphics.DrawLine(Pens.LightGray, this.offsetX + (cellSize * changedCell.X) + cellSize, this.offsetY + (cellSize * changedCell.Y) + 1, this.offsetX + (cellSize * changedCell.X) + cellSize, this.offsetY + (cellSize * changedCell.Y) + cellSize - 1); } break; case "West": using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z])) { bitmapGraphics.DrawLine(Pens.LightGray, this.offsetX + (cellSize * changedCell.X), this.offsetY + (cellSize * changedCell.Y) + 1, this.offsetX + (cellSize * changedCell.X), this.offsetY + (cellSize * changedCell.Y) + cellSize - 1); } break; case "Ceiling": using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z])) { bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4); bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 - 3, this.offsetY + cellSize * changedCell.Y + cellSize / 4 + 3); bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 + 3, this.offsetY + cellSize * changedCell.Y + cellSize / 4 + 3); } using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z + 1])) { bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4); bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 - 3, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4 - 3); bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4, this.offsetX + cellSize * changedCell.X + cellSize / 2 + 3, this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4 - 3); } break; default: generating = false; break; } if (this.checkBoxRealTime.Checked) { // setting this will force the painting of the picture box this.pictureBoxCanvas.Image = this.floorLevelBitmap[this.viewLevel - 1]; } this.toolStripStatusLabel2.Text = String.Format("Generating maze...{0}%", (int)(generatorStepCount * 100 / generatorSteps)); this.toolStripProgressBar1.SetProgressNoAnimation(generatorStepCount++); Application.DoEvents(); } // fully restore the form to normal if not real-time viewing this.labelViewingFloor.Enabled = true; this.setLevelViewButtons(); this.pictureBoxCanvas.Image = this.floorLevelBitmap[this.viewLevel - 1]; this.pictureBoxCanvas.Visible = true; this.pictureBoxCanvas.Enabled = true; this.buttonGenerate.Enabled = true; this.checkBoxRealTime.Enabled = true; // remove the generation percentage and progress bar this.toolStripStatusLabel2.Visible = false; this.toolStripProgressBar1.Visible = false; // finished message this.toolStripStatusLabel1.Text = String.Format("Generation completed."); // Re-cap // // START: maze generator returns the cell that it is changing and which wall is getting removed // OPTIONAL: update the image of all cells on floor 0 to show the wall selected for removal // OPTIONAL: update the image to show up/down steps in the cell where the floor/ceiling is selected for removal // notify maze generator to perform action // OPTIONAL: regenerate and show floor 0 of the maze // notify maze generator to continue // go back to START if there is more generation to perform // at this point, the maze generation is completed // all cells start out isolated with walls up to all neighbor cells // create list of regions from the maze cells // create image of all cells on floor 0 in the maze // START: pick a random region from the region list // create a list of all of the cells in the region // create a list of all removable walls in the list of cells // pick a random wall in the list of walls // OPTIONAL: update the image of all cells on floor 0 to show the wall selected for removal // OPTIONAL: update the image to show up/down steps in the cell where the floor/ceiling is selected for removal // remove the wall from the containing cell // remove the wall from the newly adjoining cell // combine the region of the newly adjoining cell into the random region that was previously selected // recreate the image of all cells on floor 0 in the maze // go back to START if there is more than one remaining region // at this point, the maze generation is completed }
public static void Main() { // Print library information: PrintInfo.PrintLibraryInfo(); // Enable network search: Network.AutoDetectEnabled = true; // Update device list: DeviceList.Update(); // Try to open a generator: Generator gen = null; for (UInt32 i = 0; i < DeviceList.Count; i++) { DeviceListItem item = DeviceList.GetItemByIndex(i); if (item.CanOpen(DeviceType.Generator)) { gen = item.OpenGenerator(); break; } } if (gen != null) { try { // Set signal type: gen.SignalType = SignalType.Triangle; // Set frequency: gen.Frequency = 100e3; // 100 kHz // Set amplitude: gen.Amplitude = 2; // 2 V // Set offset: gen.Offset = 0; // 0 V // Enable output: gen.OutputOn = true; // Print Generator info: PrintInfo.PrintDeviceInfo(gen); // Start signal generation gen.Start(); // Wait for keystroke: Console.WriteLine("Press Enter to stop signal generation..."); Console.ReadLine(); // Stop generator: gen.Stop(); // Disable output: gen.OutputOn = false; } catch (System.Exception e) { Console.WriteLine("Exception: " + e.Message); Environment.Exit(1); } // Close generator: gen.Dispose(); gen = null; } else { Console.WriteLine("No generator available!"); Environment.Exit(1); } Environment.Exit(0); }
public static void Main() { // Print library information: PrintInfo.PrintLibraryInfo(); // Enable network search: Network.AutoDetectEnabled = true; // Update device list: DeviceList.Update(); // Try to open a generator with arbitrary support: Generator gen = null; for (UInt32 i = 0; i < DeviceList.Count; i++) { DeviceListItem item = DeviceList.GetItemByIndex(i); if (item.CanOpen(DeviceType.Generator)) { gen = item.OpenGenerator(); // Check for arbitrary support: if ((gen.SignalTypes & Constants.ST_ARBITRARY) != 0) { break; } else { gen.Dispose(); gen = null; } } } if (gen != null) { try { // Set signal type: gen.SignalType = SignalType.Arbitrary; // Select frequency mode: gen.FrequencyMode = FrequencyMode.SampleFrequency; // Set frequency: gen.Frequency = 100e3; // 100 kHz // Set amplitude: gen.Amplitude = 2; // 2 V // Set offset: gen.Offset = 0; // 0 V // Enable output: gen.OutputOn = true; // Create signal array: float[] data = new float[8192]; for (UInt16 i = 0; i < data.Length; i++) { data[i] = (float)(Math.Sin(i / 100.0) * (1 - (i / 8192.0))); } // Load the signal array into the generator: gen.SetData(data); // Print generator info: PrintInfo.PrintDeviceInfo(gen); // Start signal generation: gen.Start(); // Wait for keystroke: Console.WriteLine("Press Enter to stop signal generation..."); Console.ReadLine(); // Stop generator: gen.Stop(); // Disable output: gen.OutputOn = false; } catch (System.Exception e) { Console.WriteLine("Exception: " + e.Message); Environment.Exit(1); } // Close generator: gen.Dispose(); gen = null; } else { Console.WriteLine("No generator available with arbitrary support!"); Environment.Exit(1); } Environment.Exit(0); }