rust-ethernet-ip 0.5.2

High-performance EtherNet/IP communication library for Allen-Bradley CompactLogix and ControlLogix PLCs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
# 🦀 Rust EtherNet/IP Driver


> **✅ PRODUCTION READY - PHASE 1 COMPLETE**  
> **This project has successfully completed Phase 1 development and is ready for production use.**  
> The core functionality is fully implemented, tested, and stable, with comprehensive data type support and advanced tag addressing capabilities.  
> **Production release v1.0 is planned for Q4 2025.**

> **🆕 NEW: Go + Next.js Fullstack Example!**
>
> Try the new high-performance Go backend + Next.js frontend demo for real-time, batch, and performance operations.
> [See fullstack example & guide →]examples/gonextjs/README.md

> **🏭 NEW: Professional HMI/SCADA Demo!**
>
> Experience a production-ready HMI dashboard with real-time monitoring, OEE analysis, and industrial data visualization.
> [Try the HMI Demo →]#-hmi-scada-production-demo

[![Rust](https://img.shields.io/badge/rust-1.70+-orange.svg)](https://www.rust-lang.org)
[![Version](https://img.shields.io/badge/version-0.5.2-blue.svg)](https://github.com/sergiogallegos/rust-ethernet-ip/releases)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Performance](https://img.shields.io/badge/performance-3000%2B%20ops%2Fsec-green.svg)]()
[![Status](https://img.shields.io/badge/status-production--ready-brightgreen.svg)]()
[![C# Wrapper](https://img.shields.io/badge/C%23%20wrapper-available-blue.svg)]()
[![Python Wrapper](https://img.shields.io/badge/Python%20wrapper-available-blue.svg)]()
[![Crates.io](https://img.shields.io/crates/v/rust-ethernet-ip.svg)](https://crates.io/crates/rust-ethernet-ip)
[![Documentation](https://docs.rs/rust-ethernet-ip/badge.svg)](https://docs.rs/rust-ethernet-ip)
[![Downloads](https://img.shields.io/crates/d/rust-ethernet-ip.svg)](https://crates.io/crates/rust-ethernet-ip)
[![Sponsor](https://img.shields.io/badge/sponsor-💖-ff69b4.svg)](https://github.com/sponsors/sergiogallegos)

A high-performance, production-ready EtherNet/IP communication library specifically designed for **Allen-Bradley CompactLogix and ControlLogix PLCs**. Built in pure Rust with focus on **PC applications**, offering exceptional performance, memory safety, and comprehensive industrial features.
 
 **📦 Available on [crates.io](https://crates.io/crates/rust-ethernet-ip)**

## 🎯 **Project Focus**


This library is specifically designed for:
- **Allen-Bradley CompactLogix** (L1x, L2x, L3x, L4x, L5x series)
- **Allen-Bradley ControlLogix** (L6x, L7x, L8x series)
- **PC Applications** (Windows, Linux, macOS)
- **Industrial Automation** software and SCADA systems
- **High-performance** data acquisition and control

### ⚠️ **Current Limitations**

- **Slot 0 Only**: Currently supports direct connections to CPUs in slot 0
- **No Remote Rack Support**: Cannot connect to CPUs in remote racks
- **No Multi-Hop Routing**: Complex network topologies not supported
- **Simple Paths Only**: Limited to basic tag path configurations

> **🚀 Routing Support Coming Soon!**  
> Industrial routing support (remote racks, multi-hop, complex topologies) is planned for v0.6.0 and v0.7.0. See [Phase 4 roadmap]#-phase-4-industrial-routing-support--planned for details.

## **Key Features**


### 🔧 **Connection Robustness**

- **Automatic session management** with proper registration/unregistration
- **Connection health monitoring** with configurable timeouts
- **Network resilience** handling for industrial environments
- **Comprehensive error handling** with detailed CIP error mapping

### 📍 **Advanced Tag Addressing****COMPLETED**

- **Program-scoped tags**: `Program:MainProgram.Tag1`
- **Array element access**: `MyArray[5]`, `MyArray[1,2,3]`
- **Bit-level operations**: `MyDINT.15` (access individual bits)
- **UDT member access**: `MyUDT.Member1.SubMember`
- **String operations**: `MyString.LEN`, `MyString.DATA[5]`
- **Complex nested paths**: `Program:Production.Lines[2].Stations[5].Motor.Status.15`

### 📊 **Complete Data Type Support****COMPLETED**

All Allen-Bradley native data types with proper CIP encoding:
- **BOOL** - Boolean values (CIP type 0x00C1)
- **SINT** - 8-bit signed integer (-128 to 127, CIP type 0x00C2)
- **INT** - 16-bit signed integer (-32,768 to 32,767, CIP type 0x00C3)
- **DINT** - 32-bit signed integer (-2.1B to 2.1B, CIP type 0x00C4)
- **LINT** - 64-bit signed integer (CIP type 0x00C5)
- **USINT** - 8-bit unsigned integer (0 to 255, CIP type 0x00C6)
- **UINT** - 16-bit unsigned integer (0 to 65,535, CIP type 0x00C7)
- **UDINT** - 32-bit unsigned integer (0 to 4.3B, CIP type 0x00C8)
- **ULINT** - 64-bit unsigned integer (CIP type 0x00C9)
- **REAL** - 32-bit IEEE 754 float (CIP type 0x00CA)
- **LREAL** - 64-bit IEEE 754 double (CIP type 0x00CB)
- **STRING** - Variable-length strings (CIP type 0x00DA)
- **UDT** - User Defined Types with full nesting support (CIP type 0x00A0)

### 🔗 **Language Bindings****COMPLETED**


#### **C# Integration****COMPLETED**

- **Complete C# wrapper** with all data types
- **22 FFI functions** for seamless integration
- **Type-safe API** with comprehensive error handling
- **NuGet package ready** for easy distribution
- **Cross-platform support** (Windows, Linux, macOS)

#### **Go Integration****NEW in v0.4.0**

- **CGO wrapper** with comprehensive API coverage
- **Type-safe Go bindings** for all PLC data types
- **Connection management** and health monitoring
- **Error handling** with Go-idiomatic patterns
- **Full-stack example** with Go backend + Next.js frontend ([see example]examples/gonextjs/README.md)

#### **Python Integration****NEW in v0.4.0**

- **PyO3-based Python wrapper** with full API coverage
- **Type-safe Python bindings** for all PLC data types
- **Synchronous and asynchronous APIs** for flexible usage
- **Comprehensive error handling** with Python exceptions
- **Easy installation** via pip or maturin
- **Cross-platform support** (Windows, Linux, macOS)
- **Write_tag method now correctly returns a boolean indicating success or failure**

### ⚠️ **Comprehensive Error Handling****COMPLETED**

- **Detailed CIP error mapping** with 40+ error codes
- **Network-level diagnostics** and troubleshooting
- **Granular error types** for precise error handling
- **Automatic error recovery** for transient issues

### 🏗️ **Build System****COMPLETED**

- **Automated build scripts** for Windows and Linux/macOS
- **Cross-platform compilation** with proper library generation
- **Comprehensive testing** with 30+ unit tests
- **CI/CD ready** with GitHub Actions examples

### **Real-Time Subscriptions****NEW in v0.4.0**

- **Real-time tag monitoring** with configurable update intervals (1ms - 10s)
- **Event-driven notifications** for tag value changes
- **Multi-tag subscriptions** supporting hundreds of concurrent monitors
- **Automatic reconnection** and error recovery
- **Memory-efficient engine** with minimal CPU overhead

### 🚀 **High-Performance Batch Operations****NEW in v0.4.0**

- **Batch read operations** - read up to 100+ tags in a single request
- **Batch write operations** - write multiple tags atomically
- **Parallel processing** with concurrent execution
- **Transaction support** with rollback capabilities
- **2,000+ ops/sec throughput** with intelligent packet packing

## 🏭 **HMI/SCADA Production Demo**


Experience a **professional-grade HMI dashboard** showcasing real-world industrial data tracking and monitoring capabilities. This demo demonstrates the library's potential for building production-ready SCADA systems and industrial dashboards.

![HMI/SCADA Production Demo](images/SampleHMI.png)

### 🎯 **Demo Features**

- **📊 Real-time Production Monitoring** - Live production counts, targets, and progress tracking
- **📈 OEE Analysis** - Overall Equipment Effectiveness with availability, performance, and quality metrics
- **🌡️ Process Parameters** - Temperature, pressure, vibration monitoring with color-coded alerts
- **⚙️ Machine Status** - Real-time machine state, shift information, and operator tracking
- **🔧 Maintenance Management** - Scheduled maintenance tracking and history
- **📱 Responsive Design** - Works seamlessly on desktop, tablet, and mobile devices

### 🚀 **Perfect for Demonstrations**

This demo showcases:
- **High-frequency data collection** (1-second intervals)
- **Professional HMI aesthetics** with industrial-grade visualizations
- **Real-world metrics** that matter to production managers
- **Scalable architecture** for larger SCADA systems
- **Modern web technologies** for cross-platform deployment

### 🏷️ **Required PLC Tags**

The demo reads 13 industrial tags including machine status, production metrics, process parameters, and OEE data. See the [Go + Next.js example](examples/gonextjs/README.md) for complete tag specifications and setup instructions.

**Try it now:** Navigate to the "HMI Demo" tab in the [Go + Next.js fullstack example](examples/gonextjs/README.md)!

## 🚀 **Performance Characteristics**


Optimized for PC applications with excellent performance:

> **🆕 Latest Performance Improvements (v0.5.2)**
> 
> Recent optimizations have delivered significant performance gains:
> - **Memory allocation improvements**: 20-30% reduction in allocation overhead for network operations
> - **Batch operations**: 3-10x faster than individual operations
> - **Code quality**: Enhanced with idiomatic Rust patterns and clippy optimizations
> - **Network efficiency**: Optimized packet building with pre-allocated buffers

| Operation | Throughput | Latency | Memory Usage |
|-----------|------------|---------|--------------|
| Single Tag Read | 3,000+ ops/sec | <1ms | ~800B |
| Single Tag Write | 1,500+ ops/sec | <2ms | ~800B |
| Batch Operations | 2,000+ ops/sec | 5-20ms | ~2KB |
| Real-time Subscriptions | 1,000+ tags/sec | 1-10ms | ~1KB |
| Tag Path Parsing | 10,000+ ops/sec | <0.1ms | ~1KB |
| Connection Setup | N/A | 50-200ms | ~4KB |
| Memory per Connection | N/A | N/A | ~4KB base |

## 📋 **Development Roadmap**


### 🔥 **Phase 1: Core Enhancements****COMPLETED - June 2025**

- [x] Basic tag read/write operations
- [x] Connection management and session handling
- [x] **Enhanced tag path parsing** (Program-scoped, arrays, bit access)
- [x] **Complete data type support** (All Allen-Bradley types)
- [x] **C# wrapper integration** (22 FFI functions)
- [x] **Comprehensive testing** (30+ unit tests)
- [x] **Build automation** (Cross-platform build scripts)
- [x] **Documentation** (Examples, API docs, guides)

### **Phase 2: Advanced Features****COMPLETED - June 2025**

- [x] **Batch operations** (multi-tag read/write) ✅ **COMPLETED**
- [x] **Real-time subscriptions** (tag change notifications) ✅ **COMPLETED**
- [x] **Performance optimizations** (20% faster operations + memory improvements) ✅ **COMPLETED**
- [x] **Enhanced error handling & recovery****COMPLETED**

### 🎯 **Phase 3: Production Ready****IN PROGRESS**

- [x] **Production monitoring** - Comprehensive metrics and health checks
- [x] **Configuration management** - Production-ready config system
- [x] **Error handling** - Detailed CIP error mapping and recovery
- [x] **Performance optimization** - Batch operations and connection pooling
- [ ] **Stress testing** - Long-term stability validation (in progress)
- [ ] **Performance benchmarking** - Comparative analysis with other libraries (in progress)
- [ ] **Production deployment** - Docker containers and deployment guides (in progress)
- [x] **Community features** - Discord server, GitHub discussions, sponsorship program

### 🚀 **Phase 4: Industrial Routing Support** 📋 **PLANNED**

- [ ] **Basic slot configuration** - Support for CPUs in slots 1-31 (v0.6.0)
- [ ] **Simple backplane routing** - Direct backplane communication (v0.6.0)
- [ ] **Route path building** - CIP route path construction (v0.6.0)
- [ ] **Remote rack support** - Connect to remote racks via network (v0.7.0)
- [ ] **Network routing** - Multi-hop network routing (v0.7.0)
- [ ] **Path validation** - Route path verification and error handling (v0.7.0)
- [ ] **Advanced routing** - Complex network topologies (v0.8.0)
- [ ] **Route discovery** - Automatic path detection (v0.8.0)

## 🛠️ **Installation**


### 📦 **Rust Library (Crates.io)**


The easiest way to get started is by adding the crate to your `Cargo.toml`:

```toml
[dependencies]
rust-ethernet-ip = "0.5.2"
tokio = { version = "1.0", features = ["full"] }

### Rust Library

Add to your `Cargo.toml`:

```toml
[dependencies]
rust-ethernet-ip = "0.5.2"
tokio = { version = "1.0", features = ["full"] }
```

### C# Wrapper

Install via NuGet:

```xml
<PackageReference Include="RustEtherNetIp" Version="0.5.2" />
```

Or via Package Manager Console:
```powershell
Install-Package RustEtherNetIp
```

### Python Wrapper

Install via pip:
```bash
pip install rust-ethernet-ip
```

Or build from source using maturin:
```bash
cd pywrapper
maturin develop
```

## 📖 **Quick Start**


### Rust Usage


```rust
use rust_ethernet_ip::{EipClient, PlcValue};

#[tokio::main]

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Connect to CompactLogix PLC
    let mut client = EipClient::connect("192.168.1.100:44818").await?;
    
    // Read different data types
    let motor_running = client.read_tag("Program:Main.MotorRunning").await?;
    let production_count = client.read_tag("Program:Main.ProductionCount").await?;
    let temperature = client.read_tag("Program:Main.Temperature").await?;
    
    // Write values
    client.write_tag("Program:Main.SetPoint", PlcValue::Dint(1500)).await?;
    client.write_tag("Program:Main.StartButton", PlcValue::Bool(true)).await?;
    
    println!("Motor running: {:?}", motor_running);
    println!("Production count: {:?}", production_count);
    println!("Temperature: {:?}", temperature);
    
    Ok(())
}
```

### C# Usage


```csharp
using RustEtherNetIp;

using var client = new EtherNetIpClient();
if (client.Connect("192.168.1.100:44818"))
{
    // Read different data types
    bool motorRunning = client.ReadBool("Program:Main.MotorRunning");
    int productionCount = client.ReadDint("Program:Main.ProductionCount");
    float temperature = client.ReadReal("Program:Main.Temperature");
    
    // Write values
    client.WriteDint("Program:Main.SetPoint", 1500);
    client.WriteBool("Program:Main.StartButton", true);
    
    Console.WriteLine($"Motor running: {motorRunning}");
    Console.WriteLine($"Production count: {productionCount}");
    Console.WriteLine($"Temperature: {temperature:F1}°C");
}
```

### Python Usage


```python
from rust_ethernet_ip import PyEipClient

def main():
    # Create a client and connect to the PLC
    client = PyEipClient(addr="192.168.0.1")
    if not client.connect():
        print("Failed to connect to PLC")
        return

    try:
        # Read a DINT value
        value = client.read_dint("TestDINT")
        print("Read TestDINT:", value)
        
        # Write a new value
        client.write_dint("TestDINT", 42)
        print("Wrote 42 to TestDINT")
        
    except Exception as e:
        print("Error:", e)

if __name__ == "__main__":
    main()
```

### Advanced Tag Addressing


```rust
// Program-scoped tags
let value = client.read_tag("Program:MainProgram.Tag1").await?;

// Array elements
let array_element = client.read_tag("Program:Main.MyArray[5]").await?;
let multi_dim = client.read_tag("Program:Main.Matrix[1,2,3]").await?;

// Bit access
let bit_value = client.read_tag("Program:Main.StatusWord.15").await?;

// UDT members
let udt_member = client.read_tag("Program:Main.MotorData.Speed").await?;
let nested_udt = client.read_tag("Program:Main.Recipe.Step1.Temperature").await?;

// String operations
let string_length = client.read_tag("Program:Main.ProductName.LEN").await?;
let string_char = client.read_tag("Program:Main.ProductName.DATA[0]").await?;
```

### Complete Data Type Examples


```rust
// All supported data types
let bool_val = client.read_tag("BoolTag").await?;           // BOOL
let sint_val = client.read_tag("SintTag").await?;           // SINT (-128 to 127)
let int_val = client.read_tag("IntTag").await?;             // INT (-32,768 to 32,767)
let dint_val = client.read_tag("DintTag").await?;           // DINT (-2.1B to 2.1B)
let lint_val = client.read_tag("LintTag").await?;           // LINT (64-bit signed)
let usint_val = client.read_tag("UsintTag").await?;         // USINT (0 to 255)
let uint_val = client.read_tag("UintTag").await?;           // UINT (0 to 65,535)
let udint_val = client.read_tag("UdintTag").await?;         // UDINT (0 to 4.3B)
let ulint_val = client.read_tag("UlintTag").await?;         // ULINT (64-bit unsigned)
let real_val = client.read_tag("RealTag").await?;           // REAL (32-bit float)
let lreal_val = client.read_tag("LrealTag").await?;         // LREAL (64-bit double)
let string_val = client.read_tag("StringTag").await?;       // STRING
let udt_val = client.read_tag("UdtTag").await?;             // UDT
```

## **Batch Operations****COMPLETED**


**Dramatically improve performance** with batch operations that execute multiple read/write operations in a single network packet. Perfect for data acquisition, recipe management, and coordinated control scenarios.

### 🚀 **Performance Benefits**

- **3-10x faster** than individual operations
- **Reduced network traffic** (1-5 packets instead of N packets for N operations)
- **Lower PLC CPU usage** due to fewer connection handling overheads
- **Better throughput** for data collection and control applications

### 📊 **Use Cases**

- **Data acquisition**: Reading multiple sensor values simultaneously
- **Recipe management**: Writing multiple setpoints at once
- **Status monitoring**: Reading multiple status flags efficiently
- **Coordinated control**: Atomic operations across multiple tags

### 🔧 **Basic Batch Reading**


```rust
use rust_ethernet_ip::{EipClient, BatchOperation, PlcValue};

// Read multiple tags in a single operation
let tags_to_read = vec![
    "ProductionCount",
    "Temperature_1", 
    "Temperature_2",
    "Pressure_1",
    "FlowRate",
];

let results = client.read_tags_batch(&tags_to_read).await?;
for (tag_name, result) in results {
    match result {
        Ok(value) => println!("📊 {}: {:?}", tag_name, value),
        Err(error) => println!("❌ {}: {}", tag_name, error),
    }
}
```

### ✏️ **Basic Batch Writing**


```rust
// Write multiple tags in a single operation
let tags_to_write = vec![
    ("SetPoint_1", PlcValue::Real(75.5)),
    ("SetPoint_2", PlcValue::Real(80.0)),
    ("EnableFlag", PlcValue::Bool(true)),
    ("ProductionMode", PlcValue::Dint(2)),
    ("RecipeNumber", PlcValue::Dint(42)),
];

let results = client.write_tags_batch(&tags_to_write).await?;
for (tag_name, result) in results {
    match result {
        Ok(()) => println!("✅ {}: Write successful", tag_name),
        Err(error) => println!("❌ {}: {}", tag_name, error),
    }
}
```

### 🔄 **Mixed Operations (Reads + Writes)**


```rust
use rust_ethernet_ip::BatchOperation;

let operations = vec![
    // Read current values
    BatchOperation::Read { tag_name: "CurrentTemp".to_string() },
    BatchOperation::Read { tag_name: "CurrentPressure".to_string() },
    
    // Write new setpoints
    BatchOperation::Write { 
        tag_name: "TempSetpoint".to_string(), 
        value: PlcValue::Real(78.5) 
    },
    BatchOperation::Write { 
        tag_name: "PressureSetpoint".to_string(), 
        value: PlcValue::Real(15.2) 
    },
    
    // Update control flags
    BatchOperation::Write { 
        tag_name: "AutoModeEnabled".to_string(), 
        value: PlcValue::Bool(true) 
    },
];

let results = client.execute_batch(&operations).await?;
for result in results {
    match result.operation {
        BatchOperation::Read { tag_name } => {
            match result.result {
                Ok(Some(value)) => println!("📊 Read {}: {:?} ({}μs)", 
                    tag_name, value, result.execution_time_us),
                Err(error) => println!("❌ Read {}: {}", tag_name, error),
            }
        }
        BatchOperation::Write { tag_name, .. } => {
            match result.result {
                Ok(_) => println!("✅ Write {}: Success ({}μs)", 
                    tag_name, result.execution_time_us),
                Err(error) => println!("❌ Write {}: {}", tag_name, error),
            }
        }
    }
}
```

### ⚙️ **Advanced Configuration**


```rust
use rust_ethernet_ip::BatchConfig;

// High-performance configuration
let high_perf_config = BatchConfig {
    max_operations_per_packet: 50,      // More operations per packet
    max_packet_size: 4000,              // Larger packets for modern PLCs
    packet_timeout_ms: 1000,            // Faster timeout
    continue_on_error: true,            // Don't stop on single failures
    optimize_packet_packing: true,      // Optimize packet efficiency
};

client.configure_batch_operations(high_perf_config);

// Conservative/reliable configuration
let conservative_config = BatchConfig {
    max_operations_per_packet: 10,      // Fewer operations per packet
    max_packet_size: 504,               // Smaller packets for compatibility
    packet_timeout_ms: 5000,            // Longer timeout
    continue_on_error: false,           // Stop on first error
    optimize_packet_packing: false,     // Preserve exact operation order
};

client.configure_batch_operations(conservative_config);
```

### 📈 **Performance Comparison Example**


```rust
use std::time::Instant;

let tags = vec!["Tag1", "Tag2", "Tag3", "Tag4", "Tag5"];

// Individual operations (traditional approach)
let individual_start = Instant::now();
for tag in &tags {
    let _ = client.read_tag(tag).await?;
}
let individual_duration = individual_start.elapsed();

// Batch operations (optimized approach)  
let batch_start = Instant::now();
let _ = client.read_tags_batch(&tags).await?;
let batch_duration = batch_start.elapsed();

let speedup = individual_duration.as_nanos() as f64 / batch_duration.as_nanos() as f64;
println!("📈 Performance improvement: {:.1}x faster with batch operations!", speedup);
```

### 🚨 **Error Handling**


```rust
// Batch operations provide detailed error information per operation
match client.execute_batch(&operations).await {
    Ok(results) => {
        let mut success_count = 0;
        let mut error_count = 0;
        
        for result in results {
            match result.result {
                Ok(_) => success_count += 1,
                Err(_) => error_count += 1,
            }
        }
        
        println!("📊 Results: {} successful, {} failed", success_count, error_count);
        println!("📈 Success rate: {:.1}%", 
            (success_count as f32 / (success_count + error_count) as f32) * 100.0);
    }
    Err(e) => println!("❌ Entire batch failed: {}", e),
}
```

### 🎯 **Best Practices**


- **Use batch operations for 3+ operations** to see significant performance benefits
- **Group similar operations** (reads together, writes together) for optimal packet packing
- **Adjust max_operations_per_packet** based on your PLC's capabilities (10-50 typical)
- **Use higher packet sizes** (up to 4000 bytes) for modern CompactLogix/ControlLogix PLCs
- **Enable continue_on_error** for data collection scenarios where partial results are acceptable
- **Disable optimize_packet_packing** if precise operation order is critical for your application

## 🏗️ **Building**


### Quick Build

```bash
# Windows

build.bat

# Linux/macOS

./build.sh
```

### Manual Build

```bash
# Build Rust library

cargo build --release --lib

# Copy to C# project (Windows)

copy target\release\rust_ethernet_ip.dll csharp\RustEtherNetIp\

# Build C# wrapper

cd csharp/RustEtherNetIp
dotnet build --configuration Release
```

See [BUILD.md](BUILD.md) for comprehensive build instructions.

## 🧪 **Testing**


Run the comprehensive test suite:

```bash
# Rust unit tests (30+ tests)

cargo test

# C# wrapper tests

cd csharp/RustEtherNetIp.Tests
dotnet test

# Run examples

cargo run --example advanced_tag_addressing
cargo run --example data_types_showcase
```

## 🎯 **Examples**


Explore comprehensive examples demonstrating all library capabilities across different platforms:

### **🌐 TypeScript + React Dashboard** *(Recommended)*

Modern web-based PLC dashboard with real-time monitoring and advanced features.

```bash
# Start backend API

cd examples/AspNetExample
dotnet run

# Start frontend (new terminal)

cd examples/TypeScriptExample/frontend
npm install && npm run dev
```

**Features:**
- **Modern UI/UX** with glassmorphism design and responsive layout
-**Real-time monitoring** with live tag updates and performance metrics
-**Complete data type support** for all 13 Allen-Bradley types
-**Advanced tag addressing** with interactive examples
-**Type-safe API** with comprehensive TypeScript interfaces
-**Professional features** including benchmarking and activity logging

**Perfect for:** Web applications, dashboards, remote monitoring, modern industrial HMIs

### **🖥️ WPF Desktop Application**

Rich desktop application with MVVM architecture and modern UI.

```bash
cd examples/WpfExample
dotnet run
```

**Features:**
- **MVVM architecture** with CommunityToolkit.Mvvm
-**Real-time tag monitoring** with automatic refresh
-**Advanced tag discovery** with type detection
-**Performance benchmarking** with visual metrics
-**Comprehensive logging** with timestamped activity

**Perfect for:** Desktop HMIs, engineering tools, maintenance applications

### **🪟 WinForms Application**

Traditional Windows Forms application with familiar UI patterns.

```bash
cd examples/WinFormsExample
dotnet run
```

**Features:**
- **Classic Windows UI** with familiar controls
-**Connection monitoring** with automatic reconnection
-**Tag operations** with validation and error handling
-**Performance testing** with real-time metrics
-**Industrial styling** with professional appearance

**Perfect for:** Legacy system integration, simple HMIs, maintenance tools

### **🌐 ASP.NET Core Web API**

RESTful API backend providing HTTP access to PLC functionality.

```bash
cd examples/AspNetExample
dotnet run
```

**Features:**
- **RESTful endpoints** for all PLC operations
-**Swagger documentation** with interactive API explorer
-**Type-safe operations** with comprehensive validation
-**Performance monitoring** with built-in benchmarking
-**Production-ready** with proper error handling and logging

**Perfect for:** Web services, microservices, system integration, mobile backends

### **🦀 Rust Examples**

Native Rust examples demonstrating core library functionality.

```bash
# Advanced tag addressing showcase

cargo run --example advanced_tag_addressing

# Complete data types demonstration

cargo run --example data_types_showcase

# Batch operations performance demo

cargo run --example batch_operations_demo
```

**Features:**
- **Advanced tag parsing** with complex path examples
-**All data types** with encoding demonstrations
-**Performance examples** with async/await patterns
-**Error handling** with comprehensive error types
-**Batch operations** with performance comparisons and configuration examples

**Perfect for:** Rust applications, embedded systems, high-performance scenarios

### **🐹 Go + Next.js Fullstack Example** *(NEW in v0.4.0!)*

Modern fullstack demo with a Go backend (using the Rust Go wrapper) and a Next.js (TypeScript) frontend for real-time, batch, and performance operations.

```bash
# Start backend

cd examples/gonextjs/backend
go run .

# Start frontend (new terminal)

cd ../frontend
npm install && npm run dev
```

**Features:**
- **Go backend** using the Rust EtherNet/IP Go wrapper (FFI)
-**Next.js frontend** (TypeScript, Tailwind, App Router)
-**Batch read/write** and individual tag operations
-**Performance benchmarking** (ops/sec, latency)
-**Real-time tag updates** via WebSocket
-**Comprehensive PLC data type support**
-**Modern, responsive UI**
-**🏭 Professional HMI/SCADA Demo** - Production-ready dashboard with OEE analysis, process monitoring, and industrial data visualization

**Perfect for:** Modern web dashboards, Go/TypeScript fullstack apps, real-time industrial monitoring, HMI/SCADA systems

### **⚡ Vue.js 3 + TypeScript Frontend** *(NEW in v0.4.0!)*

Modern Vue.js 3 frontend with TypeScript, Tailwind CSS, and Pinia state management, designed to integrate with ASP.NET Core backends.

```bash
# Start backend API

cd examples/AspNetExample
dotnet run

# Start Vue.js frontend (new terminal)

cd examples/VueExample
npm install && npm run dev
```

**Features:**
- **Vue.js 3** with Composition API and TypeScript
-**Tailwind CSS** for modern, responsive design
-**Pinia state management** for application state
-**Backend detection system** for automatic ASP.NET Core port discovery
-**Component-based architecture** with reusable UI components
-**Real-time connection monitoring** with PLC status display
-**Tag operations interface** for read/write operations
-**Professional dashboard** with metrics and activity logging
-**Development tools** including BackendDetector for debugging

**Perfect for:** Modern web applications, Vue.js-based HMIs, industrial dashboards, ASP.NET Core integration

### **🚀 Quick Start Guide**


1. **Choose your platform:**
   - **Web/Modern UI** → TypeScript + React Dashboard or Vue.js 3 + TypeScript
   - **Desktop/Windows** → WPF or WinForms Application  
   - **Web API/Services** → ASP.NET Core Web API
   - **Native/Performance** → Rust Examples

2. **Start the backend** (for web examples):
   ```bash
   cd examples/AspNetExample

   dotnet run

   ```

3. **Run your chosen example** and connect to your PLC at `192.168.0.1:44818`

4. **Explore features:**
   - Tag discovery with advanced addressing
   - Real-time monitoring and benchmarking
   - All 13 Allen-Bradley data types
   - Professional error handling and logging

### **📁 Example Structure**

```
examples/
├── TypeScriptExample/          # React + TypeScript dashboard
│   ├── frontend/              # Modern web UI
│   ├── start-backend.bat      # Backend startup script
│   └── start-frontend.bat     # Frontend startup script
├── VueExample/                 # Vue.js 3 + TypeScript frontend
│   ├── src/                   # Vue.js source code
│   ├── start-frontend.bat     # Frontend startup script
│   └── README.md              # Comprehensive documentation
├── WpfExample/                # WPF desktop application
├── WinFormsExample/           # WinForms desktop application
├── AspNetExample/             # ASP.NET Core Web API
├── gonextjs/                  # Go + Next.js fullstack example
└── rust-examples/             # Native Rust examples
    ├── advanced_tag_addressing.rs
    ├── data_types_showcase.rs
    └── batch_operations_demo.rs
```

Each example includes comprehensive documentation, setup instructions, and demonstrates different aspects of the library's capabilities.

## 📚 **Documentation**


- **[API Documentation]https://docs.rs/rust-ethernet-ip** - Complete API reference
- **[Examples]examples/** - Practical usage examples
- **[Build Guide]BUILD.md** - Comprehensive build instructions
- **[C# Wrapper Guide]csharp/RustEtherNetIp/README.md** - C# integration documentation
- **[Changelog]CHANGELOG.md** - Version history and changes
- **[Crates.io Page]https://crates.io/crates/rust-ethernet-ip** - Official crate registry page

## 💖 **Sponsor This Project**


This project is developed with ❤️ for the industrial automation community. If you find this library valuable for your projects, please consider sponsoring its development!

### 🎯 **Why Sponsor?**

- **🚀 Accelerate Development** - Help fund new features, performance improvements, and platform support
- **🐛 Priority Bug Fixes** - Get faster resolution of issues affecting your production systems
- **💡 Feature Requests** - Influence the roadmap with your specific industrial automation needs
- **📚 Enhanced Documentation** - Support creation of comprehensive guides and tutorials
- **🔧 Professional Support** - Access to direct developer support for complex implementations

### 💰 **Sponsorship Tiers**

- **☕ Coffee** - Show appreciation for the project
- **🚀 Feature Sponsor** - Fund specific feature development
- **🏭 Enterprise Sponsor** - Priority support and custom development
- **🌟 Platinum Sponsor** - Direct collaboration and roadmap input

### 🎁 **Sponsor Benefits**

- **Priority issue resolution** for production-critical bugs
- **Direct access** to development team for technical questions
- **Early access** to new features and beta releases
- **Custom feature development** for your specific use cases
- **Recognition** in project documentation and releases

**[Sponsor on GitHub →](https://github.com/sponsors/sergiogallegos)**

### 💬 **Feedback & Feature Requests**


We value your input! Help us improve the library by sharing:

#### 🐛 **Bug Reports**

- **Production Issues** - Critical bugs affecting your systems
- **Performance Problems** - Slow operations or memory issues
- **Compatibility Issues** - Problems with specific PLC models or configurations
- **Error Handling** - Unexpected errors or unclear error messages

#### 💡 **Feature Requests**

- **New Data Types** - Additional Allen-Bradley data type support
- **Platform Support** - New operating systems or architectures
- **Performance Features** - Batch operations, caching, or optimization requests
- **Integration Features** - New language bindings or framework integrations
- **Industrial Features** - SCADA-specific functionality, alarms, or trending

#### 📊 **Use Case Sharing**

- **Success Stories** - How you're using the library in production
- **Performance Metrics** - Real-world performance data from your applications
- **Integration Examples** - Custom implementations or workarounds
- **Best Practices** - Tips for other users in similar industries

**[Submit Feedback →](https://github.com/sergiogallegos/rust-ethernet-ip/issues/new/choose)**

## 🤝 **Community & Support**


- **[Discord Server]https://discord.gg/uzaM3tua** - Community discussions, support, and development updates
- **[GitHub Issues]https://github.com/sergiogallegos/rust-ethernet-ip/issues** - Bug reports and feature requests
- **[GitHub Discussions]https://github.com/sergiogallegos/rust-ethernet-ip/discussions** - General questions and ideas 
- **[Crates.io]https://crates.io/crates/rust-ethernet-ip** - Official Rust package registry

## 🙏 **Inspiration**


This project draws inspiration from excellent libraries in the industrial automation space:
- **[pylogix]https://github.com/dmroeder/pylogix** - Python library for Allen-Bradley PLCs
- **[pycomm3]https://github.com/ottowayi/pycomm3** - Python library for Allen-Bradley PLCs
- **[gologix]https://github.com/danomagnum/gologix** - Go library for Allen-Bradley PLCs
- **[libplctag]https://github.com/libplctag/libplctag** - Cross-platform PLC communication library

## 🚀 **Contributing**


We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on:
- Code style and standards
- Testing requirements
- Pull request process
- Development setup

## ⚠️ **Disclaimer and Liability**


### **Use at Your Own Risk**

This library is provided "AS IS" without warranty of any kind. Users assume full responsibility for its use in their applications and systems.

### **No Warranties**

The developers and contributors make **NO WARRANTIES, EXPRESS OR IMPLIED**, including but not limited to:
- **Merchantability** or fitness for a particular purpose
- **Reliability** or availability of the software
- **Accuracy** of data transmission or processing
- **Safety** for use in critical or production systems

### **Industrial Safety Responsibility**

- **🏭 Industrial Use:** Users are solely responsible for ensuring this library meets their industrial safety requirements
- **🔒 Safety Systems:** This library should NOT be used for safety-critical applications without proper validation
- **⚙️ Production Systems:** Thoroughly test in non-production environments before deploying to production systems
- **📋 Compliance:** Users must ensure compliance with all applicable industrial standards and regulations

### **Limitation of Liability**

Under no circumstances shall the developers, contributors, or associated parties be liable for:
- **Equipment damage** or malfunction
- **Production downtime** or operational disruptions  
- **Data loss** or corruption
- **Personal injury** or property damage
- **Financial losses** of any kind
- **Consequential or indirect damages**

### **User Responsibilities**

By using this library, you acknowledge and agree that:
- You have the technical expertise to properly implement and test the library
- You will perform adequate testing before production deployment
- You will implement appropriate safety measures and fail-safes
- You understand the risks associated with industrial automation systems
- You accept full responsibility for any consequences of using this library

### **Indemnification**

Users agree to indemnify and hold harmless the developers and contributors from any claims, damages, or liabilities arising from the use of this library.

---

**⚠️ IMPORTANT: This disclaimer is an integral part of the license terms. Use of this library constitutes acceptance of these terms.**

## 📄 **License**


This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

**Built with ❤️ for the industrial automation community**

## 📦 Examples


- **C# + React**: Modern web and desktop examples using the C# wrapper
- **Go + Next.js**: [Fullstack Go backend + Next.js frontend example]examples/gonextjs/README.md (**NEW in v0.4.0!**)
- **Vue.js 3 + TypeScript**: [Modern Vue.js frontend with ASP.NET Core integration]examples/VueExample/README.md (**NEW in v0.4.0!**)
- **TypeScript + ASP.NET**: Classic React + ASP.NET example
- ...and more in the `examples/` directory

## 🏗️ Build All


To build all wrappers, libraries, and examples (including Go + Next.js and Vue.js):

```bash
./build-all.bat
```

This script builds:
- Rust library (DLL/SO/DYLIB)
- C# wrapper and tests
- Go wrapper and tests
- All example backends and frontends (C#, Go, TypeScript, Next.js, Vue.js)

See [BUILD.md](BUILD.md) for details.

## 🆕 Version


**Current Release:** v0.5.2 ([Release Notes](RELEASE_NOTES_v0.5.0.md))

## 📝 Changelog


See [CHANGELOG.md](CHANGELOG.md) for a full list of changes.

## 🚀 Release Notes


See [RELEASE_NOTES_v0.5.0.md](RELEASE_NOTES_v0.5.0.md) for detailed release notes and migration info.

## 🚀 Quick Start: Go + Next.js Fullstack Example


- See [examples/gonextjs/README.md]examples/gonextjs/README.md for step-by-step instructions.
- Features: Go backend (using Rust FFI), Next.js frontend, batch ops, real-time, performance, and more.