Esempio n. 1
0
        static void Main(string[] args)
        {
            PubSubCalculatioEngine pubSubCalculatioEngine = new PubSubCalculatioEngine();

            ServiceManager serviceManager = new ServiceManager(PubSubCalculatioEngine.Instance);

            ClientSideCE n = ClientSideCE.Instance;

            n.Connect();

            n.ProxyTM.Enlist("net.tcp://localhost:19516/ITransactionCheck");


            Console.WriteLine("Press enter to send data.");
            Console.ReadLine();

            DataToUI data = new DataToUI();

            data.Data = CalculationEngineCache.Instance.GetAllDerForecastDayAhead();
            PubSubCalculatioEngine.Instance.Notify(data, (int)Enums.Topics.Flexibility);

            Console.WriteLine("Press enter to exit.");

            Console.ReadLine();
        }
Esempio n. 2
0
 private void Login_Load(object sender, EventArgs e)
 {
     Arduino.BaudRate      = 9600;
     Arduino.PortName      = "COM4";
     Arduino.DataReceived += new SerialDataReceivedEventHandler(DataRecHandler);
     Arduino.Open();
     updateFromHandler = new DataToUI(ChangeTextBox);
 }
Esempio n. 3
0
 public AccountSelect(SerialPort s, String n)
 {
     nuid = n;
     Cursor.Hide();
     this.Arduino = s;
     InitializeComponent();
     Arduino.DataReceived += new SerialDataReceivedEventHandler(DataRecHandler);
     updateFromHandler     = new DataToUI(CheckInput);
 }
        public void UpdateFlexibilityFromUIToCE(double valueKW, FlexibilityIncDec incOrDec, long gid)
        {
            // POZOVI METODU ZA RACUNANJE FLEXIBILITY
            DataToUI data = new DataToUI();

            data.Flexibility       = valueKW;
            data.Gid               = gid;
            data.FlexibilityIncDec = incOrDec;
            CalculationEngineCache.Instance.CalculateNewFlexibility(data);
        }
Esempio n. 5
0
 public Menu(SerialPort s, string sa, String n)
 {
     SelectedAcc = sa;
     nuid        = n;
     Cursor.Hide();
     this.Arduino = s;
     InitializeComponent();
     Arduino.DataReceived += new SerialDataReceivedEventHandler(DataRecHandler);
     updateFromHandler     = new DataToUI(CheckInput);
     cn = new MySqlConnection("server=127.0.0.1;uid=root;pwd=Antonio01!;database=lime-bank");
     cn.Open();
 }
Esempio n. 6
0
        public void Notify(DataToUI data, int gidOfTopic)
        {
            if (data == null || subscribers.Count == 0)
            {
                return;
            }

            data.Topic = gidOfTopic;
            Dictionary <string, ServerSideProxy> subscribersCopy;
            List <string> deadClients = new List <string>();

            lock (subscribersLock)
            {
                subscribersCopy = new Dictionary <string, ServerSideProxy>(subscribers);
            }

            List <string> topicSubscribers = topicSubscriptions.GetSubscribers(gidOfTopic);
            List <string> deadSubscribers  = new List <string>();

            foreach (string subscriberAddress in topicSubscribers)
            {
                if (subscribersCopy.ContainsKey(subscriberAddress))
                {
                    ServerSideProxy subscriber = subscribersCopy[subscriberAddress];

                    try
                    {
                        subscriber.Proxy.SendScadaDataToUI(data);
                    }
                    catch (CommunicationException)
                    {
                        subscriber.Abort();
                        subscriber.Connect();
                    }
                    catch (TimeoutException)
                    {
                        subscriber.Abort();
                        subscriber.Connect();
                    }
                }
                else
                {
                    deadSubscribers.Add(subscriberAddress);
                }

                topicSubscriptions.RemoveDeadSubscribers(gidOfTopic, deadSubscribers);
            }

            RemoveDeadClients(deadClients);
        }
 public void SendScadaDataToUI(DataToUI data)
 {
     if (data.Topic.Equals((int)Enums.Topics.DerForecastDayAhead))
     {
         Mediator.NotifyColleagues("DerForecastDayAhead", data);
     }
     else if (data.Topic.Equals((int)Enums.Topics.Flexibility))
     {
         Mediator.NotifyColleagues("Flexibility", data);
     }
     else if (data.Topic.Equals((int)Enums.Topics.NetworkModelTreeClass))
     {
         Mediator.NotifyColleagues("NetworkModelTreeClass", data);
     }
 }
Esempio n. 8
0
        public Withdraw(SerialPort s, string sa, String n, int r)
        {
            rekid       = r;
            nuid        = n;
            SelectedAcc = sa;
            Cursor.Hide();
            this.Arduino = s;
            InitializeComponent();
            Arduino.DataReceived += new SerialDataReceivedEventHandler(DataRecHandler);
            updateFromHandler     = new DataToUI(ChangeTextBox);
            cn = new MySqlConnection("server=127.0.0.1;uid=root;pwd=Antonio01!;database=lime-bank");
            cn.Open();
            MySqlCommand cmd1 = new MySqlCommand("SELECT Balans FROM `lime-bank`.rekening where RekeningType = " + SelectedAcc + " AND PasID = '" + nuid + "';", cn);

            reader1 = cmd1.ExecuteReader();
        }
Esempio n. 9
0
        public void SendInitialDerForecastDayAhead()
        {
            DataToUI data = CalculationEngineCache.Instance.CreateDataForUI();

            data.Topic = (int)Enums.Topics.DerForecastDayAhead;
            try
            {
                Proxy.SendScadaDataToUI(data);
            }
            catch (CommunicationException)
            {
                Abort();
                Connect();
            }
            catch (TimeoutException)
            {
                Abort();
                Connect();
            }
        }
Esempio n. 10
0
        public Balance(SerialPort s, string sa, String n)
        {
            SelectedAcc = sa;
            nuid        = n;
            //Cursor.Hide();
            this.Arduino = s;
            InitializeComponent();
            Arduino.DataReceived += new SerialDataReceivedEventHandler(DataRecHandler);
            updateFromHandler     = new DataToUI(CheckInput);
            cn = new MySqlConnection("server=127.0.0.1;uid=root;pwd=Antonio01!;database=lime-bank");
            cn.Open();
            MySqlCommand cmd = new MySqlCommand("SELECT Balans FROM `lime-bank`.rekening where RekeningType = " + SelectedAcc + " AND PasID = '" + nuid + "';", cn);

            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Object obj = new Object();
                obj = reader.GetString(0);
                string a = (string)obj;
                label5.Text = "€ " + a;
                return;
            }
        }