Ejemplo n.º 1
0
        /// <summary>
        /// Performing the log with inprut from an IIterator
        /// </summary>
        /// <param name="iterator"></param>
        /// <param name="stop"></param>
        public void Perform(IIterator iterator, Func <object, bool> stop)
        {
            if (item is IBufferDirectory)
            {
                directory = item as IBufferDirectory;
                WriteTypes();

                /*                StaticExtensionDataPerformerEventPortable.PerformIterator(consumer, iterator as IIterator,
                 *                  iterator as ITimeMeasureProvider, StaticExtensionEventInterfaces.RealtimeLogAnalysis,
                 *                  () => { return stop(null); }); */
                IEnumerable <byte[]> data = Transform(iterator, () => { return(stop(null)); });
                string name;

                if (iterator is BufferReadWrite)
                {
                    name = (iterator as BufferReadWrite).ItemName;
                }
                else
                {
                    name = DateTime.Now.ToString();
                }

                IBufferData d = directory.CreateData(data, name, name, "");
                d.Types = typeBytes;
                StaticExtensionDataPerformerInterfaces.Data.SubmitChanges();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item">Item</param>
 /// <param name="parent">Parent</param>
 public BufferItemWrapper(BufferDirectoryWrapper parent, IBufferData item)
 {
     this.item   = item;
     this.parent = parent;
     parent.items.Add(this);
     StaticExtensionDataPerformerInterfaces.items[item.Id] = this;
 }
Ejemplo n.º 3
0
        void PerformExternal(IBufferData data)
        {
            string reason                   = StaticExtensionDataPerformerInterfaces.Calculation;
            IEnumerable <object> en         = PureEnumerable(data);
            IEnumerator <object> enumerator = en.GetEnumerator();

            using (TimeProviderBackup backup = new TimeProviderBackup(externalComponentCollection, this, 0, reason))
            {
                enumerator.MoveNext();
                IDataRuntime runtime = backup.Runtime;
                IStep        st      = null;
                if (runtime is IStep)
                {
                    st      = runtime as IStep;
                    st.Step = 0;
                }
                externalComponentCollection.ForEach((IStarted started) => { started.Start(time); });
                double last = time;
                Action <double, double, long> act = runtime.Step(null,
                                                                 (double timer) => { }, reason, null);
                int i = 0;
                while (enumerator.MoveNext())
                {
                    act(last, time, i);
                    ++i;
                    if (st != null)
                    {
                        st.Step = i;
                    }
                    last = time;
                }
            }
        }
Ejemplo n.º 4
0
        IEnumerable <object> Enumerable(IBufferData data)
        {
            changeItem(data);
            IEnumerable <byte[]> eb = data.Buffer;
            bool first = true;

            foreach (byte[] b in eb)
            {
                Tuple <DateTime, Dictionary <string, object> > t
                        = bytesToObject(b) as Tuple <DateTime, Dictionary <string, object> >;
                current = t.Item2;
                time    = (t.Item1 - begin).TotalSeconds;
                if (first)
                {
                    if (externalComponentCollection != null)
                    {
                        externalComponentCollection.ForEach((IStarted started) =>
                                                            { started.Start(time); });
                    }
                    first = false;
                    continue;
                }
                yield return(t);
            }
        }
Ejemplo n.º 5
0
        private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row  = dataGridViewFiles.Rows[e.RowIndex];
            IBufferData     d    = row.Tag as IBufferData;
            int             ri   = e.ColumnIndex;
            string          text = row.Cells[ri].Value + "";

            if (ri == 1)
            {
                if (d.Comment.Equals(text))
                {
                    return;
                }
                d.Comment = text;
                return;
            }
            if (ri == 0)
            {
                if (d.Name.Equals(text))
                {
                    return;
                }
                IBufferDirectory dir  = d.Parent as IBufferDirectory;
                List <string>    l    = dir.GetDirectoryNames();
                string           name = d.Name;
                l.Remove(name);
                if (l.Contains(text))
                {
                    MessageBox.Show(this, "Name already exist");
                    row.Cells[ri].Value = name;
                    return;
                }
                d.Name = text;
            }
        }
Ejemplo n.º 6
0
        void Perform(ILogReader reader)
        {
            IEnumerable <object> en = consumer.RealtimeAnalysisEnumerable(reader, Stop,
                                                                          StaticExtensionEventInterfaces.RealtimeLogAnalysis, TimeType.Second, true);
            IEnumerable <byte[]> data = Transform(en);
            IBufferData          d    = directory.CreateData(data, reader.Name, reader.FileName, "");

            d.Types = typeBytes;
        }
Ejemplo n.º 7
0
        IEnumerable <object> PureEnumerable(IBufferData data)
        {
            changeItem(data);
            IEnumerable <byte[]> eb = data.Buffer;

            foreach (byte[] b in eb)
            {
                Tuple <DateTime, Dictionary <string, object> > t
                        = bytesToObject(b) as Tuple <DateTime, Dictionary <string, object> >;
                current = t.Item2;
                time    = (t.Item1 - begin).TotalSeconds;
                yield return(t);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Performs operation
 /// </summary>
 /// <param name="reader">Reader</param>
 /// <param name="stop">Stop</param>
 public void Perform(ILogReader reader, Func <object, bool> stop)
 {
     if (item is IBufferDirectory)
     {
         directory = item as IBufferDirectory;
         WriteTypes();
         IEnumerable <object> en = consumer.RealtimeAnalysisEnumerable(reader, stop,
                                                                       StaticExtensionEventInterfaces.RealtimeLogAnalysis, TimeType.Second, true);
         IEnumerable <byte[]> data = Transform(en);
         IBufferData          d    = directory.CreateData(data, reader.Name, reader.FileName, "");
         d.Types = typeBytes;
         StaticExtensionDataPerformerInterfaces.Data.SubmitChanges();
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Appends a data packet to his priority Queue.
        /// There will be several Queues ordered by priority: lower values first
        /// </summary>
        /// <param name="data">The data to be stored into the priority Queue</param>
        /// <param name="priority">The priority order: the lower the value, the higher the priority</param>
        public void Push(IBufferData data)
        {
            // try to retrieve the data packet List
            // if fail add a new void data packet list
            // append the data to the data packet list

            List <IBufferData> packets;

            if (!_DataQueues.TryGetValue(data.Priority, out packets))
            {
                packets = new List <IBufferData>();
                _DataQueues.Add(data.Priority, packets);
            }
            packets.Add(data);
        }
Ejemplo n.º 10
0
        IEnumerable <object> Enumerable(IBufferDirectory directory)
        {
            IEnumerable <IBufferItem> en = directory.FullDirectory();

            foreach (IBufferItem item in en)
            {
                if (item is IBufferData)
                {
                    IBufferData          data = item as IBufferData;
                    IEnumerable <object> enu  = Enumerable(data);
                    foreach (object o in enu)
                    {
                        yield return(o);
                    }
                }
            }
        }
        /// <summary>
        /// Creates data
        /// </summary>
        /// <param name="directory">Directory</param>
        /// <param name="data">Data</param>
        /// <param name="name"></param>
        /// <param name="fileName">File name</param>
        /// <param name="comment">Comment</param>
        /// <returns>The data</returns>
        public static IBufferData CreateData(this IBufferDirectory directory,
                                             IEnumerable <byte[]> data, string name, string fileName, string comment)
        {
            IDatabaseInterface d = StaticExtensionDataPerformerInterfaces.data;

            /*  !!!    if (d.Filenames.Contains(fileName))
             *    {
             *        throw new Exception("File " + fileName + " already exists");
             *    }*/
            if (directory.GetDirectoryNames().Contains(name))
            {
                throw new Exception(name + " already exists");
            }
            IBufferData ld = d.Create(data, directory.Id, name, fileName, comment);

            return(new BufferItemWrapper(directory as BufferDirectoryWrapper, ld));
        }
Ejemplo n.º 12
0
        /*
         * void NewInterval()
         * {
         *  FormSelectItem form = new FormSelectItem(true);
         *  if (form.ShowDialog(this) != DialogResult.OK)
         *  {
         *      return;
         *  }
         *  AddInterval(form.Selected);
         * }
         *
         * void AddInterval(ILogData data)
         * {
         *  TreeNode s = selected;
         *  if (s == null)
         *  {
         *      return;
         *  }
         *  ILogDirectory d = s.Tag as ILogDirectory;
         *  if ((d == null) | (data == null))
         *  {
         *      return;
         *  }
         *  try
         *  {
         *      List<string> l = d.GetDirectoryNames();
         *      for (int i = 1; ; i++)
         *      {
         *          string n = "New interval" + i;
         *          if (!l.Contains(n))
         *          {
         *              ILogInterval ld = d.CreateIntrerval(data, n, "", 0, (uint)data.Length);
         *              ShowIntervalTable(d, false);
         *              return;
         *          }
         *      }
         *
         *  }
         *  catch (Exception exception)
         *  {
         *      exception.ShowError();
         *  }
         * }
         */

        void ShowContent(IBufferDirectory dir)
        {
            return;

            if (dir == current)
            {
                return;
            }
            current = dir;
            bool isFile = IsFile;
            Dictionary <string, IBufferData> d = new Dictionary <string, IBufferData>();

            foreach (object o in current.Children)
            {
                if (o is IBufferData)
                {
                    IBufferData ld = o as IBufferData;
                    d[ld.Name] = ld;
                }
            }
            List <string> lt = new List <string>(d.Keys);

            lt.Sort();
            bool isRoot = IsRoot;

            if (isFile)
            {
                dataGridViewFiles.Rows.Clear();
                foreach (string key in lt)
                {
                    DataGridViewRow row  = new DataGridViewRow();
                    IBufferData     data = d[key];
                    row.Tag = d[key];
                    row.CreateCells(dataGridViewFiles,
                                    new object[] { data.Name, data.Comment, data.Length, data.FileName });
                    dataGridViewFiles.Rows.Add(row);
                }
                toolStripLabelDrag.Visible = !isRoot;
                newToolStripButton.Visible = false;
                dataGridViewFiles.Visible  = true;
            }
        }
Ejemplo n.º 13
0
        public unsafe bool SaveAsBitmap(IBufferData image, string file)
        {
            if (image.Pixels == IntPtr.Zero)
            {
                return(false);
            }

            IntPtr surface;

            if (image is ISdlSurface)
            {
                surface = ((ISdlSurface)image).Handle;
            }
            else
            {
                var format = screens.Primary.Resolution.Format;
                surface = CreateSurface(image.Pixels, image.Width, image.Height, Depth(format), Pitch(format) * image.Width, format);
            }
            var raw = OpenFile(UTF8_ToNative(file), UTF8_ToNative("wb"));

            SaveBMPRW(surface, raw, 1);
            return(true);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item">Item</param>
 public BufferItemWrapper(IBufferData item)
 {
     this.item = item;
     StaticExtensionDataPerformerInterfaces.items[item.Id] = this;
 }