Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I tried searching for an answer but cannot find anything relevant. If this question has been answered in the past, please point me to the right direction.

I am currently working on a small BMS (Building Management System) project. I have a Windows Forms application (C#, .NET) that communicates with a main hardware device via USB, which in turn reads/changes states of diverse other hardware devices. The UI shows different animated SWFs, one for each device that is being interrogated, and allows the users to see the states of the devices, and also to start/stop/change the state where required.

What I am after is a way to allow the user to do some kind of programming of the devices dynamically. In other words, the user should be able to create logic like below:

C#
If (device1.Temperature > threshold)
{
    Stop(Device1);
    Start(Device3);
    Device3.Speed = 10;
}

Or
C#
If (DateTime.Now >= someStartTime && Device2.IsStopped)
{
     Start(Device2);
}


The above are just examples to provide an idea on what I want to achieve. Practically they need to be able to do stuff like:

HTML
- Start some device at specific hour/day (for example start the heading system in the morning, stop it in the afternoon)
- Do some actions (start/stop/change state of different devices) if specific thresholds are being reached (for example if the temperature in a specific room is above 25 degrees Celcius, start Fan no 1 and 2 )
- Send alerts if different thresholds are being reached (for example when the smoke detector started)


I don't want this to be too complicated, but needs to be 100% reliable. Any help/ideas will be much appreciated.

Thanks in advance,
Mihai
Posted

1 solution

"I don't want this to be too complicated, but needs to be 100% reliable."

That's hard request to fulfill. :)

I think you have good start with what you have so far with the if then else ladder structure. The hardest part of most of the forms application I do is not the functional part but the UI, what the user sees and how they interact with it. From what I understand ladder programming in C# is not the easiest thing to do, example[^].

I would start out by creating classes that represent the devices you wish to control with something like the class below that provides an interface container for the logical functions you wish to control.
C#
public class BlowerType
{
    public bool on;
    public DateTime StratTime;
    public DateTime EndTIme;
    public Int16 spped;
    public Int16 Temperature;
}


Then I would create an instance for each device and dynamically populate a form with the available interfaces where the user can select or add a device and set it's attributes. As far as how to transfer these functions to the code you already have, I couldn't tell you.

Good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900