import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:modbus_client/modbus_client.dart'; import 'package:modbus_client_tcp/modbus_client_tcp.dart'; // import 'package:qr_code_scanner/qr_code_scanner.dart'; var batteryTemperature = ModbusInt16Register(name: "BatteryTemperature", type: ModbusElementType.inputRegister, address: 22, uom: "°C", multiplier: 0.1, onUpdate: (self) => print(self)); class ActiveProject extends StatelessWidget { ActiveProject({super.key}); RxString modBus = "".obs; @override Widget build(BuildContext context) { return Card( elevation: 5, child: Container( constraints: const BoxConstraints(maxWidth: double.infinity, maxHeight: double.infinity), width: 350, // height: height ?? double.infinity, // height: 450, // margin: const EdgeInsets.all(2.0), // padding: const EdgeInsets.all(5.0), clipBehavior: Clip.hardEdge, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), border: Border.all( color: Colors.grey.shade300, width: 1, style: BorderStyle.solid, ), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ SizedBox( height: 250, child: GestureDetector( onTap: () async { context.vRouter.to("/screen-1/person-dash"); }, child: Container( width: 250, height: 250, margin: const EdgeInsets.all(5), clipBehavior: Clip.hardEdge, decoration: const BoxDecoration( color: Colors.transparent, borderRadius: BorderRadius.all( Radius.circular(15), ), ), child: Image.asset("assets/hmi/cnc.png") // QRView( // key: cncEkraniLogic.qrStokNo, // onQRViewCreated: cncEkraniLogic.onQRViewStokNoCreated, // overlay: QrScannerOverlayShape( // borderColor: Colors.red, // borderRadius: 10, // borderLength: 30, // borderWidth: 10, // cutOutSize: 150), // ), ), ), ), Obx( () => FikoYTButton( text: modBus.value ?? "Proje Kodu Şimdilik El İle Girilecek", tema: FikoYTButtonTheme(fontSize: 18, fontWeight: FontWeight.bold), onPressed: () async { ModbusAppLogger(Level.FINE); // Create a modbus int16 register element var batteryTemperature = ModbusUint32Register( name: "BatteryTemperature", type: ModbusElementType.inputRegister, address: 41, uom: "°C", // viewDecimalPlaces: 0, // multiplier: 0.1, onUpdate: (self) => modBus.value = self.toString(), ); // Discover the Modbus server var serverIp = await ModbusClientTcp.discover("192.168.1.12", serverPort: 502, connectionTimeout: Duration(milliseconds: 200)); if (serverIp == null) { ModbusAppLogger.shout("No modbus server found!"); return; } // Create the modbus client. var modbusClient = ModbusClientTcp(serverIp, unitId: 2); // Send a read request from the element await modbusClient.send(batteryTemperature.getReadRequest()); // Ending here modbusClient.disconnect(); }, ), ), Padding( padding: const EdgeInsets.all(5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text("Tamamlanma Yüzdesi :", style: TextStyle(fontSize: 12, color: Colors.blueAccent)), const LinearProgressIndicator( value: 0.45, color: Colors.blue, semanticsLabel: 'Linear progress indicator', ), Row( children: [ Expanded( child: Column( children: const [ Text("İstenen Adet", style: TextStyle(fontSize: 12, color: Colors.blueAccent)), Text( "5000", style: TextStyle( // fontSize: 18, fontWeight: FontWeight.bold, color: Colors.orange, ), ), ], ), ), Expanded( child: Column( children: const [ Text( "Tamamlanan Adet", style: TextStyle( fontSize: 12, color: Colors.blue, ), ), Text( "1256 Adet", style: TextStyle( // fontSize: 18, fontWeight: FontWeight.bold, color: Colors.green, ), ), ], ), ), Expanded( child: Column( children: const [ Text("Kalan Adet:", style: TextStyle(fontSize: 12, color: Colors.blueAccent)), Text( "3744 Adet", style: TextStyle( // fontSize: 18, fontWeight: FontWeight.bold, color: Colors.red, ), ), ], ), ), ], ), Row( children: [ Expanded( child: Column( children: const [ Text("Bağlama Süresi", style: TextStyle(fontSize: 12, color: Colors.blueAccent)), Text( "45 Saniye", style: TextStyle( // fontSize: 18, fontWeight: FontWeight.bold, color: Colors.orange, ), ), ], ), ), Expanded( child: Column( children: [ Text("İşleme Süresi:", style: TextStyle(fontSize: 12, color: Colors.blueAccent)), Obx( () => FikoYTButton( text: FikoYTEvent("FikoYT.uyar.cardId.value").value ?? "", tema: FikoYTButtonTheme( fontSize: 12, fontWeight: FontWeight.bold, textColor: Colors.red, ), onPressed: () {}, ), ), ], ), ), Expanded( child: Column( children: const [ Text("Toplam Süresi:", style: TextStyle(fontSize: 12, color: Colors.blueAccent)), Text("6 Dakika 45 Saniye", style: TextStyle( // fontSize: 18, fontWeight: FontWeight.bold, color: Colors.green)), ], ), ), ], ), ], ), ), ], ), ), ); } }