internal static void OnWriteLine(LoggerArgs e) { if (WriteLine != null && e.Level <= _logLevel) { WriteLine.Invoke(e.ToString()); } }
private void RenderTracks(object o, TracksUpdatedEventArgs args) { Clear?.Invoke(this, EventArgs.Empty); WriteLine?.Invoke(this, new WriteLineEventArgs("---------------------------------------------------------TRACKS--------------------------------------------------------")); // foreach (var track in args.UpdatedTracks) { RenderTrack(track); } for (int i = 0; i < 10 - args.UpdatedTracks.Count; i++) { WriteLine?.Invoke(this, new WriteLineEventArgs("")); } WriteLine?.Invoke(this, new WriteLineEventArgs("---------------------------------------------------------EVENTS--------------------------------------------------------")); if (args.EventsList.Count > 0) { foreach (var events in args.EventsList) { if (events == null) { break; } WriteLine?.Invoke(this, new WriteLineEventArgs(" " + events.Print())); } } for (int i = 0; i < 10 - args.EventsList.Count; i++) { WriteLine?.Invoke(this, new WriteLineEventArgs("")); } WriteLine?.Invoke(this, new WriteLineEventArgs(DateTime.Now.ToString("dd-MMM-yyyy - HH':'mm") + " ---------------------------- FLIGHTS in airspace " + args.UpdatedTracks.Count + " ------------------------------------------------")); }
// Запись документа по месту назначения. Возвращает true, если записалось штатно. public bool Save() { if (saveblocked) { return(false); } bool saved = false; if (isChanged) { root.SetAttributeValue("counter", "" + counter); lock (savelocker) { try { root.Save(filePath); saved = true; } catch (Exception ex) { saved = false; saveblocked = true; //if (logwrite != null) { logwrite("Ошибка при записи файла: [" + filePath + "] " + ex.Message); } logwrite?.Invoke("Ошибка при записи файла: [" + filePath + "] " + ex.Message); } } if (!saved) { try { SaveSpecial(root, filePath + ".xml"); } catch (Exception ex) { //if (logwrite != null) { logwrite("Ошибка при повторной попытке записи файла: [" + filePath + ".xml] " + ex.Message); } logwrite?.Invoke("Ошибка при повторной попытке записи файла: [" + filePath + ".xml] " + ex.Message); } } isChanged = false; } return(saved); }
bool OpenBurn(int inEndp, int outEndp) { if (inEndp != 0x81 || outEndp != 0x02) { WriteLine?.Invoke("Device not in burn mode"); return(false); } OpenEndpoints(inEndp, outEndp); return(true); }
private int ReadFromUSB(byte[] buffer, int offset, int length) { int l; var result = epReader.Read(buffer, offset, length, ReadTimeout, out l); if (result != ErrorCode.Ok) { throw new Exception("USB read error: " + result.ToString()); } #if VERY_DEBUG WriteLine?.Invoke("<-[FEL] " + BitConverter.ToString(buffer)); #endif WriteLine?.Invoke(string.Format("<- {0} bytes", length)); return(l); }
bool OpenFel(int inEndp, int outEndp) { if (inEndp != 0x82 || outEndp != 0x01) { WriteLine?.Invoke("Uncorrect FEL device/mode"); return(false); } OpenEndpoints(inEndp, outEndp); WriteLine?.Invoke("Trying to verify device"); if (VerifyDevice().Board != 0x00166700) { WriteLine?.Invoke("Invalid board ID: " + VerifyDevice().Board); return(false); } return(true); }
void Start() { run = true; while (run) { var ii = get_next_item(); if (ii == null) { return; } ii.Queue.ProcessItem(ii); if (ii.Queue == queues[0]) { List <string> vs = new List <string>(); string url = null; for (; ii != null; ii = ii.ParentItem) { vs.InsertRange(0, ii.OutputValues); if (ii is Queue.InputItem.Url && (url == null || ii.OutputValues.Count > 0) ) { url = ii.Value; } if (ii.ParentItem == null) { break; } if (queues.IndexOf(ii.Queue) >= queues.IndexOf(ii.ParentItem.Queue)) { break; } } vs.Insert(0, url); tw.WriteLine(FieldPreparation.GetCsvLine(vs, FieldPreparation.FieldSeparator.COMMA, true)); tw.Flush(); WriteLine?.Invoke(headers, vs); } } }
private void WriteToUSB(byte[] buffer) { #if VERY_DEBUG WriteLine?.Invoke("->[FEL] " + BitConverter.ToString(buffer)); #endif WriteLine?.Invoke(string.Format("-> {0} bytes", buffer.Length)); int pos = 0; int l; while (pos < buffer.Length) { epWriter.Write(buffer, pos, buffer.Length - pos, WriteTimeout, out l); if (l > 0) { pos += l; } else { throw new Exception("Can't write to USB"); } } }
public bool Open(UInt16 vid = 0x1F3A, UInt16 pid = 0xEFE8, bool isFel = true) { try { this.vid = vid; this.pid = pid; Close(); UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(vid, pid); //WriteLine?.Invoke("Trying to open device..."); device = UsbDevice.OpenUsbDevice(MyUsbFinder); // If the device is open and ready if (device == null) { #if VERY_DEBUG WriteLine?.Invoke("Device with such VID and PID not found"); #endif return(false); } // If this is a "whole" usb device (libusb-win32, linux libusb) // it will have an IUsbDevice interface. If not (WinUSB) the // variable will be null indicating this is an interface of a // device. IUsbDevice wholeUsbDevice = device as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice, null)) { // This is a "whole" USB device. Before it can be used, // the desired configuration and interface must be selected. // Select config #1 wholeUsbDevice.SetConfiguration(1); // Claim interface #0. wholeUsbDevice.ClaimInterface(0); } int inEndp = -1; int outEndp = -1; int inMax = 0; int outMax = 0; WriteLine?.Invoke("Checking USB endpoints..."); foreach (var config in device.Configs) { foreach (var @interface in config.InterfaceInfoList) { foreach (var endp in @interface.EndpointInfoList) { if ((endp.Descriptor.EndpointID & 0x80) != 0) { inEndp = endp.Descriptor.EndpointID; inMax = endp.Descriptor.MaxPacketSize; WriteLine?.Invoke("IN endpoint found: " + inEndp); WriteLine?.Invoke("IN endpoint maxsize: " + inMax); } else { outEndp = endp.Descriptor.EndpointID; outMax = endp.Descriptor.MaxPacketSize; WriteLine?.Invoke("OUT endpoint found: " + outEndp); WriteLine?.Invoke("OUT endpoint maxsize: " + outMax); } } } } this.isFel = isFel; return(isFel ? OpenFel(inEndp, outEndp) : OpenBurn(inEndp, outEndp)); } catch (Exception ex) { WriteLine?.Invoke("Error: " + ex.Message + ex.StackTrace); return(false); } }
private void WriteToOutput(string line) { WriteLine.Invoke(line); }
private void RenderTrack(Track track) { WriteLine?.Invoke(this, new WriteLineEventArgs("Tag: " + track.Tag + ", X: " + track.X + ", Y: " + track.Y + ", Altitude: " + track.Altitude + ", Velocity: " + track.Velocity + ", Course: " + track.Course)); }
//--------------------------------------------------------------------- public static void Write(string msg, MessageType type) { using StreamWriter sw = new StreamWriter(LogFile, true); WriteLine.Invoke(sw, msg, type); sw.WriteLine(); }
public virtual void OnWriteLine(IRCEventArgs args) { WriteLine?.Invoke(this, args); }