Пример #1
0
        //button on tap
        void btn_TapEvent(object sender)
        {
            Bitmap bmp = new Bitmap(Resources.GetBytes(Resources.BinaryResources.setan), Bitmap.BitmapImageType.Jpeg);

            img.Visible = true;
            img.Bitmap  = bmp;

            img.Invalidate();
            Thread.Sleep(2000);
            img.Visible = false;
            img.Invalidate();
            window.Invalidate();
        }
Пример #2
0
 void SendData()
 {
     //loop forever
     for (; ;)
     {
         if (pulseOximeter.IsProbeAttached)
         {
             //get data from oximeter
             var RefreshedSensor = new DataSensor()
             {
                 SPO2 = pulseOximeter.LastReading.SPO2, PulseRate = pulseOximeter.LastReading.PulseRate, SignalStrength = pulseOximeter.LastReading.SignalStrength, Tanggal = DateTime.Now
             };
             string data = Json.NETMF.JsonSerializer.SerializeObject(RefreshedSensor);
             byte[] b    = Encoding.UTF8.GetBytes(data);
             string hex  = "radio tx " + ToHexString(b, 0, b.Length); // TX payload needs to be HEX
             //send data via lora
             _loraSerial.WriteLine(hex);
             txtLora.Text      = "Lora Status : OK";
             txtStatus.Text    = "Sending data : " + RefreshedSensor.Tanggal.ToString("dd MMM yy HH:mm:ss");
             txtSPO2.Text      = "SPO2 : " + RefreshedSensor.SPO2;
             txtSignal.Text    = "Signal : " + RefreshedSensor.SignalStrength;
             txtPulseRate.Text = "Pulse Rate : " + RefreshedSensor.PulseRate;
             //refresh
             window.Invalidate();
             txtLora.Invalidate();
             txtStatus.Invalidate();
             txtSPO2.Invalidate();
             txtSignal.Invalidate();
             txtPulseRate.Invalidate();
             Thread.Sleep(2000);
         }
     }
 }
Пример #3
0
        /*apre pagina per il pagamento*/
        private void _payBtn_TapEvent(object sender)
        {
            /*load pagamento*/
            _pagamento       = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Pagamento));
            Glide.MainWindow = _pagamento;

            _paypal = (GHI.Glide.UI.TextBlock)_ordina.GetChildByName("paypal");
            _pagamento.Invalidate();
        }
Пример #4
0
        /*Populate Grid function*/
        void Populate()
        {
            Debug.Print("Populating...");

            /*populating iniziale*/
            for (int i = 0; i < al.Count; i++)
            {
                Hashtable ht = al[i] as Hashtable;
                _dataGrid.AddItem(new DataGridItem(new object[4] {
                    ht["id"], ht["name"], ht["price"], qnt
                }));
            }
            _dataGrid.Invalidate();

            /*se l'utente deve modificare l'ordine'*/
            if (flagmdf == 1)
            {
                _pCounter.Text   = price.ToString();
                _qntCounter.Text = qnt.ToString();
                int qnt_appoggio = qnt;

                _dataGrid.Clear();
                _menu.Invalidate();
                _dataGrid.Invalidate();

                for (int i = 0; i < al.Count; i++)
                {
                    Hashtable ht = al[i] as Hashtable;
                    qnt = 0;
                    foreach (Product p in payment)
                    {
                        if (p.id == Double.Parse(ht["id"].ToString()))
                        {
                            qnt = p.quantita;
                        }
                    }
                    _dataGrid.AddItem(new DataGridItem(new object[4] {
                        ht["id"], ht["name"], ht["price"], qnt
                    }));
                }
                _dataGrid.Invalidate();
                qnt = qnt_appoggio;
            }
        }
Пример #5
0
        //Submit the result for the row
        public bool submitResult()
        {
            int pinLocation = 0;

            ++round;

            fullyCorrect = 0;
            halfCorrect  = 0;

            int[] places = new int[4] {
                -1, -1, -1, -1
            };
            int[] places2 = new int[4] {
                -1, -1, -1, -1
            };


            //Current selection of the color codes
            int[] currentSelection = new int[4];
            currentSelection[0] = (int)r1.Color;
            currentSelection[1] = (int)r2.Color;
            currentSelection[2] = (int)r3.Color;
            currentSelection[3] = (int)r4.Color;

            ////Check At exact same position
            for (int i = 0; i < solution.Length; i++)
            {
                if (currentSelection[i] == listColors[solution[i]])
                {
                    fullyCorrect++;
                    places[i]  = 1;
                    places2[i] = 1;
                    //TheScore.AddBlackPeg(CurrentRow, pinLocation);
                    pinLocation++;
                }
            }



            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    // make sure the positions aren't the same and the pegs in the different positions
                    // both in the solution and the player row haven't already been determined
                    if ((i != j) && (places[i] != 1) && (places2[j] != 1))
                    {
                        // if the GuessedRow color matches the Grid Color at a different position
                        // We have a white peg
                        if (currentSelection[i] == listColors[solution[j]])
                        {
                            //TheScore.AddWhitePeg(CurrentRow, pinLocation);
                            pinLocation++;
                            places[i]  = 1;
                            places2[j] = 1;
                            halfCorrect++;
                            break;
                        }
                    }
                }
            }

            bool result = populateVisualResult(fullyCorrect, halfCorrect);

            yPostition += 20;

            masterMind.Render();
            masterMind.Invalidate();
            resetOutline();


            //change later
            if (currentGroup < 10)
            {
                currentGroup++;
            }
            else
            {
                currentGroup = 0;
            }

            if (!result)
            {
                startNewRow();
            }


            return(result);
        }
Пример #6
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            //set display
            this.videoOut.SetDisplayConfiguration(VideoOut.Resolution.Vga800x600);
            //set glide
            window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Form1));

            txtTime          = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtTime");
            GvData           = (GHI.Glide.UI.DataGrid)window.GetChildByName("GvData");
            BtnReset         = (GHI.Glide.UI.Button)window.GetChildByName("BtnReset");
            txtMessage       = (GHI.Glide.UI.TextBlock)window.GetChildByName("TxtMessage");
            Glide.MainWindow = window;

            //setup grid
            //create grid column
            GvData.AddColumn(new DataGridColumn("Time", 200));
            GvData.AddColumn(new DataGridColumn("Temp", 200));
            GvData.AddColumn(new DataGridColumn("Humid", 200));
            GvData.AddColumn(new DataGridColumn("Light", 200));
            GvData.AddColumn(new DataGridColumn("Gas", 200));


            // Create a database in memory,
            // file system is possible however!
            myDatabase = new GHI.SQLite.Database();
            myDatabase.ExecuteNonQuery("CREATE Table Sensor" +
                                       " (Time TEXT, Temp DOUBLE,Humid DOUBLE,Light DOUBLE,Gas DOUBLE)");
            //reset database n display
            BtnReset.TapEvent += (object sender) =>
            {
                Counter = 0;
                myDatabase.ExecuteNonQuery("DELETE FROM Sensor");
                GvData.Clear();
                GvData.Invalidate();
            };

            //reset lora
            _restPort.Write(false);
            Thread.Sleep(1000);
            _restPort.Write(true);
            Thread.Sleep(1000);


            _loraSerial = new SimpleSerial(GHI.Pins.FEZSpiderII.Socket11.SerialPortName, 57600);
            _loraSerial.Open();
            _loraSerial.DataReceived += _loraSerial_DataReceived;
            //get version
            _loraSerial.WriteLine("sys get ver");
            Thread.Sleep(1000);
            //pause join
            _loraSerial.WriteLine("mac pause");
            Thread.Sleep(1500);
            //antena power
            _loraSerial.WriteLine("radio set pwr 14");
            Thread.Sleep(1500);
            //set device to receive
            _loraSerial.WriteLine("radio rx 0"); //set module to RX
            txtMessage.Text = "LORA-RN2483 setup has been completed...";
            txtMessage.Invalidate();
            window.Invalidate();
            //myDatabase.Dispose();
        }
Пример #7
0
        void PrintToLCD(string message)
        {
            String[]  origin_names = null;
            ArrayList tabledata    = null;

            //cek message
            if (message != null && message.Length > 0)
            {
                try
                {
                    if (message == "Radio Error")
                    {
                        return;
                    }
                    var        obj    = Json.NETMF.JsonSerializer.DeserializeString(message) as Hashtable;
                    var        detail = obj["Data"] as Hashtable;
                    DeviceData data   = new DeviceData()
                    {
                        DeviceSN = obj["DeviceSN"].ToString()
                    };
                    data.Data = new DataSensor()
                    {
                        Gas = Convert.ToDouble(detail["Gas"].ToString()), Temp = Convert.ToDouble(detail["Temp"].ToString()), Humid = Convert.ToDouble(detail["Humid"].ToString()), Light = Convert.ToDouble(detail["Light"].ToString())
                    };
                    //update display
                    txtTime.Text    = DateTime.Now.ToString("dd/MMM/yyyy HH:mm:ss");
                    txtMessage.Text = "Data Reveiced Successfully.";
                    txtTime.Invalidate();
                    txtMessage.Invalidate();

                    var TimeStr = DateTime.Now.ToString("dd/MM/yy HH:mm");
                    //insert to db
                    var item = new DataGridItem(new object[] { TimeStr, data.Data.Temp, data.Data.Humid, data.Data.Light, data.Data.Gas });
                    //add data to grid
                    GvData.AddItem(item);
                    Counter++;

                    GvData.Invalidate();
                    window.Invalidate();

                    //add rows to table
                    myDatabase.ExecuteNonQuery("INSERT INTO Sensor (Time, Temp,Humid,Light,Gas)" +
                                               " VALUES ('" + TimeStr + "' , " + data.Data.Temp + ", " + data.Data.Humid + ", " + data.Data.Light + ", " + data.Data.Gas + ")");
                    window.Invalidate();
                    if (Counter > 13)
                    {
                        //reset
                        Counter = 0;
                        myDatabase.ExecuteNonQuery("DELETE FROM Sensor");
                        GvData.Clear();
                        GvData.Invalidate();
                    }

                    /*
                     * // Process SQL query and save returned records in SQLiteDataTable
                     * ResultSet result = myDatabase.ExecuteQuery("SELECT * FROM Sensor");
                     * // Get a copy of columns orign names example
                     * origin_names = result.ColumnNames;
                     * // Get a copy of table data example
                     * tabledata = result.Data;
                     * String fields = "Fields: ";
                     * for (int i = 0; i < result.ColumnCount; i++)
                     * {
                     *  fields += result.ColumnNames[i] + " |";
                     * }
                     * Debug.Print(fields);
                     * object obj;
                     * String row = "";
                     * for (int j = 0; j < result.RowCount; j++)
                     * {
                     *  row = j.ToString() + " ";
                     *  for (int i = 0; i < result.ColumnCount; i++)
                     *  {
                     *      obj = result[j, i];
                     *      if (obj == null)
                     *          row += "N/A";
                     *      else
                     *          row += obj.ToString();
                     *      row += " |";
                     *  }
                     *  Debug.Print(row);
                     * }
                     */
                }
                catch (Exception ex)
                {
                    txtMessage.Text = message + "_" + ex.Message + "_" + ex.StackTrace;
                    txtMessage.Invalidate();
                }
            }
        }
Пример #8
0
        /*ordBtn TapEvent*/
        void _ordBtn_PressEvent(object sender)
        {
            var    random       = new Random(System.DateTime.Now.Millisecond);
            uint   randomNumber = (uint)random.Next();
            string id_ordine    = randomNumber.ToString();
            string tot          = price.ToString();


            Hashtable order = new Hashtable();

            order.Add("id", id_ordine);
            order.Add("price", tot);

            // Preparing order array list
            ArrayList foods = new ArrayList();

            foreach (Product p in payment)
            {
                // Preparing food array list
                Hashtable new_food = new Hashtable();
                new_food.Add("name", p.nome);
                new_food.Add("price", p.prezzo);


                Hashtable food = new Hashtable();
                food.Add("food", new_food);
                food.Add("quantity", p.quantita);

                foods.Add(food);
            }

            order.Add("foods", foods);

            string order_as_json = Json.NETMF.JsonSerializer.SerializeObject(order);

            // TODO: MANDARE order_as_json al Desktop tramite Socket
            Debug.Print(order_as_json);

            /*load ordina*/
            _ordina          = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Ordina));
            Glide.MainWindow = _ordina;
            _gridOrdine      = (GHI.Glide.UI.DataGrid)_menu.GetChildByName("gridOrdine");
            _annullaBtn      = (GHI.Glide.UI.Button)_ordina.GetChildByName("annullaBtn");
            _payBtn          = (GHI.Glide.UI.Button)_ordina.GetChildByName("payBtn");
            _mdfBtn          = (GHI.Glide.UI.Button)_ordina.GetChildByName("mdfBtn");
            _pfinal          = (GHI.Glide.UI.TextBlock)_ordina.GetChildByName("pFinal");

            _annullaBtn.TapEvent += _annullaBtn_TapEvent;
            _mdfBtn.TapEvent     += _mdfBtn_TapEvent;
            _payBtn.TapEvent     += _payBtn_TapEvent;

            /*Setup the dataGrid reference*/
            _gridOrdine = (DataGrid)_ordina.GetChildByName("gridOrdine");

            /*Create our four columns*/
            _gridOrdine.AddColumn(new DataGridColumn("PIZZA", 125));
            _gridOrdine.AddColumn(new DataGridColumn("PREZZO", 80));
            _gridOrdine.AddColumn(new DataGridColumn("QNT", 50));

            foreach (Product p in payment)
            {
                _gridOrdine.AddItem(new DataGridItem(new object[3] {
                    p.nome, p.prezzo, p.quantita
                }));
            }

            _pfinal.Text = price.ToString();

            _ordina.Invalidate();
            _gridOrdine.Invalidate();
        }
Пример #9
0
        void initMenu()
        {
            Debug.Print("Init Menu!");

            /*inizio socket*/
            SocketClient.StartClient();
            /*fine socket*/

            /*load menu*/
            _menu            = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Menu));
            Glide.MainWindow = _menu;

            _dataGrid   = (GHI.Glide.UI.DataGrid)_menu.GetChildByName("dataGrid");
            _pCounter   = (GHI.Glide.UI.TextBlock)_menu.GetChildByName("pCounter");
            _qntCounter = (GHI.Glide.UI.TextBlock)_menu.GetChildByName("qntCounter");
            _errMsg     = (GHI.Glide.UI.TextBlock)_menu.GetChildByName("errMsg");

            _ordBtn = (GHI.Glide.UI.Button)_menu.GetChildByName("ordBtn");
            if (flagmdf == 0)
            {
                _ordBtn.Enabled = false;
            }
            else
            {
                _ordBtn.Enabled = true;
            }
            _menu.Invalidate();
            _ordBtn.PressEvent += _ordBtn_PressEvent;

            _deleteBtn = (GHI.Glide.UI.Button)_menu.GetChildByName("deleteBtn");
            if (flagmdf == 0)
            {
                _deleteBtn.Enabled = false;
            }
            else
            {
                _deleteBtn.Enabled = true;
            }
            _menu.Invalidate();
            _deleteBtn.PressEvent += deleteBtn_PressEvent;

            //_ingBtn = (GHI.Glide.UI.Button)_menu.GetChildByName("ingBtn");
            //_ingBtn.Visible = false;
            //_menu.Invalidate();
            //_ingBtn.PressEvent += ingBtn_PressEvent;

            /*Setup the dataGrid reference*/
            _dataGrid = (DataGrid)_menu.GetChildByName("dataGrid");

            // Listen for tap cell events.
            _dataGrid.TapCellEvent += new OnTapCell(dataGrid_TapCellEvent);

            /*Create our four columns*/
            _dataGrid.AddColumn(new DataGridColumn("ID", 0));
            _dataGrid.AddColumn(new DataGridColumn("PIZZA", 125));
            _dataGrid.AddColumn(new DataGridColumn("PREZZO", 80));
            _dataGrid.AddColumn(new DataGridColumn("QNT", 50));

            /*Populate the data grid with random data*/
            Populate();

            /*Add the data grid to the window before rendering it*/
            _menu.AddChild(_dataGrid);
            _dataGrid.Render();

            /*Create a timer & run method timer_trick when thr timer ticks (for joystick)*/
            GT.Timer timer = new GT.Timer(200);
            timer.Tick += Timer_Tick;
            timer.Start();
        }