This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cfnet:cfheader:csharp:index [2026/05/29 05:50] – [CFHEADER .NET (C#, VB.NET) API] mfranklin | cfnet:cfheader:csharp:index [2026/05/29 06:06] (current) – [Simple Digital Output Example] mfranklin | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| After [[cfnet: | After [[cfnet: | ||
| - | Debug the entire solution on the Windows development machine before deploying to an ARM Linux or other target device. | + | |
| + | ===== Simple Digital Output Example ===== | ||
| <code csharp> | <code csharp> | ||
| + | using ComfileTech.Cfnet.Cfheader; | ||
| + | |||
| var cfheader0 = Cfheader.Instances[0]; | var cfheader0 = Cfheader.Instances[0]; | ||
| - | var digitalOutputModule0 | + | var DOModule0 |
| cfheader0.Open(); | cfheader0.Open(); | ||
| Line 13: | Line 16: | ||
| while (true) | while (true) | ||
| { | { | ||
| - | | + | foreach (var channel in DOModule0.Channels.Concat(DOModule0.Channels.Reverse())) |
| - | | + | |
| { | { | ||
| - | | + | foreach (var state in new[] { true, false }) |
| - | } | + | { |
| - | + | channel.State = state; | |
| - | // Blink each output in decreasing order | + | |
| - | | + | Thread.Sleep(50); |
| - | | + | } |
| - | channel.Blink(); | + | |
| - | | + | |
| - | } | + | |
| - | + | ||
| - | static class Extensions | + | |
| - | { | + | |
| - | public static void Blink(this DigitalOutputModule.Channel channel) | + | |
| - | { | + | |
| - | // Toggle the channel' | + | |
| - | | + | |
| - | + | ||
| - | // Delay for 50ms | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | channel.Toggle(); | + | |
| - | | + | |
| - | + | ||
| - | public static void Toggle(this DigitalOutputModule.Channel channel) | + | |
| - | { | + | |
| - | // Toggle state | + | |
| - | channel.State = !channel.State; | + | |
| - | + | ||
| - | // Write the state to the module | + | |
| - | channel.Module.Header.Sync(); | + | |
| } | } | ||
| } | } | ||
| Line 52: | Line 29: | ||
| {{ : | {{ : | ||
| + | |||
| + | Debug the entire solution on the Windows development machine before deploying to an ARM Linux or other target device. | ||
| ===== Contents ===== | ===== Contents ===== | ||