Click here to Skip to main content
15,912,977 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie21-Nov-11 22:53
CCodeNewbie21-Nov-11 22:53 
QuestionDeploying C# Application with Crystal report Pin
akosidandan19-Nov-11 23:51
akosidandan19-Nov-11 23:51 
AnswerRe: Deploying C# Application with Crystal report Pin
akosidandan20-Nov-11 1:39
akosidandan20-Nov-11 1:39 
AnswerRe: Deploying C# Application with Crystal report Pin
thatraja20-Nov-11 2:56
professionalthatraja20-Nov-11 2:56 
Questiondata presentation Pin
Tom Paronis19-Nov-11 10:14
Tom Paronis19-Nov-11 10:14 
AnswerRe: data presentation Pin
PIEBALDconsult20-Nov-11 2:55
mvePIEBALDconsult20-Nov-11 2:55 
QuestionSQL Compact v3.5 ComboBox Not Populating from Query Pin
namelkcip19-Nov-11 8:16
namelkcip19-Nov-11 8:16 
QuestionSOS Something strange with memory Pin
Member 807559118-Nov-11 21:48
Member 807559118-Nov-11 21:48 
I’m writing one program (C# .Net 3.5) for temperature values reception from some device through COM port. The program (for convenient postprocessing of temperature values) divides received data on (figure 1):
MEASURE – continuous sequence of temperature values.
SET – consecutive set of several MEASUREs. Each SET is separated from another SET by a certain interval of time. For example, 15 minutes. After this time limit the program closes current SET and opens a new SET.
DAY – set of SETs received during a day.
The program seems to work as it supposed. But sometimes there is an overlapping of MEASUREs of different SETs of a DAY. For example, a MEASURE of one SET could be an absolute copy of a MEASURE of some another following SET (figure 2). Or any SET besides of its own MEASUREs can contain all MEASUREs of all following SETs. As a result some SET has MEASURE(s) which do not belong to it.
I have an idea that List M (see the code) of a SET sometimes during a day can refer on itself and on List M of the previous SET. It is incredible, because only one (current) SET and its (current) MEASURE could be active; the rest should be closed and not active.
What is wrong? What recommendations you will advise to reveal this bug?

figure 1

figure 2


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;

namespace WindowsFormsApplication1
{
    class MyPoint
    {
        public double x;
        public double y;
    }
    class Measurement
    {
        List<MyPoint> points = new List<MyPoint>();
        public void Add(MyPoint p)
        {
            points.Add(p);
        }
    }
    class Set
    {
        public Measurement CurrentM = null;
        List<Measurement> M = new List<Measurement>();
        public Measurement GetNewM()
        {
            Measurement m = new Measurement();
            /*
             * m.Field1 = ...;
             * m.Field2 = ...;
             * ...
             * m.FieldN = ...;
             */
            return m;

        }
        public void CreateMesurement()
        {
            CurrentM = GetNewM();
            M.Add(CurrentM);
        }
    }
    class Day
    {
        public Set CurrentS = null;
        List<Set> S = new List<Set>();
        public void OnSetCreation()
        {
            CurrentS = new Set();
            S.Add(CurrentS);
        }
        public void OnMeasureCreation()
        {
            CurrentS.CreateMesurement();
        }
        public void WriteData()
        {
            // saving all data to disk
        }
    }
    static class DaysConteiner
    {
        static public Day Active;

        static double Temperature;
        static bool IfThereIsAGapBetweenTempuratureValues = false;
        static bool IfThereIsSetTimeLimitElapsed = false;
        static bool IfNewDay = false;

        static void OnStartNewDay()
        {
            if (IfNewDay)
            {
                Active.WriteData();
                Active = new Day();
            }
        }
        static internal void OnDataFromCOMPortReceived()
        {
            /*
             * data processing
             * Temperature = ...;
             * IfThereIsAGapBetweenTempuratureValues = ...;
             * IfThereIsSetTimeLimitElapsed = ...;
             */


            /*
             * Sending data to Form by means of Invoke and so on
             */
            if (IfThereIsSetTimeLimitElapsed) Active.OnSetCreation();
            if (IfThereIsAGapBetweenTempuratureValues) Active.OnMeasureCreation();
            
            MyPoint p = new MyPoint();
            p.x = DateTime.Now.ToOADate();
            p.y = Temperature;
            Active.CurrentS.CurrentM.Add(p); 
            /* */
        }

    }
}

AnswerRe: SOS Something strange with memory Pin
OriginalGriff18-Nov-11 22:01
mveOriginalGriff18-Nov-11 22:01 
GeneralRe: SOS Something strange with memory Pin
Member 807559119-Nov-11 0:09
Member 807559119-Nov-11 0:09 
AnswerRe: SOS Something strange with memory Pin
Luc Pattyn19-Nov-11 7:28
sitebuilderLuc Pattyn19-Nov-11 7:28 
GeneralRe: SOS Something strange with memory Pin
Member 807559119-Nov-11 20:52
Member 807559119-Nov-11 20:52 
QuestionC# class that makes program read SqlConnection string from xml file Pin
Framework .l.18-Nov-11 17:36
Framework .l.18-Nov-11 17:36 
AnswerRe: C# class that makes program read SqlConnection string from xml file Pin
Wayne Gaylard18-Nov-11 19:31
professionalWayne Gaylard18-Nov-11 19:31 
GeneralRe: C# class that makes program read SqlConnection string from xml file Pin
Framework .l.18-Nov-11 19:46
Framework .l.18-Nov-11 19:46 
GeneralRe: C# class that makes program read SqlConnection string from xml file Pin
Wayne Gaylard18-Nov-11 19:51
professionalWayne Gaylard18-Nov-11 19:51 
GeneralRe: C# class that makes program read SqlConnection string from xml file Pin
Framework .l.18-Nov-11 19:55
Framework .l.18-Nov-11 19:55 
GeneralRe: C# class that makes program read SqlConnection string from xml file Pin
Wayne Gaylard18-Nov-11 20:00
professionalWayne Gaylard18-Nov-11 20:00 
AnswerRe: C# class that makes program read SqlConnection string from xml file Pin
OriginalGriff18-Nov-11 20:38
mveOriginalGriff18-Nov-11 20:38 
GeneralRe: C# class that makes program read SqlConnection string from xml file Pin
Wayne Gaylard18-Nov-11 20:57
professionalWayne Gaylard18-Nov-11 20:57 
GeneralRe: C# class that makes program read SqlConnection string from xml file Pin
OriginalGriff18-Nov-11 21:36
mveOriginalGriff18-Nov-11 21:36 
GeneralRe: C# class that makes program read SqlConnection string from xml file Pin
Wayne Gaylard18-Nov-11 21:44
professionalWayne Gaylard18-Nov-11 21:44 
QuestionAccessing a dynamically created drop down list Pin
Jon Myers18-Nov-11 9:21
Jon Myers18-Nov-11 9:21 
AnswerRe: Accessing a dynamically created drop down list Pin
Dan Mos19-Nov-11 8:05
Dan Mos19-Nov-11 8:05 
GeneralRe: Accessing a dynamically created drop down list Pin
Jon Myers19-Nov-11 10:21
Jon Myers19-Nov-11 10:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.