private async void GetImage() { FileOpenPicker picker = new FileOpenPicker(); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read); BitmapImage image = new BitmapImage(); await image.SetSourceAsync(stream.CloneStream()); image.UriSource = new Uri(file.Path); MyBuffer buffer = new MyBuffer(new byte[stream.Size]); await stream.ReadAsync(buffer.Buffer, (uint)stream.Size, InputStreamOptions.None); var newAvatar = buffer.AsByteArray(); Database_Service.SchedServiceClient client = new Database_Service.SchedServiceClient(); account.avatarImage = newAvatar; Application.Current.Resources["User"] = account; await client.UpdateUserAsync(account.clientID, account.phoneNumber, account.address, account.username, newAvatar); EventViewModel e = this.DataContext as EventViewModel; e.newAvatar(newAvatar); DataContext = e; } }
private void body_end(string whence) { this.imsg("websvc: body_end called {0}", (object)whence); if (this.isgzip) { byte[] bf = Websvc.ungzip(this.mem_body.inbf, this.mem_body.Length); this.mem_body = new MyBuffer(); this.mem_body.add(bf, bf.Length); } ++Websvc.nrequests; try { this.wmod.do_body_end(this); } catch (Exception ex) { this.imsg("crash in do_body_end() {0} {1}", (object)ex.Message, (object)ex.ToString()); Web.simple_error(this, "crash in do_body_end() " + ex.Message); } clib.imsg("body_end setting wmod to null"); this.wmod = (WebModule)null; if (this.query != null) { this.query.Clear(); } if (this.form != null) { this.form.Clear(); } this.inbody = false; this.content_len = 0; this.in_chunked = false; this.imsg("mystery body_end called {0}", (object)this.content_len); }
static void Main(string[] args) { var buffer = new MyBuffer <double>(); ProcessInput(buffer); ProcessBuffer(buffer); // Collections var employeesByName = new SortedList <string, List <Employee> >(); employeesByName.Add("Sales", new List <Employee> { new Employee(), new Employee(), new Employee() }); employeesByName.Add("Engineering", new List <Employee> { new Employee(), new Employee() }); foreach (var item in employeesByName) { Console.WriteLine("The count of employees for {0} is {1}", item.Key, item.Value.Count ); } // Collection and custom comparer var departments = new DepartmentCollection(); departments.Add("Sales", new Employee { Name = "Joy" }) .Add("Sales", new Employee { Name = "Dani" }) .Add("Sales", new Employee { Name = "Dani" }); departments.Add("Engineering", new Employee { Name = "Scott" }) .Add("Engineering", new Employee { Name = "Alex" }) .Add("Engineering", new Employee { Name = "Dani" }); foreach (var department in departments) { Console.WriteLine(department.Key); foreach (var employee in department.Value) { Console.WriteLine("\t" + employee.Name); } } }
public void BufferFullAfterThreeWrites() { var buffer = new MyBuffer <double>(capacity: 3); buffer.Write(5.0); buffer.Write(6.0); buffer.Write(7.0); Assert.IsTrue(buffer.IsFull); }
public void CheckBufferIsFull() { var buffer = new MyBuffer <double>(capacity: 3); buffer.Write(1.5); buffer.Write(1.5); buffer.Write(1.5); Assert.IsTrue(buffer.IsFull); }
public EventViewModel() { Chat = ""; StorageFile file = StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/weather/01d.png")).AsTask().GetAwaiter().GetResult(); IRandomAccessStream stream = file.OpenAsync(FileAccessMode.Read).AsTask().GetAwaiter().GetResult(); MyBuffer buffer = new MyBuffer(new byte[stream.Size]); stream.ReadAsync(buffer.Buffer, (uint)stream.Size, InputStreamOptions.None).AsTask().GetAwaiter().GetResult(); newAvatar(buffer.AsByteArray()); }
//public void delegate OnDisconnectDelegate(StompServerClient client); public StompServerClient(Socket socket) { if (StompConfiguration.ForceOverlappedIo) socket.UseOnlyOverlappedIO = true; _guid = Guid.NewGuid(); _socket = socket; _ip = ((IPEndPoint)socket.RemoteEndPoint).Address; _outgoingBuffers = new List<ArraySegment<byte>>(); _buffer = new MyBuffer(StompConfiguration.MinClientBufferSize); }
private static void ProcessBuffer(MyBuffer <double> buffer) { var sum = 0.0; Console.WriteLine("Buffer: "); while (!buffer.IsEmpty) { sum += buffer.Read(); } Console.WriteLine(sum); }
private void tryCopy(DataGridView dgv) { try { MyBuffer.Copy(dgv); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void FirstInFirstOut() { var buffer = new MyBuffer <double>(capacity: 3); buffer.Write(5.0); buffer.Write(8.0); var readVal1 = buffer.Read(); var readVal2 = buffer.Read(); Assert.AreEqual(5.0, readVal1); Assert.AreEqual(8.0, readVal2); }
public void OnGetTiles(uint clientId, GetTilesClientMessage msg) { var tileBlock = GameState.World.GetTileBlock(msg.MapX, msg.MapY); var tilesBuffer = MyBuffer.Create(TileBlock.Size + 1) .SetUint8((byte)ServerMessageType.MapTiles) .SetInt32(tileBlock.X) .SetInt32(tileBlock.Y); Buffer.BlockCopy(tileBlock.Tiles.Cast <int>().ToArray(), 0, tilesBuffer.buffer, 9, tileBlock.Tiles.Length * sizeof(TileType)); Messenger.SendMessage(clientId, tilesBuffer); }
public void FirstInFirstOutWithinCapacity() { var buffer = new MyBuffer <string>(capacity: 3); var value1 = "1.1"; var value2 = "2.0"; buffer.Write(value1); buffer.Write(value2); Assert.AreEqual(value1, buffer.Read()); Assert.AreEqual(value2, buffer.Read()); Assert.IsTrue(buffer.IsEmpty); }
//public void delegate OnDisconnectDelegate(StompServerClient client); public StompServerClient(Socket socket) { if (StompConfiguration.ForceOverlappedIo) { socket.UseOnlyOverlappedIO = true; } _guid = Guid.NewGuid(); _socket = socket; _ip = ((IPEndPoint)socket.RemoteEndPoint).Address; _outgoingBuffers = new List <ArraySegment <byte> >(); _buffer = new MyBuffer(StompConfiguration.MinClientBufferSize); }
private static void ProcessInput(MyBuffer <double> buffer) { while (true) { var value = 0.0; var input = Console.ReadLine(); if (double.TryParse(input, out value)) { buffer.Write(value); continue; } break; } }
public void OverWrites() { var buffer = new MyBuffer <double>(capacity: 3); var testArray = new [] { 1.0, 2.0, 3.0, 4.0, 5.0 }; foreach (var val in testArray) { buffer.Write(val); } Assert.IsTrue(buffer.IsFull); Assert.AreEqual(testArray[2], buffer.Read()); Assert.AreEqual(testArray[3], buffer.Read()); Assert.AreEqual(testArray[4], buffer.Read()); Assert.IsTrue(buffer.IsEmpty); }
public void OverwritesWhenCapacityExceeded() { var buffer = new MyBuffer <double>(capacity: 3); var values = new[] { 1.0, 2.0, 3.0, 4.0, 5.0 }; foreach (var value in values) { buffer.Write(value); } Assert.IsTrue(buffer.IsFull); Assert.AreEqual(values[2], buffer.Read()); Assert.AreEqual(values[3], buffer.Read()); Assert.AreEqual(values[4], buffer.Read()); Assert.IsTrue(buffer.IsEmpty); }
private ToolStripMenuItem CreateCopy() { ToolStripMenuItem item = CreateItem("Копировать"); item.ShortcutKeys = Keys.Control | Keys.C; item.Click += delegate { try { MyBuffer.Copy(_dgvMain.GetDGV()); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; return(item); }
private void process_cmd_early() { if (this.iswebdav) { this.wmod = (WebModule) new WebDav(); this.imsg("Using webdav module for this one"); } else { foreach (WebModule webModule in Websvc.modlist) { if (webModule.isforme(clib.pathstart(this.url), this.url)) { this.wmod = (WebModule)webModule.Clone(); } } } if (this.wmod == null) { this.imsg("FATAL: isforme... No module found for url {0} {1} iswebdav = {2}", (object)this.url, (object)clib.pathstart(this.url), (object)this.iswebdav); string x = "Sorry invalid url"; this.chan.write(string.Format("HTTP/1.1 500 Invalid url for this server\r\nContent-Length: {0}\r\n\r\n", (object)x.Length)); this.chan.write(x); } else { this.imsg("wmod: Found module {0}", (object)this.wmod.myname()); this.query = clib.ParseQueryString(this.url_raw); foreach (string allKey in this.query.AllKeys) { this.imsg("QUERY: {0,-10} {1}", (object)allKey, (object)this.query[allKey]); } this.auth_decode(this.head_get("Authorization")); this.ifmodified = this.head_get("If-Modified-Since"); if (this.ifmodified == null) { this.ifmodified = ""; } this.ifheader = this.head_get("If"); this.ifheader_done = false; this.top_done = false; if (this.ifheader == null) { this.ifheader = ""; } this.host = this.head_get("Host"); if (this.host == null) { this.host = "http://localhost"; } this.lockid = this.head_get("Lock-Token"); if (this.lockid == null) { this.lockid = ""; } this.lockid = this.lockid.Trim("<> ".ToCharArray()); this.content_type = this.head_get("Content-Type"); this.data_ok = false; this.wmod.do_headers(this); this.inbody = true; if (this.method == Wmethod.POST || this.method == Wmethod.PUT) { this.inmem = false; } else { this.inmem = true; this.mem_body = new MyBuffer(); } } }
public void EmptyBufferTest() { var buffer = new MyBuffer <double>(); Assert.IsTrue(buffer.IsEmpty); }
/// <remarks> /// Parses via Sequence, but doesn't ever need to copy bytes. Puts onus on Utf8JsonReader to be fast with Sequence. /// </remarks> public static async Task <T> ParseNoCopyAsync <T, TParser>(Stream stream, CancellationToken cancellationToken) where TParser : IJsonParser <T>, new() { ArrayPool <byte> pool = ArrayPool <byte> .Shared; int rentSize = 4096; MyBuffer firstBuffer, lastBuffer; int fill = 0, consumed = 0; bool done = false; firstBuffer = lastBuffer = new MyBuffer(pool.Rent(rentSize), 0); var readerState = new JsonReaderState(); var parser = new TParser(); while (true) { if (!done) { if (fill == lastBuffer.Memory.Length) { rentSize = Math.Min(65536, rentSize * 3 / 2); var newLastBuffer = new MyBuffer(pool.Rent(rentSize), lastBuffer.RunningIndex + lastBuffer.Memory.Length); lastBuffer.SetNext(newLastBuffer); lastBuffer = newLastBuffer; fill = 0; } int read = await stream.ReadAsync(lastBuffer.WritableMemory.AsMemory(fill), cancellationToken).ConfigureAwait(false); fill += read; done = read == 0; } if (!DoReadSync()) { if (done) { throw new Exception("unexpected end of document."); } } else { return(parser.FinalValue); } } bool DoReadSync() { var availableSequence = new ReadOnlySequence <byte>(firstBuffer, consumed, lastBuffer, fill); var reader = new Utf8JsonReader(availableSequence, done, readerState); bool res = parser.TryContinueParse(ref reader); long newConsumed = reader.BytesConsumed; while (newConsumed != 0) { int left = (firstBuffer == lastBuffer ? fill : firstBuffer.Memory.Length) - consumed; int take = (int)Math.Min(left, newConsumed); consumed += take; newConsumed -= take; if (consumed == firstBuffer.Memory.Length) { consumed = 0; if (firstBuffer != lastBuffer) { pool.Return(firstBuffer.WritableMemory); firstBuffer = (MyBuffer)firstBuffer.Next; } else { fill = 0; } } } readerState = reader.CurrentState; return(res); } }
public void SetNext(MyBuffer nextBuffer) { Next = nextBuffer; }
/******************************************** * 函数名称:run() * 功能:心率传感节点组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------心率传感器节点input端口传输数据-------------------// //若input端口不为空 if (this.input_ports != null) { //foreach(Input_port input in this.input_ports){ PortDataTransfer(this.input_ports[0]); //input端口进行数据传输 //} } //--------------------心率传感器组件启动执行---------------------------// HeartRateSensor hrs = (HeartRateSensor)(this.HeartRateSensor); //step1、心率传感器组件接收数据 hrs.ComponentDataReceive(hrs); //step2、执行心率传感器功能,即采样数据,并将采样数据传至发送队列 hrs.CollectHeartRateData(); //step3、心率传感器组件output端口传输数据 hrs.ComponentDataTransfer(hrs); //传输采样心率数据 //--------------------微处理器组件启动执行---------------------------// MicroProcessor mp = (MicroProcessor)this.microProcessor; //step1、微处理器组件接收数据 mp.ComponentDataReceive(mp); //step2、执行微处理器功能 mp.MessageEncapsulation(x); //step3、微处理器组件output端口传输数据 mp.ComponentDataTransfer(mp); //--------------------缓冲区组件启动执行---------------------------// MyBuffer buf = (MyBuffer)this.myBuffer; //step1、缓冲区组件接收数据 buf.ComponentDataReceive(buf); //step2、执行缓冲区功能 buf.MessageBuffering(y); //step3、缓冲区组件output端口传输数据 buf.ComponentDataTransfer(buf); //------------------------无线模块--------------------------------// WirelessModule wm = (WirelessModule)this.wirelessModule; //step1、无线模块组件接收数据 wm.ComponentDataReceive(wm); //step2、执行无线模块数据帧封装功能 wm.FrameEncapsulation(y, access_address); //step3、无线模块组件output端口传输数据 wm.ComponentDataTransfer(wm); //-------------------心率传感器节点output端口传输数据-------------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } } // public void run()
/******************************************** * 函数名称:run() * 功能:物联网网关组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------IoT网关input端口传输数据----------------// //若input端口不为空 if (this.input_ports != null) { foreach (Input_port input in this.input_ports) { PortDataTransfer(input); //input端口进行数据传输 } } //-------------------无线模块1组件启动执行-------------------// WirelessModule wm1 = (WirelessModule)this.wirelessModule1; //step1、无线模块1组件接收数据 wm1.ComponentDataReceive(wm1); //step2、执行无线模块1数据帧解封装功能 wm1.FrameDecapsulation(); //step3、无线模块1组件output端口传输数据 wm1.ComponentDataTransfer(wm1); //-------------------无线模块2组件启动执行-------------------// WirelessModule wm2 = (WirelessModule)this.wirelessModule2; //step1、无线模块2组件接收数据 wm2.ComponentDataReceive(wm2); //step2、执行无线模块2数据帧解封装功能 wm2.FrameDecapsulation(); //step3、无线模块2组件output端口传输数据 wm2.ComponentDataTransfer(wm2); //-------------------无线模块3组件启动执行-------------------// WirelessModule wm3 = (WirelessModule)this.wirelessModule3; //step1、无线模块2组件接收数据 wm3.ComponentDataReceive(wm3); //step2、执行无线模块2数据帧解封装功能 wm3.FrameDecapsulation(); //step3、无线模块2组件output端口传输数据 wm3.ComponentDataTransfer(wm3); //-------------------缓冲区1组件启动执行-------------------// MyBuffer buf1 = (MyBuffer)this.myBuffer1; //step1、缓冲区1组件接收数据 buf1.ComponentDataReceive(buf1); //step2、执行缓冲区功能 buf1.MessageBuffering("frame802154"); //step3、缓冲区1组件output端口传输数据 buf1.ComponentDataTransfer(buf1); //-------------------缓冲区2组件启动执行-------------------// MyBuffer buf2 = (MyBuffer)this.myBuffer2; //step1、缓冲区2组件接收数据 buf2.ComponentDataReceive(buf2); //step2、执行缓冲区2功能 buf2.MessageBuffering("frame802154"); //step3、缓冲区2组件output端口传输数据 buf2.ComponentDataTransfer(buf2); //-------------------缓冲区3组件启动执行-------------------// MyBuffer buf3 = (MyBuffer)this.myBuffer3; //step1、缓冲区3组件接收数据 buf3.ComponentDataReceive(buf3); //step2、执行缓冲区3功能 buf3.MessageBuffering("frame802151"); //step3、缓冲区3组件output端口传输数据 buf3.ComponentDataTransfer(buf3); //----------------网络协议转换模块启动执行-----------------// ProtocolConverter pc = (ProtocolConverter)this.protocolConverter; //step1、网络协议转换模块接收数据 pc.ComponentDataReceive(pc); //step2、执行网络协议转换模块功能 pc.ProtocolConversion(); //step3、网络协议转换模块output端口传输数据 pc.ComponentDataTransfer(pc); //-------------------缓冲区4组件启动执行-------------------// MyBuffer buf4 = (MyBuffer)this.myBuffer4; //step1、缓冲区3组件接收数据 buf4.ComponentDataReceive(buf4); //step2、执行缓冲区3功能 buf4.MessageBuffering(null); //step3、缓冲区3组件output端口传输数据 buf4.ComponentDataTransfer(buf4); //-------------------有线模块组件启动执行-------------------// WiredModule wiredM = (WiredModule)wiredModule; //step1、有线模块组件接收数据 wiredM.ComponentDataReceive(wiredM); //step2、执行有线模块组件功能 wiredM.EthernetFrameEncapsulation(dest_address); //step3、有线模块组件output端口传输数据 wiredM.ComponentDataTransfer(wiredM); //----------------IoT网关output端口传输数据--------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } }// public void run()
/******************************************** * 函数名称:run() * 功能:医疗服务器组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------医疗服务器input端口传输数据----------------// //若input端口不为空 if (this.input_ports != null) { foreach (Input_port input in this.input_ports) { PortDataTransfer(input); //input端口进行数据传输 } } //-------------------有线模块组件启动执行-------------------// WiredModule wiredM = (WiredModule)this.wiredModule; //step1、有线模块组件接收数据 wiredM.ComponentDataReceive(wiredM); //step2、执行有线模块数据帧解封装功能 wiredM.EthernetFrameDecapsulation(); //step3、有线模块组件output端口传输数据 wiredM.ComponentDataTransfer(wiredM); //--------------------缓冲区组件启动执行--------------------// MyBuffer buf = (MyBuffer)this.myBuffer; //step1、缓冲区组件接收数据 buf.ComponentDataReceive(buf); //step2、执行缓冲区功能 buf.MessageBuffering(null); //step3、缓冲区1组件output端口传输数据 buf.ComponentDataTransfer(buf); //---------------网络数据处理模块组件启动执行--------------// DataProcessor dp = (DataProcessor)this.dataProcessor; //step1、网络数据处理模块接收数据 dp.ComponentDataReceive(dp); //step2、执行网络数据处理模块功能 dp.NetworkDataProcessing(); //step3、网络数据处理模块output端口传输数据 dp.ComponentDataTransfer(dp); //----------------信息分析控制模块启动执行------------------// DataAnalyzer da = (DataAnalyzer)this.dataAnalyzer; //step1、信息分析控制模块接收数据 da.ComponentDataReceive(da); //step2、执行信息分析控制模块功能 da.DataAnalysis(); //step3、信息分析控制模块output端口传输数据 da.ComponentDataTransfer(da); //----------------医疗服务器output端口传输数据--------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } }// public void run()
/******************************************** * 函数名称:run() * 功能:体温传感节点组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------体温传感器节点input端口传输数据-------------------// //若input端口不为空 if (this.input_ports != null) { //foreach(Input_port input in this.input_ports){ PortDataTransfer(this.input_ports[0]); //input端口进行数据传输 //} } //--------------------体温传感器组件启动执行---------------------------// TemperatureSensor ts = (TemperatureSensor)(this.TemperatureSensor); //step1、体温传感器组件接收数据 ts.ComponentDataReceive(ts); //++++++++++++ Debug - 读取组件接收队列中的数据 +++++++++++// //Console.Write(ts.name + "组件接收队列内的数据(入队后):"); //Console.WriteLine("组件接收队列长度:" + ts.Component_reveice_queue.Count); //foreach (TemperatureDataType arr in ts.Component_reveice_queue) //{ // Console.Write("[" +arr.Temperature+"] "); //} //Console.WriteLine(""); ////Console.WriteLine("========================="); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //step2、执行体温传感器功能,即采样数据,并将采样数据传至发送队列 ts.CollectTemperatureData(); //step3、体温传感器组件output端口传输数据 ts.ComponentDataTransfer(ts); //传输采样体温数据 //--------------------微处理器组件启动执行---------------------------// MicroProcessor mp = (MicroProcessor)this.microProcessor; //step1、微处理器组件接收数据 mp.ComponentDataReceive(mp); //step2、执行微处理器功能 mp.MessageEncapsulation(x); //step3、微处理器组件output端口传输数据 mp.ComponentDataTransfer(mp); //--------------------缓冲区组件启动执行---------------------------// MyBuffer buf = (MyBuffer)this.myBuffer; //step1、缓冲区组件接收数据 buf.ComponentDataReceive(buf); //step2、执行缓冲区功能 buf.MessageBuffering(y); //step3、缓冲区组件output端口传输数据 buf.ComponentDataTransfer(buf); //------------------------无线模块--------------------------------// WirelessModule wm = (WirelessModule)this.wirelessModule; //step1、无线模块组件接收数据 wm.ComponentDataReceive(wm); //step2、执行无线模块数据帧封装功能 wm.FrameEncapsulation(y, dest_address); //step3、无线模块组件output端口传输数据 wm.ComponentDataTransfer(wm); //-------------------体温传感器节点output端口传输数据-------------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } }// public void run()
private void process_header(string header) { this.head.Clear(); this.content_type = ""; this.content_len = 0; this.imsg("content_mystery, process_header started {0}", (object)this.content_len); this.depth = 2; string[] strArray = clib.string_lines(header); string rline = strArray[0]; this.save_request = rline; if (Ini.istrue(En.debug_http)) { this.imsg("http: ===< Request: {0}", (object)rline); } foreach (string str1 in strArray) { int length = str1.IndexOf(":"); if (length >= 0) { string str2 = str1.Substring(0, length); string str3 = str1.Substring(length + 1); if (str3.Length > 0 && str3.StartsWith(" ")) { str3 = str3.Substring(1); } if (Ini.istrue(En.debug_http)) { this.imsg("http: {0}: {1}", (object)str2, (object)str3); } try { this.head.Add(str2.ToLower(), str3); } catch { } } } this.isgzip = this.head_get("Content-Encoding").Contains("gzip"); if (this.isgzip) { this.inmem = true; this.mem_body = new MyBuffer(); } this.isie = this.head_get("User-Agent").Contains("MSIE"); this.was_content = false; this.content_len = clib.atoi(this.head_get("Content-Length")); if (this.content_len > 0) { this.was_content = true; } this.imsg("do_headers: mystery content_len is {0} {1}", (object)this.content_len, (object)rline); this.in_chunked = false; string str4 = this.head_get("Timeout"); if (str4 != null) { int num = str4.IndexOf("Second-"); this.h_timeout = num < 0 ? 3600 : clib.atoi(str4.Substring(num + "Second-".Length)); } string str5 = this.head_get("Transfer-Encoding"); if (str5 != null && str5.ToLower().Contains("chunked")) { this.in_chunked = true; this.chunk_len = 0; } this.do_continue = false; if (this.head_get("Expect").Contains("100-continue")) { this.do_continue = true; } if (this.do_continue) { this.imsg("Sending: HTTP/1.1 100 Continue\n"); this.chan.write("HTTP/1.1 100 Continue\r\n\r\n"); } this.destination = this.head_get("Destination"); this.destination = clib.url_decode(this.destination); this.imsg("decoded dest is now {0}", (object)this.destination); this.overwrite = true; string str6 = this.head_get("Overwrite"); if (str6 != null) { if (str6.ToLower().Contains("t")) { this.overwrite = true; } if (str6.ToLower().Contains("f")) { this.overwrite = false; } } string lower = (this.head_get("Depth") ?? "2").Trim().ToLower(); if (lower.Length == 0) { this.depth = 2; } else if (lower == "0") { this.depth = 0; } else if (lower == "1") { this.depth = 1; } else if (lower == "infinity") { this.depth = 2; } this.imsg("Depth is {0}", (object)this.depth); this.cookie = this.head_get("Cookie"); this.imsg("Main request: {0} {1}", (object)this.content_len, (object)rline); if (!this.decode_request(rline)) { this.imsg("decode_request failed - close link"); this.imsg("decode_request failed - close link"); this.chan.EndConnection(); } else { this.imsg("decode_request worked okk"); } }
public void CheckBufferIsEmpty() { var buffer = new MyBuffer <double>(); Assert.IsTrue(buffer.IsEmpty); }
public Task SendMessage(MyBuffer buffer) { return(buffer.SendAsync(_socket)); }
/******************************************** * 函数名称:run() * 功能:IPv6路由器组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------IPv6路由器input端口传输数据----------------// //若input端口不为空 if (this.input_ports != null) { foreach (Input_port input in this.input_ports) { PortDataTransfer(input); //input端口进行数据传输 } } //-------------------有线模块1组件启动执行-------------------// WiredModule wiredM1 = (WiredModule)this.wiredModule1; //step1、有线模块1组件接收数据 wiredM1.ComponentDataReceive(wiredM1); //step2、执行有线模块1数据帧解封装功能 wiredM1.EthernetFrameDecapsulation(); //step3、有线模块1组件output端口传输数据 wiredM1.ComponentDataTransfer(wiredM1); //-------------------缓冲区1组件启动执行-------------------// MyBuffer buf1 = (MyBuffer)this.myBuffer1; //step1、缓冲区1组件接收数据 buf1.ComponentDataReceive(buf1); //step2、执行缓冲区功能 buf1.MessageBuffering(null); //step3、缓冲区1组件output端口传输数据 buf1.ComponentDataTransfer(buf1); //-------------------路由模块组件启动执行-------------------// RouteModule rm = (RouteModule)this.routeModule; //step1、路由模块组件接收数据 rm.ComponentDataReceive(rm); //step2、执行路由模块功能 rm.Routing(); //step3、路由模块组件output端口传输数据 rm.ComponentDataTransfer(rm); //-------------------缓冲区2组件启动执行-------------------// MyBuffer buf2 = (MyBuffer)this.myBuffer2; //step1、缓冲区2组件接收数据 buf2.ComponentDataReceive(buf2); //step2、执行缓冲区功能 buf2.MessageBuffering(null); //step3、缓冲区2组件output端口传输数据 buf2.ComponentDataTransfer(buf2); //-------------------有线模块2组件启动执行-------------------// WiredModule wiredM2 = (WiredModule)this.wiredModule2; //step1、有线模块2组件接收数据 wiredM2.ComponentDataReceive(wiredM2); //step2、执行有线模块2数据帧封装功能 wiredM2.EthernetFrameEncapsulation(dest_address); //step3、有线模块2组件output端口传输数据 wiredM2.ComponentDataTransfer(wiredM2); //----------------IPv6路由器output端口传输数据--------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } } // public void run()
public PgConnectionBase(Socket s, int bufSize = 1024 * 4, bool own = true) { sock = s; readBuf = new MyBuffer(bufSize); ownSock = own; }
/*************************************************************************** * 函数名称:treeView1_NodeMouseDoubleClick() * 功能:组件库列表表项鼠标双击事件,在graphControl绘图控制区创建相应组件 * 参数:sender;e * 返回值:无 * *************************************************************************/ private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); if (treeView1.SelectedNode.Level > 1) { string name; //int tabIndex = 0; //第一个选项卡 name = e.Node.Name.ToString(); switch (name) { //================================================================// //======================创建基本组件==============================// //================================================================// //B01 人体血压 case "BloodPressure": bloodPressure = new BloodPressure(this.graphControl, null, null, null); graphControl.AddShape(bloodPressure, bloodPressure.Location); break; //B02 人体体温 case "Temperature": temperature = new Temperature(this.graphControl, null, null, null); graphControl.AddShape(temperature, new PointF(temperature.Location.X, temperature.Location.Y + 80)); break; //B03 人体心率 case "HeartRate": heartRate = new HeartRate(this.graphControl, null, null, null); graphControl.AddShape(heartRate, new PointF(heartRate.Location.X, heartRate.Location.Y + 160)); break; //B04 血压传感器 case "BloodPressureSensor": bloodPressureSensor = new BloodPressureSensor(this.graphControl, null, null, null); graphControl.AddShape(bloodPressureSensor, new PointF(bloodPressureSensor.Location.X + 110, bloodPressureSensor.Location.Y)); break; //B05 体温传感器 case "TemperatureSensor": temperatureSensor = new TemperatureSensor(this.graphControl, null, null, null); graphControl.AddShape(temperatureSensor, new PointF(temperatureSensor.Location.X + 110, temperatureSensor.Location.Y + 80)); break; //B06 心率传感器 case "HeartRateSensor": heartRateSensor = new HeartRateSensor(this.graphControl, null, null, null); graphControl.AddShape(heartRateSensor, new PointF(heartRateSensor.Location.X + 110, heartRateSensor.Location.Y + 160)); break; //B07 显示控制器 case "DisplayController": displayController = new DisplayController(this.graphControl, null, null, null); graphControl.AddShape(displayController, new PointF(displayController.Location.X + 220, displayController.Location.Y)); break; //B08 音频控制器 case "AudioController": audioController = new AudioController(this.graphControl, null, null, null); graphControl.AddShape(audioController, new PointF(audioController.Location.X + 220, audioController.Location.Y + 80)); break; //B09 电机控制器 case "ElectricMachineryController": electricMachineryController = new ElectricMachineryController(this.graphControl, null, null, null); graphControl.AddShape(electricMachineryController, new PointF(electricMachineryController.Location.X + 220, electricMachineryController.Location.Y + 160)); break; //B10 运算器 微处理器 case "MicroProcessor": microProcessor = new MicroProcessor(this.graphControl, null, null, null); graphControl.AddShape(microProcessor, new PointF(microProcessor.Location.X + 330, microProcessor.Location.Y)); break; //B11 协议转换器 case "ProtocolConverter": protocolConverter = new ProtocolConverter(this.graphControl, null, null, null); graphControl.AddShape(protocolConverter, new PointF(protocolConverter.Location.X + 330, protocolConverter.Location.Y + 70)); break; //B12 数据处理器 case "DataProcessor": dataProcessor = new DataProcessor(this.graphControl, null, null, null); graphControl.AddShape(dataProcessor, new PointF(dataProcessor.Location.X + 330, dataProcessor.Location.Y + 160)); break; //B13 数据分析器 case "DataAnalyzer": dataAnalyzer = new DataAnalyzer(this.graphControl, null, null, null); graphControl.AddShape(dataAnalyzer, new PointF(dataAnalyzer.Location.X + 330, dataAnalyzer.Location.Y + 240)); break; //B14 有线通信模块 case "WiredModule": wiredModule = new WiredModule(this.graphControl, null, null, null); graphControl.AddShape(wiredModule, new PointF(wiredModule.Location.X + 440, wiredModule.Location.Y)); break; //B15 无线通信模块 case "WirelessModule": wirelessModule = new WirelessModule(this.graphControl, null, null, null); graphControl.AddShape(wirelessModule, new PointF(wirelessModule.Location.X + 440, wirelessModule.Location.Y + 80)); break; //B16 有线媒介 case "WiredMedia": wiredMedia = new WiredMedia(this.graphControl, null, null, null); graphControl.AddShape(wiredMedia, new PointF(wiredMedia.Location.X + 440, wiredMedia.Location.Y + 160)); break; //B17 无线媒介 case "WirelessMedia": wirelessMedia = new WirelessMedia(this.graphControl, null, null, null); graphControl.AddShape(wirelessMedia, new PointF(wirelessMedia.Location.X + 440, wirelessMedia.Location.Y + 240)); break; //18 寄存器 case "Register": register = new Register(this.graphControl, null, null, null); graphControl.AddShape(register, new PointF(register.Location.X + 550, register.Location.Y)); break; //B19 存储器RAM case "RAM": ram = new RAM(this.graphControl, null, null, null); graphControl.AddShape(ram, new PointF(ram.Location.X + 550, ram.Location.Y + 80)); break; //B20 存储器ROM case "ROM": rom = new ROM(this.graphControl, null, null, null); graphControl.AddShape(rom, new PointF(rom.Location.X + 550, rom.Location.Y + 160)); break; //B21 数据存储器 case "DataMemory": dataMemory = new DataMemory(this.graphControl, null, null, null); graphControl.AddShape(dataMemory, new PointF(dataMemory.Location.X + 550, dataMemory.Location.Y + 240)); break; //B22 缓冲区 case "Buffer": buffer = new MyBuffer(this.graphControl, null, null, null); graphControl.AddShape(buffer, new PointF(buffer.Location.X + 550, buffer.Location.Y + 320)); break; //B23 路由模块 case "RouteModule": routeModule = new RouteModule(this.graphControl, null, null, null); graphControl.AddShape(routeModule, new PointF(routeModule.Location.X + 330, routeModule.Location.Y + 320)); break; //B24 监控器 case "Monitor": monitor = new MyMonitor(this.graphControl, null, null, null); graphControl.AddShape(monitor, new PointF(monitor.Location.X + 220, monitor.Location.Y + 240)); break; //B25 血压监控器 case "BloodPressureMonitor": bpMonitor = new BloodPressureMonitor(this.graphControl, null, null, null); graphControl.AddShape(bpMonitor, new PointF(bpMonitor.Location.X + 220, bpMonitor.Location.Y + 280)); break; //B26 体温监控器 case "TemperatureMonitor": tempMonitor = new TemperatureMonitor(this.graphControl, null, null, null); graphControl.AddShape(tempMonitor, new PointF(tempMonitor.Location.X + 220, tempMonitor.Location.Y + 320)); break; //B27 心率监控器 case "HeartRateMonitor": hrMonitor = new HeartRateMonitor(this.graphControl, null, null, null); graphControl.AddShape(hrMonitor, new PointF(hrMonitor.Location.X + 220, hrMonitor.Location.Y + 360)); break; //====================================================================// //======================CMIoT组件库中组件=============================// //====================================================================// //C01 患者组件 case "Patient": patient = new Patient(this.graphControl); graphControl.AddShape(patient, patient.Location); break; //C02 血压传感节点 case "BloodPressureSensorNode": BPSN = new BloodPressureSensorNode(this.graphControl); //BPSN_InsideForm = new InsideForm(BPSN); //构建内部结构 graphControl.AddShape(BPSN, BPSN.Location); break; //C03 体温传感节点 case "TemperatureSensorNode": TSN = new TemperatureSensorNode(this.graphControl); graphControl.AddShape(TSN, TSN.Location); break; //C04 心率传感节点 case "HeartRateSensorNode": HRSN = new HeartRateSensorNode(this.graphControl); graphControl.AddShape(HRSN, HRSN.Location); break; //C05 物联网网关 case "IoTGateway": IoTG = new IoTGateway(this.graphControl); graphControl.AddShape(IoTG, IoTG.Location); break; //C06 802.11信道组件 case "802.11Channel": channel_802_11 = new Channel802_11(this.graphControl, null, null, null); graphControl.AddShape(channel_802_11, channel_802_11.Location); break; //C07 802.15.1信道组件 case "802.15.1Channel": channel802_15_1 = new Channel802_15_1(this.graphControl, null, null, null); graphControl.AddShape(channel802_15_1, channel802_15_1.Location); break; //C08 802.15.4信道组件 case "802.15.4Channel": channel802_15_4 = new Channel802_15_4(this.graphControl, null, null, null); graphControl.AddShape(channel802_15_4, channel802_15_4.Location); break; //C09 Ethernet信道组件 case "EthernetChannel": channel_ethernet = new ChannelEthernet(this.graphControl, null, null, null); graphControl.AddShape(channel_ethernet, channel_ethernet.Location); break; //C10 IPv6路由器组件 case "IPv6Router": ipv6Router = new IPv6Router(this.graphControl); graphControl.AddShape(ipv6Router, ipv6Router.Location); break; //C11 医疗服务器组件 case "MedicalServer": MS = new MedicalServer(this.graphControl); graphControl.AddShape(MS, MS.Location); break; } } // if (treeView1.SelectedNode.Level > 1) } //treeView1_NodeMouseDoubleClick