Marcus Gardner

Generation

generate functionSat, 08 Apr 2023

Open a tcp socket and continuously read the stream in a non-working way. Items in the stream are seperated by a cartridge return. Please use regex to remove the non numeric characters from the item but allow the decimal point. Add each cleaned item to a queue named rawData.

using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Sockets; using System.Text.RegularExpressions; using System.Threading; namespace MultiThreading.Tasks { public class TankData { public int TankId { get; set; } public string TankName { get; set; } public double Gallons { get; set; } } public class TankDataReader { private const string IP = "192.168.0.3"; private const int PORT = 8085; private const int ID = 1; private const string NAME = "Tank1"; private const double CONVERSIONFACTOR = 6.4; //The number of gallons (U.S.) per unit. private const int READLOOPDELAY = 1000; public void ReadTankData(Queue<TankData> rawData) { TcpClient socket = new TcpClient(); socket.Connect(IP,

Want to kickstart your project?Use the new AI Studio to create your code