Click here to Skip to main content
       

C#

 
GeneralRe: When to use & when not to use ( Abstract Class & Interface ) PinmemberShameel8-Mar-13 5:01 
GeneralRe: When to use & when not to use ( Abstract Class & Interface ) PinmemberKrishna Varadharajan8-Mar-13 5:53 
AnswerRe: When to use & when not to use ( Abstract Class & Interface ) Pinmemberjschell8-Mar-13 12:41 
QuestionWhy SqlCommandBuilder Pinmemberkrishnavaradharajan8-Mar-13 1:50 
AnswerRe: Why SqlCommandBuilder PinmvpEddy Vluggen8-Mar-13 3:01 
GeneralRe: Why SqlCommandBuilder Pinmemberkrishnavaradharajan8-Mar-13 3:22 
GeneralRe: Why SqlCommandBuilder PinmvpEddy Vluggen8-Mar-13 4:59 
GeneralRe: Why SqlCommandBuilder PinmemberKrishna Varadharajan8-Mar-13 5:55 
GeneralRe: Why SqlCommandBuilder PinmvpEddy Vluggen8-Mar-13 7:12 
AnswerRe: Why SqlCommandBuilder PinmemberPIEBALDconsult8-Mar-13 3:38 
GeneralRe: Why SqlCommandBuilder Pinmemberkrishnavaradharajan8-Mar-13 3:59 
GeneralRe: Why SqlCommandBuilder PinmemberPIEBALDconsult8-Mar-13 5:42 
GeneralRe: Why SqlCommandBuilder PinmemberKrishna Varadharajan8-Mar-13 5:56 
QuestionWireless Sensor Node Simulation Time in C# PinmemberNico Encarnacion7-Mar-13 14:45 
I am trying to develop a very simple wireless sensor node simulator using C#. I have figured out how to "divide" the simulation time into different "states" of the sensor node but I am currently having some problems on how to properly implement a global simulation time for all the sensor nodes.
 
Here's what I did so far but I am sure there is a much better way to do this.
 
I made a NODE class which contains a Run() method that has a for loop executed to simulate time. But the obvious problem is, if I duplicate this NODE class to make other nodes (5-10 other nodes), there's a tendency that they will not be synchronized (especially when they communicate with each other).
 
public void Run()
{
    //simulation loop
    for (int i = 0; i < 1000; i++ ) //this acts as the basis for the simulation time
    {
        if (sleep)
        {
            if (csleep < timeToSleep)
            {
                Sleep(i);
                csleep++;
            }
            else
            {
                sleep = false;
                csleep = 0;
                wakeup = true;
            }
        }
 
        if (wakeup)
        {
            if (cwakeup < timeToWakeUp)
            {
                WakeUp(i);
                cwakeup++;
            }
            else
            {
                wakeup = false;
                cwakeup = 0;
                listen = true;
            }
        }
 
        if (listen)
        {
            ...same as above code...
        }
 
        if (send)
        {
            ...same as above code...
        }
        if (receive)
        {
            ...same as above code...
        }
    }//end main simulation loop

    Console.WriteLine("END SIMULATION");
}
 
So, when I execute the nodes in the main simulation class, it looks like this:
 
class Program
{
    static void Main(string[] args)
    {
        Node node1 = new Node();
        Node node2 = new Node();
        node1.Run();
        node2.Run();
    }
}
 
The above codes are obviously incorrect since the simulation time is placed inside each node object. What I am trying to do is this:
 
I want to treat all nodes as if they are threads communicating with each other or could sometimes just independently "exist" in the simulation. But how do I make it that all of these nodes could have one single basis for the simulation time?
 
Simulation loop
{
    Node 1 executed; //nodes execute sending, receiving, sleeping, etc
    Node 2 executed; //nodes execute sending, receiving, sleeping, etc
}

AnswerRe: Wireless Sensor Node Simulation Time in C# PinmemberGerry Schmitz7-Mar-13 18:49 
GeneralRe: Wireless Sensor Node Simulation Time in C# PinmemberNico Encarnacion12-Mar-13 20:05 
GeneralRe: Wireless Sensor Node Simulation Time in C# PinmemberGerry Schmitz13-Mar-13 12:10 
QuestionExplicit type-casting of pointer PinmemberFlo_897-Mar-13 11:18 
AnswerRe: Explicit type-casting of pointer PinmemberGerry Schmitz7-Mar-13 12:23 
GeneralRe: Explicit type-casting of pointer PinmemberFlo_897-Mar-13 12:24 
AnswerRe: Explicit type-casting of pointer PinmemberMatt T Heffron7-Mar-13 12:34 
AnswerRe: Explicit type-casting of pointer Pinmemberharold aptroot7-Mar-13 21:57 
QuestionHow to highlight word in word document using C# [modified] PinmemberTridip Bhattacharjee7-Mar-13 3:56 
AnswerRe: How to highlight word in word document using C# PinmvpRichard MacCutchan7-Mar-13 5:13 
GeneralRe: How to highlight word in word document using C# PinmemberTridip Bhattacharjee8-Mar-13 1:46 
GeneralRe: How to highlight word in word document using C# PinmvpRichard MacCutchan8-Mar-13 2:16 
QuestionRe: How to highlight word in word document using C# PinmemberAlan N7-Mar-13 5:17 
AnswerRe: How to highlight word in word document using C# PinmemberTridip Bhattacharjee8-Mar-13 1:47 
GeneralRe: How to highlight word in word document using C# PinmemberAlan N8-Mar-13 3:12 
QuestionC# file access Pinmemberclassy_dog7-Mar-13 1:52 
AnswerRe: C# file access PinmvpDave Kreskowiak7-Mar-13 2:30 
AnswerRe: C# file access PinmemberMatt T Heffron7-Mar-13 8:49 
QuestionHow to use sql server database into oracle PinmemberArun kumar Gautam7-Mar-13 1:04 
AnswerRe: How to use sql server database into oracle PinmemberSimon_Whale7-Mar-13 1:14 
AnswerRe: How to use sql server database into oracle Pinmemberjschell7-Mar-13 8:34 
AnswerRe: How to use sql server database into oracle PinmemberGerry Schmitz7-Mar-13 19:38 
QuestionRetrieve Mongodb Images using GridFS C# Winforms PinmemberArunRajendran16-Mar-13 19:38 
AnswerRe: Retrieve Mongodb Images using GridFS C# Winforms PinmvpEddy Vluggen6-Mar-13 22:48 
QuestionC# in vb.net in windows base application PinmemberJinal Mistry6-Mar-13 19:30 
AnswerRe: C# in vb.net in windows base application PinmvpRichard MacCutchan6-Mar-13 22:30 
QuestionMonitoring Applications and Processes Pinmembermphill47446-Mar-13 10:37 
AnswerRe: Monitoring Applications and Processes PinmemberJim Meadors6-Mar-13 19:49 
AnswerRe: Monitoring Applications and Processes PinmemberBernhard Hiller6-Mar-13 23:24 
GeneralRe: Monitoring Applications and Processes Pinmembermphill47447-Mar-13 5:25 
AnswerRe: Monitoring Applications and Processes Pinmemberjschell7-Mar-13 8:40 
Questionc# file directory structure change Pinmemberclassy_dog6-Mar-13 10:19 
AnswerRe: c# file directory structure change PinmemberMatt T Heffron6-Mar-13 12:42 
GeneralRe: c# file directory structure change Pinmemberclassy_dog6-Mar-13 18:50 
GeneralRe: c# file directory structure change PinmemberMatt T Heffron7-Mar-13 8:29 
AnswerRe: c# file directory structure change PinmemberJegan Thiyagesan6-Mar-13 13:03 

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

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


Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 12 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid