public void Restart(int dueMillis) { _state = new SensorState(); _nbad = 0; _nreadings = 0; _nstale = 0; readProfile(); if (HasAttribute(SensorAttribute.Immediate) && _timer != null) { _timer.Change(Timeout.Infinite, Timeout.Infinite); } else { if (Enabled) { if (_repeats > 1) { _readings = new FixedSizedQueue <Reading>(_repeats); _timer.Change(dueMillis, _intervalMillis); } else { _timer.Change(Timeout.Infinite, Timeout.Infinite); } } else { _timer.Change(Timeout.Infinite, Timeout.Infinite); } } }
/// <summary> /// Builds a colour map out of the combined colours from several frames. /// </summary> /// <param name="frames">List of frames to sample colour palette from</param> public void BuildPalette(ref FixedSizedQueue <GifFrame> frames) { // Do not build the color palette here if user wants separate palettes created per frame if (m_FramesPerColorSample == 0) { return; } GifFrame frame = frames.ElementAt(0); // Initialize a large image Byte[] combinedPixels = new Byte[3 * frame.Width * frame.Height * (1 + frames.Count() / m_FramesPerColorSample)]; int count = 0; // Stich the large image together out of pixels from several frames for (int i = 0; i < frames.Count(); i += m_FramesPerColorSample) { frame = frames.ElementAt(0); Color32[] p = frame.Data; // Texture data is layered down-top, so flip it for (int th = frame.Height - 1; th >= 0; th--) { for (int tw = 0; tw < frame.Width; tw++) { Color32 color = p[th * frame.Width + tw]; combinedPixels[count] = color.r; count++; combinedPixels[count] = color.g; count++; combinedPixels[count] = color.b; count++; } } } // Run the quantizer over our stitched together image and create reduced palette nq = new NeuQuant(combinedPixels, combinedPixels.Length, (int)m_SampleInterval); m_ColorTab = nq.Process(); }
public TestTransport( Dictionary <Address, TestTransport> transports, PrivateKey privateKey, bool blockBroadcast, int tableSize, int bucketSize, TimeSpan?networkDelay) { _runningEvent = new TaskCompletionSource <object>(); _privateKey = privateKey; _blockBroadcast = blockBroadcast; var loggerId = _privateKey.ToAddress().ToHex(); _logger = Log.ForContext <TestTransport>() .ForContext("Address", loggerId); _peersToReply = new ConcurrentDictionary <byte[], Address>(); _replyToReceive = new ConcurrentDictionary <byte[], Message>(); ReceivedMessages = new ConcurrentBag <Message>(); MessageReceived = new AsyncAutoResetEvent(); _transports = transports; _transports[privateKey.ToAddress()] = this; _networkDelay = networkDelay ?? TimeSpan.Zero; _requests = new AsyncCollection <Request>(); _ignoreTestMessageWithData = new List <string>(); _random = new Random(); Table = new RoutingTable(Address, tableSize, bucketSize); ProcessMessageHandler = new AsyncDelegate <Message>(); Protocol = new KademliaProtocol(Table, this, Address); MessageHistory = new FixedSizedQueue <Message>(30); }
private Thread thread = null; // worker thread public ImagesProvider(int nbrCells) { this.imagesQueue = new FixedSizedQueue<CachedImg>(nbrCells * 2); this.thread = new Thread(run); Debug.Log("starting image provider"); Start(); }
public void Push(string user, WeixinRequest request) { if (!mCache.ContainsKey(user)) { mCache[user] = new FixedSizedQueue <RequestPing>(4); } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { FixedSizedQueue <App> queue = null; while (reader.Read()) { if (reader.TokenType != JsonToken.PropertyName) { break; } var propertyName = (string)reader.Value; if (!reader.Read()) { continue; } if (propertyName == "Apps") { queue = new FixedSizedQueue <App>(serializer.Deserialize <ConcurrentQueue <App> >(reader)); } } return(queue == null? new FixedSizedQueue <App>() : queue); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; _solar1 = GridTerminalSystem.GetBlockWithName("s1") as IMyPowerProducer; _solar2 = GridTerminalSystem.GetBlockWithName("s2") as IMyPowerProducer; _solar3 = GridTerminalSystem.GetBlockWithName("s3") as IMyPowerProducer; _solar4 = GridTerminalSystem.GetBlockWithName("s4") as IMyPowerProducer; _display1 = GridTerminalSystem.GetBlockWithName("display1") as IMyTextPanel; _display2 = GridTerminalSystem.GetBlockWithName("display2") as IMyTextPanel; _displayPower = GridTerminalSystem.GetBlockWithName("display-power") as IMyTextPanel; batteryInfo = new Dictionary <string, FixedSizedQueue <double> >(); batteryInfo["currentPower"] = new FixedSizedQueue <double>(5); batteryInfo["maxPower"] = new FixedSizedQueue <double>(1); batteryInfo["currentInput"] = new FixedSizedQueue <double>(20); batteryInfo["currentOutput"] = new FixedSizedQueue <double>(50); batteryInfo["currentNet"] = new FixedSizedQueue <double>(50); inventoryStats = new Dictionary <string, string>(); inventoryDisplayMapping = new Dictionary <string, IMyTextPanel>(); inventoryDisplayMapping["MyObjectBuilder_Ore"] = GridTerminalSystem.GetBlockWithName("display_ore") as IMyTextPanel; inventoryDisplayMapping["MyObjectBuilder_Ingot"] = GridTerminalSystem.GetBlockWithName("display_ingot") as IMyTextPanel; inventoryDisplayMapping["MyObjectBuilder_Component"] = GridTerminalSystem.GetBlockWithName("display_comp") as IMyTextPanel; tempItemList = new List <MyInventoryItem>(); buildingItemTypes = new[] { "Ore", "Ingot", "Component" }; _logText = new FixedSizedQueue <string>(15); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; tempDebugDisplay = GridTerminalSystem.GetBlockWithName("display1") as IMyTextPanel; permDebugDisplay = GridTerminalSystem.GetBlockWithName("display2") as IMyTextPanel; _logText = new FixedSizedQueue <string>(15); }
public Neuron(int id, CnnNet cnnNet, IEnumerable <AxonGuidanceForceBase> axonGuidanceForces, IEnumerable <SomaGuidanceForceBase> somaGuidanceForces, NeuronType type) { Contract.Requires <ArgumentException>(id >= 0); Contract.Requires <ArgumentNullException>(cnnNet != null); Contract.Requires <ArgumentNullException>(axonGuidanceForces != null); Contract.Requires <ArgumentNullException>(somaGuidanceForces != null); Id = id; Network = cnnNet; AxonWayPoints = new List <NeuronAxonWaypoint> { new NeuronAxonWaypoint(1, this, new Point(PosX, PosY)) }; AxonGuidanceForces = new ReadOnlyCollection <AxonGuidanceForceBase>(axonGuidanceForces.ToList()); SomaGuidanceForces = new ReadOnlyCollection <SomaGuidanceForceBase>(somaGuidanceForces.ToList()); Type = type; HasSomaReachedFinalPosition = Type == NeuronType.Input || Type == NeuronType.Output; HasAxonReachedFinalPosition = Type == NeuronType.Output; _synapses = new List <DendricSynapse>(); _synapsesActivationHistory = new FixedSizedQueue <DendricSynapse[]>(cnnNet.NeuronActivityHistoryLength); _random = new Random(); }
public void GetLastTest() { var queue = new FixedSizedQueue <int>(5); var array = Enumerable.Range(1, 5).Select(x => queue.Enqueue(x)).ToArray(); Assert.IsTrue(queue.GetLast() == 5); }
public Neuron(int id, CnnNet cnnNet, IEnumerable<AxonGuidanceForceBase> axonGuidanceForces, IEnumerable<SomaGuidanceForceBase> somaGuidanceForces, NeuronType type) { Contract.Requires<ArgumentException>(id >= 0); Contract.Requires<ArgumentNullException>(cnnNet != null); Contract.Requires<ArgumentNullException>(axonGuidanceForces != null); Contract.Requires<ArgumentNullException>(somaGuidanceForces != null); Id = id; Network = cnnNet; AxonWayPoints = new List<NeuronAxonWaypoint> { new NeuronAxonWaypoint(1, this, new Point(PosX, PosY)) }; AxonGuidanceForces = new ReadOnlyCollection<AxonGuidanceForceBase>(axonGuidanceForces.ToList()); SomaGuidanceForces = new ReadOnlyCollection<SomaGuidanceForceBase>(somaGuidanceForces.ToList()); Type = type; HasSomaReachedFinalPosition = Type == NeuronType.Input || Type == NeuronType.Output; HasAxonReachedFinalPosition = Type == NeuronType.Output; _synapses = new List<DendricSynapse>(); _synapsesActivationHistory = new FixedSizedQueue<DendricSynapse[]>(cnnNet.NeuronActivityHistoryLength); _random = new Random(); }
public void readProfile() { int defaultInterval = 0, defaultRepeats = 0; switch (Name) { case "Wind": defaultInterval = 30; defaultRepeats = 3; break; case "Sun": defaultInterval = 60; defaultRepeats = 1; break; case "HumanIntervention": defaultInterval = 0; defaultRepeats = 1; break; case "Rain": defaultInterval = 30; defaultRepeats = 2; break; case "Clouds": defaultInterval = 30; defaultRepeats = 3; break; case "Humidity": defaultInterval = 30; defaultRepeats = 4; break; } _interval = 1000 * Convert.ToInt32(wisesafe._profile.GetValue(Const.wiseSafeToOperateDriverID, Name, "Interval", defaultInterval.ToString())); _repeats = Convert.ToInt32(wisesafe._profile.GetValue(Const.wiseSafeToOperateDriverID, Name, "Repeats", defaultRepeats.ToString())); _isSafeQueue = new FixedSizedQueue <bool>(_repeats); Enabled = Convert.ToBoolean(wisesafe._profile.GetValue(Const.wiseSafeToOperateDriverID, Name, "Enabled", true.ToString())); readSensorProfile(); }
/// @endcond public static void Initialize() { if (isInitiate) { return; } NRDebugger.Log("[NRRgbCamera] Initialize"); m_NativeCamera = new NativeCamera(); #if !UNITY_EDITOR m_NativeCamera.Create(); m_NativeCamera.SetCaptureCallback(Capture); #endif if (FramePool == null) { FramePool = new ObjectPool(); FramePool.InitCount = 10; } if (m_RGBFrames == null) { m_RGBFrames = new FixedSizedQueue(FramePool); m_RGBFrames.Limit = 5; } m_ActiveTextures = new List <NRRGBCamTexture>(); isInitiate = true; SetImageFormat(CameraImageFormat.RGB_888); }
private void Awake() { _spellStore = new FixedSizedQueue <Spell> { Limit = _spellStoreLimit }; UpdateSpells(); }
public void Push(string user, WeixinRequest request) { if (!mCache.ContainsKey(user)) { mCache[user] = new FixedSizedQueue<RequestPing>(4); } }
/// <summary> /// Reads possible new log file entries form the file that is observed. /// </summary> private void ReadNewLogMessagesFromFile() { if (mFileReader == null || Equals(mFileReader.BaseStream.Length, mLastFileOffset)) { return; } if (mLastFileOffset > mFileReader.BaseStream.Length) { // the current log file was re-created. Observe from beginning on. mLastFileOffset = 0; } mFileReader.BaseStream.Seek( mLastFileOffset , SeekOrigin.Begin); string line; string dataToParse = string.Empty; FixedSizedQueue <LogMessage> messages = new FixedSizedQueue <LogMessage>( Properties.Settings.Default.MaxLogMessages); while ((line = mFileReader.ReadLine()) != null) { dataToParse += line; int log4NetEndTag = dataToParse.IndexOf( LOG4NET_LOGMSG_END , StringComparison.Ordinal); if (log4NetEndTag > 0) { LogMessage newLogMsg; try { newLogMsg = new LogMessageLog4Net( dataToParse , ++mLogNumber); } catch (Exception ex) { Logger.Warn(ex.Message); continue; } messages.Enqueue(newLogMsg); dataToParse = dataToParse.Substring( log4NetEndTag , dataToParse.Length - (log4NetEndTag + LOG4NET_LOGMSG_END.Length)); } } mLastFileOffset = mFileReader.BaseStream.Position; mLogHandler?.HandleMessage(messages.ToArray()); }
public DataWindow(IDataProvider <TData> provider, int windowSize) { this.provider = provider; this.windowSize = windowSize; previousQ = new FixedSizedQueue <TData>(windowSize); nextQ = new FixedSizedQueue <TData>(windowSize); Task.Run(() => CacheInBackground()); }
internal void Start(ThreadPriority priority, int maxCapturedFrames) { StoredFrames = new FixedSizedQueue <GifFrame>(maxCapturedFrames); _thread = new Thread(Run) { Priority = priority }; _thread.Start(); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update100; inventoryDisplayMapping = new Dictionary <string, IMyTextPanel>(); // ------------------------------ Begin things you can configure -------------------------- /** These are the displays you need to run this. They're all mandatory and the script will fail if they don't exist. * Create the 5 displays, name them to match the strings below, and set them to display text/images BEFORE * running the script. If you read this after you ran the script, just do it and re-compile/rerun. */ inventoryDisplayMapping["MyObjectBuilder_Ore"] = GridTerminalSystem.GetBlockWithName("display_ore") as IMyTextPanel; inventoryDisplayMapping["MyObjectBuilder_Ingot"] = GridTerminalSystem.GetBlockWithName("display_ingot") as IMyTextPanel; inventoryDisplayMapping["MyObjectBuilder_Component"] = GridTerminalSystem.GetBlockWithName("display_comp") as IMyTextPanel; _display_temp = GridTerminalSystem.GetBlockWithName("display_debug_temp") as IMyTextPanel; _display_perm = GridTerminalSystem.GetBlockWithName("display_debug_perm") as IMyTextPanel; // NOTE: For the system to create these items, you must have at least ONE of it already in your inventory. // Also NOTE: This script only takes into account the grid the prog block is part of, not subgrids. // The amount of each non-bulk item you want to have on hand at all times targetItemCount = 10000; // The amount of each bulk item you want to have on hand at all times (list of bulk items below) bulkItemCount = 20000; // List of items to create in bulk. You can add to or remove from this list, but be sure you're using the // name for the item that the code uses (Not always the same as in-game text). bulkItems = new HashSet <string>(); bulkItems.Add("SteelPlate"); bulkItems.Add("ConstructionComponent"); bulkItems.Add("InteriorPlate"); bulkItems.Add("ThrustComponent"); bulkItems.Add("BulletproofGlass"); // --------------------------------- End things you can configure ------------------------------------ inventoryStats = new Dictionary <string, string>(); buildingItemTypes = new[] { "Ore", "Ingot", "Component" }; toolTypes = new[] { "Weld", "Grind", "Drill", "Rifle" }; inventoryToBlueprintMap = new Dictionary <string, string>(); inventoryToBlueprintMap["Computer"] = "ComputerComponent"; inventoryToBlueprintMap["Construction"] = "ConstructionComponent"; inventoryToBlueprintMap["Detector"] = "DetectorComponent"; inventoryToBlueprintMap["Girder"] = "GirderComponent"; inventoryToBlueprintMap["Medical"] = "MedicalComponent"; inventoryToBlueprintMap["Motor"] = "MotorComponent"; inventoryToBlueprintMap["RadioCommunication"] = "RadioCommunicationComponent"; inventoryToBlueprintMap["Thrust"] = "ThrustComponent"; inventoryToBlueprintMap["Reactor"] = "ReactorComponent"; inventoryToBlueprintMap["Reactor"] = "ReactorComponent"; inventoryToBlueprintMap["GravityGenerator"] = "GravityGeneratorComponent"; //blueprintToInventoryMap = inventoryToBlueprintMap.ToDictionary(i => i.Value, i => i.Key); tempItemList = new List <MyInventoryItem>(); _logText = new FixedSizedQueue <string>(15); unproducable = new HashSet <string>(); }
public IchimokuCloudBtcStrategy(IOptions <MacdStrategyOptions> options, IIndicatorFactory indicatorFactory) { _ichimokuCloudIndicator = indicatorFactory.GetIchimokuCloud(); _rsiIndicator = indicatorFactory.GetRsiIndicator(7); _shortEmaIndicator = indicatorFactory.GetEmaIndicator(options.Value.ShortWeight); _longEmaIndicator = indicatorFactory.GetEmaIndicator(options.Value.LongWeight); _last5Macd = new FixedSizedQueue <decimal>(5); }
protected BaseNamedPipe(bool errorToConsole, string pipeName) { _errorToConsole = errorToConsole; _errorBuffer = new FixedSizedQueue <string>(500); if (pipeName != null) { _pipeName = pipeName; } }
public IchimokuCloudIndicator() { _shortPeriodQueue = new FixedSizedQueue <CandleModel>(Short); _middlePeriodQueue = new FixedSizedQueue <CandleModel>(Middle); _longPeriodQueue = new FixedSizedQueue <CandleModel>(Long); _tenkenSenQueue = new FixedSizedQueue <decimal>(Shift); _kijunSenQueue = new FixedSizedQueue <decimal>(Shift); _longPeriodHighestHighQueue = new FixedSizedQueue <decimal>(Shift); _longPeriodLowestLowQueue = new FixedSizedQueue <decimal>(Shift); }
public FilterQuaternion(float processNoise = 1, float measurementNoise = 1, int period = 5, int queueCount = 15) { _period = period; _quaternionQueue = new FixedSizedQueue <GyroQuaternion>(queueCount); _kalmanFilterX = new KalmanFilter(processNoise, measurementNoise); _kalmanFilterY = new KalmanFilter(processNoise, measurementNoise); _kalmanFilterZ = new KalmanFilter(processNoise, measurementNoise); _kalmanFilterW = new KalmanFilter(processNoise, measurementNoise); }
/// <summary> /// Constructor /// </summary> /// <param name="epc"></param> /// <param name="antenna"></param> public MetaTag(string epc, Antenna antenna) { EPC = epc; Antenna = antenna; TimeStampDateTime = DateTime.Now; TimeStamp = TimeStampDateTime.Ticks; rssiQueue = new FixedSizedQueue <int>(FixedSizedQueue <int> .Size); }
/// <summary> /// Closes all open streams and removes all data /// </summary> public void Dispose() { if (MainStream != null) { MainStream.Close(); MainStream.Dispose(); } Entries.Clear(); Buffer = null; FileHandle.DeleteFile(TmpFile); }
internal void Start(ThreadPriority priority, int maxCapturedFrames) { // make sure everything is cleared from previous session Clear(); StoredFrames = new FixedSizedQueue <GifFrame>(maxCapturedFrames); _thread = new Thread(Run) { Priority = priority }; _thread.Start(); }
public PersistenceManager(PluginManager pluginManager, string xmlFilename) { _Log = LogManager.GetLogger(GetType()); _PluginManager = pluginManager; _XmlFilename = xmlFilename; _SaveQueue = new FixedSizedQueue <string>(1); using (Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TouchRemote.Model.Persistence.Controls.xsd")) { _Schema = XmlSchema.Read(schemaStream, null); } }
public void Persist(IBitcoinPrice bitcoinPrice) { FixedSizedQueue <IBitcoinPrice> newQueue = new FixedSizedQueue <IBitcoinPrice>(this._repositoryServiceOptions.MemorySize); newQueue.Enqueue(bitcoinPrice); this.inMemoryStorage.AddOrUpdate(bitcoinPrice.Currency, newQueue, (key, existingVal) => { existingVal.Enqueue(bitcoinPrice); return(existingVal); }); }
public MacdIchimokuStrategy(IOptions <MacdStrategyOptions> options, IIndicatorFactory indicatorFactory) { _shortEmaIndicator = indicatorFactory.GetEmaIndicator(options.Value.ShortWeight); _longEmaIndicator = indicatorFactory.GetEmaIndicator(options.Value.LongWeight); _ema200Indicator = indicatorFactory.GetEmaIndicator(200); _ichimokuCloudIndicator = indicatorFactory.GetIchimokuCloud(); _last10Ema200ClosePriceRate = new FixedSizedQueue <decimal>(10); }
public EthMacdStrategy(IOptions <MacdStrategyOptions> options, IIndicatorFactory indicatorFactory, IExchangeProvider exchangeProvider) { _exchangeProvider = exchangeProvider; _options = options.Value; _shortEmaIndicator = indicatorFactory.GetEmaIndicator(_options.ShortWeight); _longEmaIndicator = indicatorFactory.GetEmaIndicator(_options.LongWeight); _signalEmaIndicator = indicatorFactory.GetEmaIndicator(_options.Signal); _macdStatistcsQueue = new FixedSizedQueue <MacdStatistic>(6); _macdTempStatisticsQueue = new FixedSizedQueue <MacdStatistic>(200); _volumenQueue = new FixedSizedQueue <decimal>(100); }
public CustomBtcStrategy(IOptions <MacdStrategyOptions> options, IIndicatorFactory indicatorFactory, IExchangeProvider exchangeProvider) { _exchangeProvider = exchangeProvider; _options = options.Value; _shortEmaIndicator = indicatorFactory.GetEmaIndicator(_options.ShortWeight); _longEmaIndicator = indicatorFactory.GetEmaIndicator(_options.LongWeight); _signalEmaIndicator = indicatorFactory.GetEmaIndicator(_options.Signal); _ichimokuCloudIndicator = indicatorFactory.GetIchimokuCloud(); _volumenQueue = new FixedSizedQueue <decimal>(100); }
/// <summary> /// Reads possible new log file entries form the file that is observed. /// </summary> private void ReadNewLogMessagesFromFile() { if (mFileReader == null || Equals(mFileReader.BaseStream.Length, mLastFileOffset)) { return; } if (mLastFileOffset > mFileReader.BaseStream.Length) { // the current log file was re-created. Observe from beginning on. mLastFileOffset = 0; } mFileReader.BaseStream.Seek( mLastFileOffset , SeekOrigin.Begin); string currentLine; string messageLines = string.Empty; FixedSizedQueue <LogMessage> messages = new FixedSizedQueue <LogMessage>( Properties.Settings.Default.MaxLogMessages); while ((currentLine = mFileReader.ReadLine()) != null) { LogMessageCustom cstmLgMsg; try { messageLines += currentLine; cstmLgMsg = new LogMessageCustom( messageLines , mLogNumber + 1 , mColumnizer); } catch (Exception ex) { Logger.Warn(ex.Message); continue; } messageLines = string.Empty; mLogNumber++; messages.Enqueue(cstmLgMsg); } mLastFileOffset = mFileReader.BaseStream.Position; mLogHandler?.HandleMessage(messages.ToArray()); }
public TacticalMap() { InitializeComponent(); History = new FixedSizedQueue <SortedDictionary <int, GranularObjectInformation> >(4); if (DebugTools.IsInDesignMode()) { return; } Global.Game.OnEndTurn += CalculateTurnInformation; }
public LibraryCache(int size) { mQueue = new FixedSizedQueue<LibrarySearchResult>(size); }
void Awake() { fixSizedQueue = new FixedSizedQueue<GameEvent>(GuiConstants.EVENT_PANEL_SIZE); GameLogger.printRed("Queue CREATED!"); }