Exemplo n.º 1
0
        void ITagInterface.UpdateEvent(TagEvent e)
        {
            bool ckd;

            if ((Module == null) || (Module == e.ModuleName))
            {
                if (e.Name == Sort)
                {
                    try
                    {
                        if (e.Data == base.Text)
                        {
                            ckd = true;
                        }
                        else
                        {
                            ckd = false;
                        }

                        this.BeginInvoke(new InvokeDelegate(TagInvoke), ckd);
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine("TagState, " + ex.Message + "\n");
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Add the unique data or min/max if it's a valid number
        public void Uniques(TagEvent e)
        {
            bool DataFound = false;

            if (e.ValueValid)
            {
                //Update the min / max of the tag
                Value(e.Value);
            }
            else
            {
                //does this string already exist?
                foreach (string s in Data)
                {
                    if (s == e.Data)
                    {
                        DataFound = true;
                    }
                }

                //Add data string if not found
                if (false == DataFound)
                {
                    Data.Add(e.Data);
                }
            }
        }
Exemplo n.º 3
0
        public void TagInvoke(TagEvent e)
        {
            int i;

            //can have multiple series on one chart
            for (i = 0; i < base.Series.Count; i++)
            {
                if (base.Series[i].Name == e.Name)
                {
                    if (base.Series[i].Points.Count < base.ChartAreas[0].AxisX.Maximum)
                    {
                        base.Series[i].Points.Add(e.Value);
                    }
                    else
                    {
                        indx = int.Parse(base.Series[i].GetCustomProperty("index"));

                        base.Series[i].Points[indx].SetValueY(e.Value);

                        if (++indx > base.ChartAreas[0].AxisX.Maximum - 1)
                        {
                            indx = 0;
                        }

                        base.Series[i].SetCustomProperty("index", indx.ToString());

                        Invalidate();
                    }
                }
            }
        }
Exemplo n.º 4
0
 //Update the chart
 void ITagInterface.UpdateEvent(TagEvent e)
 {
     //Todo; Suport multiple chart areas
     if ((Module == null) || (Module == e.ModuleName))
     {
         this.BeginInvoke(new InvokeDelegate(TagInvoke), e);
     }
 }
Exemplo n.º 5
0
        void ITagInterface.UpdateEvent(TagEvent e)
        {
            bool ckd;

            if ((Module == null) || (Module == e.ModuleName))
            {
                if (e.Name == Sort)
                {
                    //Apply the bitmask to the passed in data
                    if (((UInt16)e.Value & U16_Mask) == U16_Mask)
                    {
                        ckd = true;
                    }
                    else
                    {
                        ckd = false;
                    }

                    this.BeginInvoke(new InvokeDelegate(TagInvoke), ckd);
                }
            }
        }
Exemplo n.º 6
0
        //Create a list of unique module/tag/data combinations
        public void Uniques(TagEvent e)
        {
            bool TagNameFound = false;

            //Search to see if tag exists
            foreach (Tags tg in TagList)
            {
                if (tg.Name == e.Name)
                {
                    //found, now check data and values
                    TagNameFound = true;
                    tg.Uniques(e);
                }
            }

            //add tag to list of unique tags
            if (false == TagNameFound)
            {
                TagList.Add(new Tags(e));

                TagList.Sort();
            }
        }
Exemplo n.º 7
0
        public Tags(TagEvent e)
        {
            Name = e.Name;

            if (e.ValueValid)
            {
                if (e.Value > max)
                {
                    max = e.Value;
                }

                if (e.Value < min)
                {
                    min = e.Value;
                }

                ValueValid = true;
            }
            else
            {
                Data.Add(e.Data);
            }
        }
Exemplo n.º 8
0
        public void TagInvoke(TagEvent e)
        {
            int i;

            //can have multiple series on one chart
            for (i = 0; i < base.Series.Count; i++)
            {
                if (base.Series[i].Name == e.Name)
                {
                    if (base.Series[i].Points.Count < base.ChartAreas[0].AxisX.Maximum)
                    {
                        base.Series[i].Points.Add(e.Value);
                    }
                    else
                    {
                        indx = int.Parse(base.Series[i].GetCustomProperty("index"));

                        base.Series[i].Points[indx].SetValueY(e.Value);

                        if (++indx > base.ChartAreas[0].AxisX.Maximum - 1) indx = 0;

                        base.Series[i].SetCustomProperty("index", indx.ToString());

                        Invalidate();
                    }
                }
            }
        }
Exemplo n.º 9
0
        //update the list of unique tags
        private void MyUpdate(TagEvent e)
        {
            bool ModuleNameFound = false;

            //Search to see if tag exists
            foreach (Module m in ModuleList)
            {
                if (m.ModuleName == e.ModuleName)
                {
                    ModuleNameFound = true;

                    //module found, add tag or data if unique
                    m.Uniques(e);
                }
            }

            if (false == ModuleNameFound)
            {
                ModuleList.Add(new Module(e));

                ModuleList.Sort();

                //we have a new tag, redisplay them all
                ClearModuleTextBox('d');

                foreach (Module m in ModuleList)
                {
                    Trace.WriteLine(m.ModuleName + "\n");
                    AppendModuleTextBox(m.ModuleName + "\r\n");
                }
            }
        }
Exemplo n.º 10
0
        void ITagInterface.UpdateEvent(TagEvent e)
        {
            string txt;

            if ((Module == null) || (Module == e.ModuleName))
            {
                if (e.Name == Sort)
                {
                    if (base.Multiline)
                    {
                        try
                        {
                            this.BeginInvoke(new InvokeDelegate(TagInvoke), e.Data + "\r\n");
                        }
                        catch (Exception ex)
                        {
                            Trace.WriteLine("TagText1, " + ex.Message + "\n");
                        }
                    }
                    else
                    {
                        this.BeginInvoke(new InvokeDelegate(TagInvoke2), e.Data);
                    }
                }

                if (Sort == "*")
                {
                    try
                    {
                        if (base.Multiline)
                        {
                            if (e.Name.Length < TabSize)
                            {
                                txt = e.Name + "\t\t\t\t" + e.Data + "\r\n";
                            }
                            else if (e.Name.Length < TabSize * 2)
                            {
                                txt = e.Name + "\t\t\t" + e.Data + "\r\n";
                            }
                            else if (e.Name.Length < TabSize * 3)
                            {
                                txt = e.Name + "\t\t" + e.Data + "\r\n";
                            }
                            else
                            {
                                txt = e.Name + "\t" + e.Data + "\r\n";
                            }

                            //were in the serial ports thread, update the thread in the GUI context
                            this.BeginInvoke(new InvokeDelegate(TagInvoke), txt);
                        }
                        else
                        {
                            txt = e.Name + "\t\t" + e.Data + "\r\n";
                            this.BeginInvoke(new InvokeDelegate(TagInvoke2), txt);
                        }

                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine("TagText, " + ex.Message + "\n");
                    }
                }
            }
        }
Exemplo n.º 11
0
        void ITagInterface.UpdateEvent(TagEvent e)
        {
            string txt;

            if ((Module == null) || (Module == e.ModuleName))
            {
                if (e.Name == Sort)
                {
                    if (base.Multiline)
                    {
                        try
                        {
                            this.BeginInvoke(new InvokeDelegate(TagInvoke), e.Data + "\r\n");
                        }
                        catch (Exception ex)
                        {
                            Trace.WriteLine("TagText1, " + ex.Message + "\n");
                        }
                    }
                    else
                    {
                        this.BeginInvoke(new InvokeDelegate(TagInvoke2), e.Data);
                    }
                }

                if (Sort == "*")
                {
                    try
                    {
                        if (base.Multiline)
                        {
                            if (e.Name.Length < TabSize)
                            {
                                txt = e.Name + "\t\t\t\t" + e.Data + "\r\n";
                            }
                            else if (e.Name.Length < TabSize * 2)
                            {
                                txt = e.Name + "\t\t\t" + e.Data + "\r\n";
                            }
                            else if (e.Name.Length < TabSize * 3)
                            {
                                txt = e.Name + "\t\t" + e.Data + "\r\n";
                            }
                            else
                            {
                                txt = e.Name + "\t" + e.Data + "\r\n";
                            }

                            //were in the serial ports thread, update the thread in the GUI context
                            this.BeginInvoke(new InvokeDelegate(TagInvoke), txt);
                        }
                        else
                        {
                            txt = e.Name + "\t\t" + e.Data + "\r\n";
                            this.BeginInvoke(new InvokeDelegate(TagInvoke2), txt);
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine("TagText, " + ex.Message + "\n");
                    }
                }
            }
        }
Exemplo n.º 12
0
        void ITagInterface.UpdateEvent(TagEvent e)
        {
            bool ckd;

            if ((Module == null) || (Module == e.ModuleName))
            {
                if (e.Name == Sort)
                {
                    //Apply the bitmask to the passed in data
                    if ( ((UInt16)e.Value & U16_Mask) == U16_Mask)
                        ckd = true;
                    else
                        ckd = false;

                    this.BeginInvoke(new InvokeDelegate(TagInvoke), ckd);
                }
            }
        }
Exemplo n.º 13
0
        public Module(TagEvent e)
        {
            ModuleName = e.ModuleName;

            TagList.Add(new Tags(e));
        }
Exemplo n.º 14
0
        //find the next tag and data, set an event to all listeners
        private int ParseTags(string instr, int offset)
        {
            int start;
            int end = instr.Length;
            int comma;
            int comma2;
            int d;

            try
            {
                //Tag format is >string,string,string<
                start = instr.IndexOf(">", offset);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("serialx, " + ex.Message + "\n");
                Type ep = ex.GetType();
                return end;
            }

            //how to determine we missed a '>'
            if (start >= 0)//May be first character
            {
                try
                {
                    end = instr.IndexOf("<", start + 1);

                    if (end > start + 5)//>a,b,c< absolute minimum valid tag
                    {
                        //found start and end, find the comma
                        comma = instr.IndexOf(",", start + 1);

                        if (comma > 0)
                        {
                            //find the second comma
                            comma2 = instr.IndexOf(",", comma + 1);
                            if(comma2<0) comma2 = int.MaxValue;

                            int wspace = instr.IndexOf(" ", comma + 1);
                            if (wspace < 0) wspace = int.MaxValue;

                            int period = instr.IndexOf(".", comma + 1);
                            if (period < 0) period = int.MaxValue;

                            comma2 = Math.Min(Math.Min(comma2, wspace), period);

                            //find the second command AND need at last one char between second comma and <
                            if ((comma2 > 0) && ((comma2 + 1) < end))
                            {
                                //set the tag recieved event
                                TagEvent t = new TagEvent();

                                //split the tag and cleanup any whitespace
                                t.ModuleName = instr.Substring(start + 1, comma - (start + 1)).TrimEnd(); //module name
                                t.Name = instr.Substring(comma + 1, comma2 - (comma + 1)).TrimEnd(); //tag name
                                t.Data = instr.Substring(comma2 + 1, end - (comma2 + 1)).TrimEnd(); //data

                                //see if there is a number in the data
                                if (t.Data.StartsWith("0x", StringComparison.CurrentCultureIgnoreCase))
                                {
                                    string valstr = t.Data.Substring(2);
                                    UInt16 val;

                                    //Hex numbers are considered unsigned
                                    if(UInt16.TryParse(valstr, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
                                    {
                                        t.Value = val;
                                        t.ValueValid = true;
                                    }
                                }
                                else
                                {
                                    if (int.TryParse(t.Data, out d))
                                    {
                                        t.Value = d;
                                        t.ValueValid = true;

                                    }
                                }

                                //Trace.WriteLine("Module, " + t.ModuleName + ", ");
                                //Trace.WriteLine("Name, " + t.Name + ", ");
                                //Trace.WriteLine("Data, " + t.Data + "\n");

                                //send the tag to all regestered handelers
                                if (null != TagEvents)
                                    TagEvents.Invoke(t);

                            }
                            else
                            {
                                if (null != TagErrorEvent)
                                    TagErrorEvent(instr.Substring(offset));
                            }
                        }
                        else
                        {
                            //Trace.WriteLine("error1, " + instr.Substring(offset) + "\n");

                            if (null != TagErrorEvent)
                                TagErrorEvent(instr.Substring(offset));
                        }
                    }
                    else
                    {
                        Trace.WriteLine("error2, " + instr.Substring(offset) + "\n");

                        if (null != TagErrorEvent)
                            TagErrorEvent(instr.Substring(offset));
                    }
                }
                catch (Exception ex)
                {
                    //Trace.WriteLine("tag formatting, " + ex.Message + "\n");
                    if (null != TagErrorEvent)
                        TagErrorEvent("tag format, " + ex.Message);
                }
            }

            return end;
        }
Exemplo n.º 15
0
 //Update the chart
 void ITagInterface.UpdateEvent(TagEvent e)
 {
     //Todo; Suport multiple chart areas
     if ((Module == null) || (Module == e.ModuleName))
     {
         this.BeginInvoke(new InvokeDelegate(TagInvoke), e);
     }
 }
Exemplo n.º 16
0
        //find the next tag and data, set an event to all listeners
        private int ParseTags(string instr, int offset)
        {
            int start;
            int end = instr.Length;
            int comma;
            int comma2;
            int d;

            try
            {
                //Tag format is >string,string,string<
                start = instr.IndexOf(">", offset);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("serialx, " + ex.Message + "\n");
                Type ep = ex.GetType();
                return(end);
            }

            //how to determine we missed a '>'
            if (start >= 0)//May be first character
            {
                try
                {
                    end = instr.IndexOf("<", start + 1);

                    if (end > start + 5)//>a,b,c< absolute minimum valid tag
                    {
                        //found start and end, find the comma
                        comma = instr.IndexOf(",", start + 1);

                        if (comma > 0)
                        {
                            //find the second comma
                            comma2 = instr.IndexOf(",", comma + 1);
                            if (comma2 < 0)
                            {
                                comma2 = int.MaxValue;
                            }

                            int wspace = instr.IndexOf(" ", comma + 1);
                            if (wspace < 0)
                            {
                                wspace = int.MaxValue;
                            }

                            int period = instr.IndexOf(".", comma + 1);
                            if (period < 0)
                            {
                                period = int.MaxValue;
                            }

                            comma2 = Math.Min(Math.Min(comma2, wspace), period);

                            //find the second command AND need at last one char between second comma and <
                            if ((comma2 > 0) && ((comma2 + 1) < end))
                            {
                                //set the tag recieved event
                                TagEvent t = new TagEvent();

                                //split the tag and cleanup any whitespace
                                t.ModuleName = instr.Substring(start + 1, comma - (start + 1)).TrimEnd();  //module name
                                t.Name       = instr.Substring(comma + 1, comma2 - (comma + 1)).TrimEnd(); //tag name
                                t.Data       = instr.Substring(comma2 + 1, end - (comma2 + 1)).TrimEnd();  //data

                                //see if there is a number in the data
                                if (t.Data.StartsWith("0x", StringComparison.CurrentCultureIgnoreCase))
                                {
                                    string valstr = t.Data.Substring(2);
                                    UInt16 val;

                                    //Hex numbers are considered unsigned
                                    if (UInt16.TryParse(valstr, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
                                    {
                                        t.Value      = val;
                                        t.ValueValid = true;
                                    }
                                }
                                else
                                {
                                    if (int.TryParse(t.Data, out d))
                                    {
                                        t.Value      = d;
                                        t.ValueValid = true;
                                    }
                                }

                                //Trace.WriteLine("Module, " + t.ModuleName + ", ");
                                //Trace.WriteLine("Name, " + t.Name + ", ");
                                //Trace.WriteLine("Data, " + t.Data + "\n");

                                //send the tag to all regestered handelers
                                if (null != TagEvents)
                                {
                                    TagEvents.Invoke(t);
                                }
                            }
                            else
                            {
                                if (null != TagErrorEvent)
                                {
                                    TagErrorEvent(instr.Substring(offset));
                                }
                            }
                        }
                        else
                        {
                            //Trace.WriteLine("error1, " + instr.Substring(offset) + "\n");

                            if (null != TagErrorEvent)
                            {
                                TagErrorEvent(instr.Substring(offset));
                            }
                        }
                    }
                    else
                    {
                        Trace.WriteLine("error2, " + instr.Substring(offset) + "\n");

                        if (null != TagErrorEvent)
                        {
                            TagErrorEvent(instr.Substring(offset));
                        }
                    }
                }
                catch (Exception ex)
                {
                    //Trace.WriteLine("tag formatting, " + ex.Message + "\n");
                    if (null != TagErrorEvent)
                    {
                        TagErrorEvent("tag format, " + ex.Message);
                    }
                }
            }

            return(end);
        }
Exemplo n.º 17
0
 /// <summary>
 /// This event gets called when a tag has been recieved
 /// if the name of the tag is the same as the components tag, set the value
 /// </summary>
 /// <param name="f"></param>
 /// <param name="e"></param>
 void ITagInterface.UpdateEvent(TagEvent e)
 {
     if ((Module == null) || (Module == e.ModuleName))
     {
         if (e.Name == Sort)
         {
             this.BeginInvoke(new InvokeDelegate(TagInvoke), e.Value);
         }
     }
 }
Exemplo n.º 18
0
        void ITagInterface.UpdateEvent(TagEvent e)
        {
            bool ckd;

            if ((Module == null) || (Module == e.ModuleName))
            {
                if (e.Name == Sort)
                {
                    try
                    {
                        if (e.Data == base.Text)
                            ckd = true;
                        else
                            ckd = false;

                        this.BeginInvoke(new InvokeDelegate(TagInvoke), ckd);
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine("TagState, " + ex.Message + "\n");
                    }
                }
            }
        }