public NewpageProcessor(ProcessorInfo processorInfo) : base(processorInfo) { }
public static void Main(string[] args) { Log.onLog = OnLog; Parser parser = new Parser(with => { with.EnableDashDash = true; with.CaseInsensitiveEnumValues = true; with.CaseSensitive = false; with.EnableDashDash = true; with.HelpWriter = Console.Out; }); try { parser.ParseArguments <ProcessorInfoArguments, SettingsFileArgument>(args) .WithParsed <ProcessorInfoArguments>(x => { ProcessorInfo info = (ProcessorInfo)x; if (!x.noSettingsFile) { XmlSerializer serializer = new XmlSerializer(info.GetType()); string savePath; if (!string.IsNullOrEmpty(info.outputFilesPrefix.Trim())) { savePath = Path.Combine(info.outputDir, string.Format("{0}-settings.xml", info.outputFilesPrefix)); } else { savePath = Path.Combine(info.outputDir, "settings.xml"); } using (XmlWriter writer = XmlWriter.Create(savePath)) serializer.Serialize(writer, info); } Processor.Processor.Run(info); }) .WithParsed <SettingsFileArgument>(x => { if (!File.Exists(x.file)) { Log.Line(LogType.Error, "Could not find settings file '{0}'", x.file); return; } XmlSerializer serializer = new XmlSerializer(typeof(ProcessorInfo)); using (XmlReader reader = XmlReader.Create(x.file)) { ProcessorInfo info = (ProcessorInfo)serializer.Deserialize(reader); Processor.Processor.Run(info); } }) .WithNotParsed(HandleParseErrors); } catch (Exception e) { Log.Exception(e); } finally { parser.Dispose(); } // TODO: Set the return value based on the result of the processor }
public MainFormPresenter(IMainForm form, ProcessorInfo processorInfo, PhysicalMemoryInfo physicalMemoryInfo, DiskDriveInfo diskDriveInfo) { _form = form; #region Get processor info _processorInfo = processorInfo; _form.ProcessorName = _processorInfo.Instance[0].Name; _temperatureLsit = new List <double>(); _form.MaxProcessorClockSpeed = _processorInfo.Instance[0].MaxClockSpeed; var processorsProperities = new Dictionary <string, string>(); processorsProperities.Add("AddressWidth", _processorInfo.Instance[0].AddressWidth); processorsProperities.Add("Architecture", _processorInfo.Instance[0].Architecture); processorsProperities.Add("Caption", _processorInfo.Instance[0].Caption); processorsProperities.Add("DataWidth", _processorInfo.Instance[0].DataWidth); processorsProperities.Add("Description", _processorInfo.Instance[0].Description); processorsProperities.Add("DeviceId", _processorInfo.Instance[0].DeviceId); processorsProperities.Add("Family", _processorInfo.Instance[0].Family); processorsProperities.Add("Manufactured", _processorInfo.Instance[0].Manufactured); processorsProperities.Add("Name", _processorInfo.Instance[0].Name); processorsProperities.Add("NumberOfCores", _processorInfo.Instance[0].NumberOfCores); processorsProperities.Add("NumberOfEnabledCore", _processorInfo.Instance[0].NumberOfEnabledCore); processorsProperities.Add("NumberOfLogicalProcessors", _processorInfo.Instance[0].NumberOfLogicalProcessors); processorsProperities.Add("PartNumber", _processorInfo.Instance[0].PartNumber); processorsProperities.Add("ProcessorId", _processorInfo.Instance[0].ProcessorId); processorsProperities.Add("SerialNumber", _processorInfo.Instance[0].SerialNumber); processorsProperities.Add("Status", _processorInfo.Instance[0].Status); processorsProperities.Add("ThreadCount", _processorInfo.Instance[0].ThreadCount); foreach (var processorProperity in processorsProperities) { var item = new ListViewItem(processorProperity.Key, 0); item.SubItems.Add(processorProperity.Value); _form.ProcessorProperitiesListView.Items.Add(item); } _calcProcessorTempThread = new Thread(new ThreadStart(ReloadProcessorTemp)); _calcProcessorSpeedThread = new Thread(new ThreadStart(ReloadProcessorSpeed)); _calcProcessorTempThread.Start(); _calcProcessorSpeedThread.Start(); #endregion #region Get physical memory info _physicalMemoryInfo = physicalMemoryInfo; var physicalMemoryDevices = new Dictionary <string, string> [_physicalMemoryInfo.Instance.Length]; for (int i = 0; i < _physicalMemoryInfo.Instance.Length; i++) { var physicalMemoryProperities = new Dictionary <string, string>(); physicalMemoryProperities.Add("BankLabel", _physicalMemoryInfo.Instance[i].BankLabel); physicalMemoryProperities.Add("Capacity", _physicalMemoryInfo.Instance[i].Capacity); physicalMemoryProperities.Add("Caption", _physicalMemoryInfo.Instance[i].Caption); physicalMemoryProperities.Add("ConfiguredClockSpeed", _physicalMemoryInfo.Instance[i].ConfiguredClockSpeed); physicalMemoryProperities.Add("ConfiguredVoltage", _physicalMemoryInfo.Instance[i].ConfiguredVoltage); physicalMemoryProperities.Add("DataWidth", _physicalMemoryInfo.Instance[i].DataWidth); physicalMemoryProperities.Add("Description", _physicalMemoryInfo.Instance[i].Description); physicalMemoryProperities.Add("DeviceLocator", _physicalMemoryInfo.Instance[i].DeviceLocator); physicalMemoryProperities.Add("Manufacturer", _physicalMemoryInfo.Instance[i].Manufacturer); physicalMemoryProperities.Add("Name", _physicalMemoryInfo.Instance[i].Name); physicalMemoryProperities.Add("PartNumber", _physicalMemoryInfo.Instance[i].PartNumber); physicalMemoryProperities.Add("PositionInRow", _physicalMemoryInfo.Instance[i].PositionInRow); physicalMemoryProperities.Add("Speed", _physicalMemoryInfo.Instance[i].Speed); physicalMemoryDevices[i] = physicalMemoryProperities; } foreach (var device in physicalMemoryDevices) { foreach (var physicalMemoryProperity in device) { var item = new ListViewItem(physicalMemoryProperity.Key, 0); item.SubItems.Add(physicalMemoryProperity.Value); _form.PhysicalMemoryProperitiesListView.Items.Add(item); } } #endregion #region Get disk drive info _diskDriveInfo = diskDriveInfo; var diskDriveDevices = new Dictionary <string, string> [_diskDriveInfo.Instance.Length]; for (int i = 0; i < _diskDriveInfo.Instance.Length; i++) { var diskDriveProperities = new Dictionary <string, string>(); diskDriveProperities.Add("BytesPerSector", _diskDriveInfo.Instance[i].BytesPerSector); diskDriveProperities.Add("Capabilities", _diskDriveInfo.Instance[i].Capabilities); diskDriveProperities.Add("CapabilityDescriptions", _diskDriveInfo.Instance[i].CapabilityDescriptions); diskDriveProperities.Add("Caption", _diskDriveInfo.Instance[i].Caption); diskDriveProperities.Add("Description", _diskDriveInfo.Instance[i].Description); diskDriveProperities.Add("DeviceId", _diskDriveInfo.Instance[i].DeviceId); diskDriveProperities.Add("InterfaceType", _diskDriveInfo.Instance[i].InterfaceType); diskDriveProperities.Add("Manufacturer", _diskDriveInfo.Instance[i].Manufacturer); diskDriveProperities.Add("Model", _diskDriveInfo.Instance[i].Model); diskDriveProperities.Add("Name", _diskDriveInfo.Instance[i].Name); diskDriveProperities.Add("Partitions", _diskDriveInfo.Instance[i].Partitions); diskDriveProperities.Add("PNPDeviceID", _diskDriveInfo.Instance[i].PNPDeviceID); diskDriveProperities.Add("SectorsPerTrack", _diskDriveInfo.Instance[i].SectorsPerTrack); diskDriveProperities.Add("SerialNumber", _diskDriveInfo.Instance[i].SerialNumber); diskDriveProperities.Add("Size", _diskDriveInfo.Instance[i].Size); diskDriveProperities.Add("Status", _diskDriveInfo.Instance[i].Status); diskDriveProperities.Add("SystemName", _diskDriveInfo.Instance[i].SystemName); diskDriveProperities.Add("TotalCylinders", _diskDriveInfo.Instance[i].TotalCylinders); diskDriveProperities.Add("TotalHeads", _diskDriveInfo.Instance[i].TotalHeads); diskDriveProperities.Add("TotalSectors", _diskDriveInfo.Instance[i].TotalSectors); diskDriveProperities.Add("TotalTracks", _diskDriveInfo.Instance[i].TotalTracks); diskDriveProperities.Add("TracksPerCylinder", _diskDriveInfo.Instance[i].TracksPerCylinder); diskDriveDevices[i] = diskDriveProperities; } foreach (var device in diskDriveDevices) { foreach (var diskDriveProperity in device) { var item = new ListViewItem(diskDriveProperity.Key, 0); item.SubItems.Add(diskDriveProperity.Value); _form.DiskDriveProperitiesListView.Items.Add(item); } } #endregion _form.ApplicationClose += _form_ApplicationClose; }
public Link(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.LiteralStruct) .Require(StructureType.LiteralStruct); }
public IfDefElseProcessor(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.LiteralStruct) .Require(StructureType.Any) .Require(StructureType.Any); }
public IDataProcessor Build() { if (_state != 0) { throw new InvalidOperationException(); } _state = 1; using (Timer.Step("DataProcessorBuilder.Build")) { // flatten tree into list where dependants come later var queue = ProcessorInfo.SortDependenciesFirst(_nodes); // loop through processors, adding them to their source writers for (var ix = 0; ix < queue.Count; ix++) { var o = queue[ix]; var needsSplit = o.GetSourceWriters().Count() > 1; // if the processor needs data from multiple writers, // then insert an intermediate node to store the state if (needsSplit) { var newNodes = o.Split(out WriterInfo newWriter); _writers.Add(newWriter); // update the queue queue.RemoveAt(ix); queue.InsertRange(ix, newNodes); // reprime the current node o = queue[ix]; } var w = o.GetSourceWriters().SingleOrDefault(); // no source writer, then nothing to do if (w == null) { Log.Warn($"No source writer for: {o.Name}"); continue; } // add it to the writer w.Append(o); } // loop through the writers, compiling each one foreach (var w in _writers) { var expr = w.GetFinalLambda(); if (Log.IsVerbose) { Log.Verbose($"Compiling writer: {w.Name}", expr); } var action = _compiler.Compile(w.Name, expr); w.Writer.SetAction(action); } // return the data processor var cs = _writers.Select(w => w.Writer) .OfType <IClosable>() .ToArray(); return(new DataProcessor(cs)); } }
public TodayProcessor(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.RequireOptional(StructureType.LiteralStruct | StructureType.MarcoStruct); }
public SetWorkingDirectory(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.LiteralStruct); }
public DefineMarco(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.LiteralStruct) .Require(StructureType.Any); }
public static async void SendToElastic(this sFlowDatagram datagram) { string request = ""; string datetime = DateTime.Now.ToString("o"); foreach (Sample sample in datagram.Samples) { if (sample == null) { continue; } Dictionary <string, object> doc = new Dictionary <string, object>(); doc.Add("@timestamp", datetime); doc.Add("sflow_source", datagram.AgentAddress.ToString()); doc.Add("sflow_sequence", datagram.SequenceNumber); if (sample.Type == SampleType.Flow) { FlowSample flowSample = (FlowSample)sample; doc.Add("sampling_rate", flowSample.SamplingRate); doc.Add("sampling_pool", flowSample.SamplingPool); doc.Add("dropped_packets", flowSample.DroppedPackets); doc.Add("frame_in_interface_value", flowSample.InputInterface.Value); doc.Add("frame_out_interface_value", flowSample.OutputInterface.Value); doc.Add("frame_out_interface_format", flowSample.OutputInterface.Format.ToString()); doc.Add("frame_out_interface_discard", flowSample.OutputInterface.DiscardReason.ToString()); foreach (FlowRecord record in flowSample.Records) { if (record.Type == FlowRecordType.RawPacketHeader) { RawPacketHeader rawPacketHeader = (RawPacketHeader)record; doc.Add("frame_length_octets", rawPacketHeader.FrameLength); if (rawPacketHeader.HeaderProtocol == HeaderProtocol.Ethernet) { EthernetFrame ethFrame = (EthernetFrame)rawPacketHeader.Header; doc.Add("mac_source", ethFrame.SourceMAC.ToString()); doc.Add("mac_destination", ethFrame.DestinationMAC.ToString()); doc.Add("packet_type", ethFrame.PacketType.ToString()); ProtocolType ProtocolType = 0; if (ethFrame.PacketType == PacketType.IPv4) { IPv4Packet packet = (IPv4Packet)ethFrame.Packet; doc.Add("ip_source", packet.SourceAddress.ToString()); doc.Add("ip_destination", packet.DestinationAddress.ToString()); doc.Add("ip_ttl", packet.TimeToLive); doc.Add("protocol_type", packet.ProtocolType.ToString()); ProtocolType = packet.ProtocolType; } if (ProtocolType == ProtocolType.TCP) { TCP TCP = (TCP)ethFrame.Packet.Payload; doc.Add("port_source", TCP.SourcePort); doc.Add("port_destination", TCP.DestinationPort); } else if (ProtocolType == ProtocolType.UDP) { UDP UDP = (UDP)ethFrame.Packet.Payload; doc.Add("port_source", UDP.SourcePort); doc.Add("port_destination", UDP.DestinationPort); } } } else if (record.Type == FlowRecordType.ExtSwitchData) { SwitchData switchData = (SwitchData)record; doc.Add("vlan_in", switchData.IncomingVLAN); doc.Add("vlan_out", switchData.OutgoingVLAN); } } } else if (sample.Type == SampleType.Counter) { CounterSample countSample = (CounterSample)sample; foreach (CounterRecord record in countSample.Records) { if (record.Type == CounterRecordType.GenericInterface) { Generic gi = (Generic)record; doc.Add("if_direction", gi.IfDirection.ToString()); doc.Add("if_in_broadcast_pkts", gi.IfInBroadcastPkts); doc.Add("if_index", gi.IfIndex); doc.Add("if_in_discards", gi.IfInDiscards); doc.Add("if_in_errors", gi.IfInErrors); doc.Add("if_in_multicast_pkts", gi.IfInMulticastPkts); doc.Add("if_in_octets", gi.IfInOctets); doc.Add("if_in_unicast_pkts", gi.IfInUcastPkts); doc.Add("if_in_unknown_protos", gi.IfInUnknownProtos); doc.Add("if_out_broadcast_pkts", gi.IfOutBroadcastPkts); doc.Add("if_out_discards", gi.IfOutDiscards); doc.Add("if_out_errors", gi.IfOutErrors); doc.Add("if_out_multicast_pkts", gi.IfOutMulticastPkts); doc.Add("if_out_octets", gi.IfOutOctets); doc.Add("if_out_unicast_ptks", gi.IfOutUcastPkts); doc.Add("if_promiscuous_mode", gi.IfPromiscuousMode); doc.Add("if_speed", gi.IfSpeed); doc.Add("if_type", gi.IfType); doc.Add("if_status_up_admin", gi.IfStatus.HasFlag(Generic.IfStatusFlags.IfAdminStatusUp)); doc.Add("if_status_up_operational", gi.IfStatus.HasFlag(Generic.IfStatusFlags.IfOperStatusUp)); } else if (record.Type == CounterRecordType.EthernetInterface) { Ethernet eth = (Ethernet)record; doc.Add("eth_alignment_errors", eth.AlignmentErrors); doc.Add("eth_carrier_sense_errors", eth.CarrierSenseErrors); doc.Add("eth_deferred_transmissions", eth.DeferredTransmissions); doc.Add("eth_excessive_collisions", eth.ExcessiveCollisions); doc.Add("eth_fcs_errors", eth.FCSErrors); doc.Add("eth_frame_too_longs", eth.FrameTooLongs); doc.Add("eth_mac_recieve_errors", eth.InternalMacReceiveErrors); doc.Add("eth_mac_transmit_errors", eth.InternalMacTransmitErrors); doc.Add("eth_late_collisions", eth.LateCollisions); doc.Add("eth_multiple_collision_frames", eth.MultipleCollisionFrames); doc.Add("eth_single_collision_frames", eth.SingleCollisionFrames); doc.Add("eth_sqe_test_errors", eth.SQETestErrors); doc.Add("eth_symbol_errors", eth.SymbolErrors); } else if (record.Type == CounterRecordType.VLAN) { VLAN vlan = (VLAN)record; doc.Add("vlan_multicast_pkts", vlan.MulticastPkts); doc.Add("vlan_octets", vlan.Octets); doc.Add("vlan_unicast_pkts", vlan.UCastPkts); doc.Add("vlan_id", vlan.VlanID); } else if (record.Type == CounterRecordType.ProcessorInformation) { ProcessorInfo pi = (ProcessorInfo)record; doc.Add("stats_cpu_percent_1m", pi.Cpu1mPercentage); doc.Add("stats_cpu_percent", pi.Cpu5mPercentage); doc.Add("stats_cpu_5s_percent", pi.Cpu5sPercentage); doc.Add("stats_memory_free", pi.FreeMemory); doc.Add("stats_memory_total", pi.TotalMemory); } } } request += "{\"create\":{\"_index\":\"" + PREFIX + sample.Type.ToString().ToLower() + "\"}}\n"; request += JsonConvert.SerializeObject(doc) + '\n'; } try { MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(request)); await HC.PostAsync(URI + "/_bulk", new StreamContent(ms) { Headers = { ContentType = MediaTypeHeaderValue.Parse("application/json") } }); ms.Dispose(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public ConcatProcessor(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.Any).MakeVariable(); }
public CodeInline(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.LiteralStruct); }
public void Patch() { var patchedMethods = new List <MethodBase>((HarmonySharedState_GetPatchedMethods.Invoke(null, new object[0]) as IEnumerable <MethodBase>)); UnityEngine.Debug.Log($"{patchedMethods.Count} patched methods found."); var processors = new List <ProcessorInfo>(); foreach (var method in patchedMethods) { var patchInfo = HarmonySharedState_GetPatchInfo.Invoke(null, new object[] { method }); if (patchInfo == null) { continue; } var prefixes = (object[])PatchInfo_prefixed.GetValue(patchInfo); foreach (var patch in prefixes) { processors.Add(ProcessorInfo .Create(CreateHarmony(patch), method) .AddPrefix(CreateHarmonyMethod(patch))); } var postfixes = (object[])PatchInfo_postfixes.GetValue(patchInfo); foreach (var patch in postfixes) { processors.Add(ProcessorInfo .Create(CreateHarmony(patch), method) .AddPostfix(CreateHarmonyMethod(patch))); } var transpilers = (object[])PatchInfo_transpilers.GetValue(patchInfo); foreach (var patch in transpilers) { processors.Add(ProcessorInfo .Create(CreateHarmony(patch), method) .AddTranspiler(CreateHarmonyMethod(patch))); } } UnityEngine.Debug.Log($"Reverting patches..."); var oldInstance = HarmonyInstance_Create.Invoke(null, new object[] { "CitiesHarmony" }); foreach (var method in patchedMethods.ToList()) { HarmonyInstance_Unpatch.Invoke(oldInstance, new object[] { method, HarmonyPatchType_All, null }); } // Reset is not needed while we are using a Harmony 2 fork that uses a different assembly name! /* * // Reset shared state * var sharedStateAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name.Contains("HarmonySharedState")); * if (sharedStateAssembly != null) { * var stateField = sharedStateAssembly.GetType("HarmonySharedState")?.GetField("state"); * if (stateField != null) { * UnityEngine.Debug.Log("Resetting HarmonySharedState..."); * stateField.SetValue(null, null); * } * } */ // Apply patches to old Harmony Harmony1SelfPatcher.Apply(harmony, assembly); // Apply patches using Harmony 2.x foreach (var processor in processors) { try { UnityEngine.Debug.Log($"Applying patch for {processor.original.FullDescription()} ({processor.instance.Id})"); processor.Patch(); } catch (Exception e) { UnityEngine.Debug.LogError($"Exception while transferring Harmony 1 patch in {processor.original.FullDescription()} ({processor.instance.Id})"); UnityEngine.Debug.LogException(e); } } }
public TextStyleChangeStyleProcessor(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.MapStruct) .Require(StructureType.LiteralStruct | StructureType.DirectiveStruct) .MakeVariable(); }
public HeadingFormatSetterProcessor(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.MapStruct); headerCounter = HeaderCounter.Instance; }
public SetProperty(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.LiteralStruct) .Require(StructureType.LiteralStruct | StructureType.NumberStruct | StructureType.MapStruct); }
public void AddProcessor(LambdaExpression processor, NameType nameOut, params NameType[] nameIn) { if (_state != 0) { throw new InvalidOperationException(); } if (nameIn == null) { throw new ArgumentNullException(); } if (!nameOut.IsValid) { throw new ArgumentException(); } if (processor == null) { throw new ArgumentNullException(); } if (processor.ReturnType == typeof(void)) { throw new ArgumentException(); } if (nameIn.Length != processor.Parameters.Count()) { throw new ArgumentException(); } if (nameIn.Length == 0) { throw new ArgumentException(); } var maybeType = nameOut.Type.ToMaybe(); if (processor.ReturnType != nameOut.Type && processor.ReturnType != maybeType) { throw new ArgumentException(); } var nout = Get(nameOut); // check that no parameters have multiple inputs if (nout.SourceWriter != null) { throw new InvalidOperationException(); } if (nout.SourceProcessor != null) { throw new InvalidOperationException(); } if (Log.IsInfo) { Log.Info($"AddProcessor: {nameOut} - {string.Join(", ", nameIn)}"); } if (Log.IsVerbose) { Log.Verbose("Expression", processor); } var ns = nameIn.Select(Get).ToArray(); var ni = new ProcessorInfo(processor, ns, nout); _nodes.Add(ni); nout.SourceProcessor = ni; foreach (var n in ns) { n.Consumers.Add(ni); } }
public DefineObjectProcessor(ProcessorInfo info) : base(info) { ProcessorParam.Require(StructureType.LiteralStruct) .Require(StructureType.MapStruct); }
public GetMemberProcessor(ProcessorInfo processorInfo) : base(processorInfo) { ProcessorParam.Require(StructureType.LiteralStruct) .Require(StructureType.LiteralStruct); }