Exemple #1
0
 public override bool InsertTrip(UserNodeCore context, Communication.Trip trip)
 {
     Command command = new InsertTripCommand(trip);
     context.ServiceProxy.HandleDarPoolingRequest(command);
     // This command does not change state
     return true;
 }
        void serial_AllConfigCommunicationReceived(Communication.Frames.Configuration.AllConfig config)
        {
            updating_gui = true;

            this.config = config;

            MethodInvoker m = delegate()
            {
                _cbInvert1.Checked = config.servo_reverse[0];
                _cbInvert2.Checked = config.servo_reverse[1];
                _cbInvert3.Checked = config.servo_reverse[2];
                _cbInvert4.Checked = config.servo_reverse[3];

                _lblInterpretation1.Text = "";
                _lblInterpretation2.Text = "";
                _lblInterpretation3.Text = "";
                _lblInterpretation4.Text = "";

                ComboBox[] cbn = { _cbInputFunction1, _cbInputFunction2, _cbInputFunction3, _cbInputFunction4 };
                cbn[0].SelectedIndex = 4;
                cbn[1].SelectedIndex = 4;
                cbn[2].SelectedIndex = 4;
                cbn[3].SelectedIndex = 4;

                if (config.channel_ap <= cbn.Length && config.channel_ap > 0)
                    cbn[config.channel_ap - 1].SelectedIndex = 3;
                if (config.channel_motor <= cbn.Length && config.channel_motor > 0)
                    cbn[config.channel_motor - 1].SelectedIndex = 2;
                if (config.channel_pitch <= cbn.Length && config.channel_pitch > 0)
                    cbn[config.channel_pitch - 1].SelectedIndex = 0;
                if (config.channel_roll <= cbn.Length && config.channel_roll > 0)
                    cbn[config.channel_roll - 1].SelectedIndex = 1;
                //if (config.channel_yaw <= cbn.Length && config.channel_yaw > 0)
                //    cbn[config.channel_yaw - 1].SelectedIndex = 2;

                if (config.control_mixing < _cbMixing.Items.Count)
                    _cbMixing.SelectedIndex = Math.Max(0, Math.Min(10, config.control_mixing));

                _hsPitchSensitivity.Value = Math.Max(0, (int)(config.pid_pitch2elevator_p * 10.0));
                _hsRollSensitivity.Value = Math.Max(0, (int)(config.pid_roll2aileron_p * 10.0));

                _cbAutothrottle.Checked = config.auto_throttle_enabled;
                _hsbCruiseThrottle.Value = Math.Max(0, config.auto_throttle_cruise_pct);
                _hsbCruiseThrottle_Scroll(null, new ScrollEventArgs(ScrollEventType.EndScroll, _hsbCruiseThrottle.Value));

                updating_gui = false;
            };

            try
            {
                BeginInvoke(m);
            }
            catch
            {
                ;
            } 
        }
Exemple #3
0
        //muss statt void die AAI-Kompnente zurückgeben
        public static IHESFassade BuildComponents(ISessionFactory sessionFactory)
        {
            ICommunication      communication               = new Communication.Communication();
            IProduktMgmt        produktKomponente           = new ProduktFassade(sessionFactory);
            IProduktDetails     produktDetailsKomponente    = new ProduktFassade(sessionFactory);
            INachbestellungMgmt nachbestellungsKomponente   = new NachbestellungsFassade(sessionFactory, produktKomponente);
            ILagerLogMgmt       lagerLogKompomente          = new LagerLogFassade(sessionFactory);
            IWaWiFassade        waWiVerwaltungsKomponente   = new WaWiVerwaltungFassade(produktKomponente, lagerLogKompomente, nachbestellungsKomponente);
            IRechnungMgmt       rechnungsKomponente         = new RechnungFassade(sessionFactory);
            IAuslieferungsMgmt  auslieferungsKomponente     = new AuslieferungsFassade(sessionFactory);
            IKundenMgmt         kundenKomponente            = new KundenFassade(sessionFactory);
            IAuftragMgmt        auftragabwicklungKomponente = new AuftragabwicklungFassade(sessionFactory, waWiVerwaltungsKomponente);
            IHESFassade         hESFassade = new HESFassade(kundenKomponente, auftragabwicklungKomponente, produktDetailsKomponente, rechnungsKomponente);

            return(hESFassade);
        }
        void serial_AllConfigCommunicationReceived(Communication.Frames.Configuration.AllConfig config)
        {
            MethodInvoker m = delegate()
            {
                timer.Stop();
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            };

            try
            {
                BeginInvoke(m);
            }
            catch
            {
                ;
            }
        }
Exemple #5
0
 void serial_ControlInfoCommunicationReceived(Communication.Frames.Incoming.ControlInfo ci)
 {
     this.ci = ci;
 }
Exemple #6
0
 void serial_AttitudeCommunicationReceived(Communication.Frames.Incoming.Attitude attitude)
 {
     if (aI3D != null)
     {
         aI3D.Roll = attitude.RollDeg / 180.0 * Math.PI;
         aI3D.Pitch = attitude.PitchDeg / 180.0 * Math.PI;
     }
     artificialHorizon1.pitch_angle = attitude.PitchDeg;
     artificialHorizon1.roll_angle = -attitude.RollDeg;
 }
Exemple #7
0
 void serial_AttitudeCommunicationReceived(Communication.Frames.Incoming.Attitude attitude)
 {
     roll = (float)attitude.RollDeg;
     pitch = (float)attitude.PitchDeg;
     yaw = -(float)attitude.YawDeg;
 }
Exemple #8
0
 void serial_PressureTempCommunicationReceived(Communication.Frames.Incoming.PressureTemp info)
 {
     /*if (!is_started)
     {
         start_pressure_height_m = info.Height;
         is_started = true;
     }
     pressure_height_m = info.Height - start_pressure_height_m;*/
 }
Exemple #9
0
 void serial_GpsBasicCommunicationReceived(Communication.Frames.Incoming.GpsBasic gpsbasic)
 {
     longitude = gpsbasic.Longitude / 3.14159 * 180.0;
     latitude = gpsbasic.Latitude / 3.14159 * 180.0;
     heading = gpsbasic.Heading_deg;
     height = gpsbasic.Height_m;
 }
Exemple #10
0
        void _serial_AllConfigCommunicationReceived(Communication.Frames.Configuration.AllConfig config)
        {
            MethodInvoker m = delegate()
                {
                    is_updating = true;

                    UncheckAll();
                    if ((config.osd_bitmask & 4) != 0)
                        Check("horizon");
                    if ((config.osd_bitmask & 8192) != 0)
                        Check("Voltage battery 1");
                    if ((config.osd_bitmask & 16384) != 0)
                        Check("Voltage battery 2");
                    if ((config.osd_bitmask & 16) != 0)
                        Check("Current battery 1");
                    if ((config.osd_bitmask & 256) != 0)
                        Check("mAh");
                    if ((config.osd_bitmask & 512) != 0)
                        Check("Autopilot mode");
                    if ((config.osd_bitmask & 128) != 0)
                        Check("GPS");
                    if ((config.osd_bitmask & 2) != 0)
                        Check("Home arrow");
                    if ((config.osd_bitmask & 32) != 0)
                        Check("Distance");
                    if ((config.osd_bitmask & 1024) != 0)
                        Check("RC-receiver");
                    if ((config.osd_bitmask & 32) != 0)
                        Check("Distance to home");
                    if ((config.osd_bitmask & 4096) != 0)
                        Check("Vario");
                    if ((config.osd_bitmask & 64) != 0)
                        Check("time");
                    if ((config.osd_bitmask & 2048) != 0)
                        Check("Speed");
                    if ((config.osd_bitmask & 1) != 0)
                        Check("Altitude");
                    if ((config.osd_bitmask & 32768) != 0)
                        Check("block name");

                    last_bitmask = config.osd_bitmask;

                    try
                    {
                        _nud_rssi_low.Value = (decimal)config.osd_voltage_low;
                        _nud_rssi_high.Value = (decimal)config.osd_voltage_high;
                    }
                    catch (Exception ex)
                    {
                    }

                    if (config.osd_RssiMode >= 0 && config.osd_RssiMode < _cbRssi.Items.Count)
                        _cbRssi.SelectedIndex = config.osd_RssiMode;

                    is_updating = false;
                };

            try
            {
                BeginInvoke(m);
            }
            catch
            {
            }
        }
 void serial_AttitudeCommunicationReceived(Communication.Frames.Incoming.Attitude attitude)
 {
     //throw new NotImplementedException();
 }
Exemple #12
0
        public void walkToObject(Communication.Point obj, Communication.Point nao, bool fudge1)
        {
            Communication.Point p = new Communication.Point();
            p.X = obj.X - nao.X;
            p.Y = obj.Y - nao.Y;
            p.Z = checkAngle(nao.Z);
            if (Math.Abs(p.Z) > PI / 2)
            {
                Console.WriteLine("Facing Kinect");
            }

            rotate(p);

            double newZ = Math.Atan2(p.Y, p.X);
            if (newZ > PI)
                newZ = PI;
            else if (newZ < -1 * PI)
                newZ = -1 * PI;
            p.X = Math.Round(p.X, 2);
            p.Y = Math.Round(p.Y, 2);
            newZ = Math.Round(newZ, 2);
            Console.WriteLine("Object: ({0}, {1}, {2}),\nNao: ({3}, {4}, {5}),\nNew Loc: ({6}, {7}, {8}) @{9}",
                obj.X, obj.Y, obj.Z, nao.X, nao.Y, nao.Z, p.X, p.Y, p.Z, newZ);
            fudge(p, fudge1);
            Console.WriteLine("Fudged: ({0}, {1}, {2})", p.X, p.Y, p.Z);
            proxy.post.walkTo((float)p.X, (float)p.Y, (float)newZ);

            prevAng = (float)newZ + (float)p.Z;
            if (prevAng > PI)
                prevAng = prevAng - 2 * PI;
            else if (prevAng < -1 * PI)
                prevAng = prevAng + 2 * PI;
            Console.WriteLine("PPPPPPPPPPPPPPPPPPPPredicted Angle: " + prevAng);
        }
Exemple #13
0
        // tranform the position of the object wrt to Nao's facing direction
        private void rotate(Communication.Point p)
        {
            float x = (float)p.X;
            float y = (float)p.Y;
            float rad = (float)p.Z;

            p.X = (float)(x * Math.Cos(rad) + y * Math.Sin(rad));
            p.Y = (float)(-x * Math.Sin(rad) + y * Math.Cos(rad));
        }
Exemple #14
0
 private void fudge(Communication.Point delta, bool fudge1)
 {
     double theta = Math.Atan2(delta.Y, delta.X);
     double hyp = Math.Sqrt(Math.Pow(delta.X, 2) + Math.Pow(delta.Y, 2)) - (fudge1 ? FUDGE_1 : FUDGE_2);
     delta.X = hyp * Math.Cos(theta);
     delta.Y = hyp * Math.Sign(theta);
     Console.WriteLine("Theta: " + theta);
 }
        private void boxTasker()
        {
            Console.WriteLine("BoxTasker started");
            Communication.Communication boxCommunication = new Communication.Communication();

            Console.WriteLine("Waiting for connection to box");
            Socket boks = boxCommunication.openConnection(boxPORT);

            while (true)
            {
                Socket boks_connected = boxCommunication.waitForClient(boks);
                //boks_connected.SendTimeout = 1000;
                //boks_connected.reciveTimeout = 5000;
                Console.WriteLine("BOX Connected");

                try {
                    int    timeRemember = 0;
                    int    timeNow      = 0;
                    string boxState     = "0";
                    int    tjekCounter  = 0;
                    bool   firstStart   = true;


                    timeRemember = timeNow;

                    while (boks_connected.Connected)
                    {
                        byte[]   buf     = new byte[BUFSIZE];
                        string   menuBox = "0";
                        DateTime time    = DateTime.Now;
                        timeNow = time.Second;


                        if (boks_connected.Available > 0)
                        {
                            buf          = boxCommunication.recive(boks_connected);
                            menuBox      = boxCommunication.decodeMessageString(buf);
                            timeRemember = timeNow;
                            Console.WriteLine("menuBox = {0}", menuBox);
                        }
                        //else if (timeRemember + 5 == timeNow )
                        //{
                        //                      Console.WriteLine("Time: {0} ", timeNow);
                        //                      Console.WriteLine("States: {0} , {1} , {2}", stades[0], stades[1], stades[2]);
                        //                      //menuBox = "2";
                        //                      timeRemember = timeNow;
                        //}
                        //else if (5 > timeNow )
                        //{
                        //                      timeRemember = 5;
                        //}
                        //else if(firstStart == true)
                        //{
                        //	//menuBox = "2";
                        //	firstStart = false;
                        //}

                        switch (menuBox.Substring(0, Math.Min(1, menuBox.Length)))
                        {                         //Menu for the box
                        case "1":                 //login/unlock
                            Console.WriteLine("Getting table data");
                            buf = boxCommunication.convertMessageString("1");
                            boxCommunication.transmit(boks_connected, buf);
                            System.Threading.Thread.Sleep(500);
                            buf = boxCommunication.receive(boks_connected);
                            string id = boxCommunication.decodeMessageString(buf);
                            boxCommunication.transmit(boks_connected, buf);
                            System.Threading.Thread.Sleep(500);
                            Console.WriteLine("ID: {0}", id);
                            buf = boxCommunication.receive(boks_connected);
                            string state = boxCommunication.decodeMessageString(buf);
                            Console.WriteLine("State: {0}", state);

                            if (addr[0] == id)
                            {
                                stades[0] = state;
                            }
                            else if (addr[1] == id)
                            {
                                stades[1] = state;
                            }
                            else if (addr[2] == state)
                            {
                                stades[2] = state;
                            }
                            break;


                        case "2":                         //Ping
                            Console.WriteLine("Asking for table data");
                            buf = boxCommunication.convertMessageString("1");
                            //boxCommunication.transmit(boks_connected, buf);
                            System.Threading.Thread.Sleep(100);
                            break;
                        }
                    }
                }
                catch
                {
                    Console.Write("Boks lost connection");
                    boxCommunication.closeConnection(boks_connected);
                }
            }
        }
Exemple #16
0
        void serial_RcInputCommunicationReceived(Communication.Frames.Incoming.RcInput rcinput)
        {
            if (config != null)
            {
                MethodInvoker m = delegate()
                {
                    ProgressBar[] pbs = { _pbChannel1, _pbChannel2, _pbChannel3, _pbChannel4, _pbChannel5, _pbChannel6 };
                    for (int i = 0; i < 6; i++)
                    {
                        if (rcinput.GetPwm(i + 1) > 900 && rcinput.GetPwm(i + 1) < 2100)
                            pbs[i].Value = rcinput.GetPwm(i + 1) - 900;
                        else
                            pbs[i].Value = 0;
                    }

                    Label[] channel_labels = {_lblInterpretation1, _lblInterpretation2, _lblInterpretation3, _lblInterpretation4, _lblInterpretation5, _lblInterpretation6 };
                    _lblInterpretation1.Text = "";
                    _lblInterpretation2.Text = "";
                    _lblInterpretation3.Text = "";
                    _lblInterpretation4.Text = "";
                    _lblInterpretation5.Text = "";
                    _lblInterpretation6.Text = "";

                    if (config.channel_ap > 0 && config.channel_ap <= channel_labels.Length)
                    {
                        if (rcinput.GetPwm(config.channel_ap) > 1750)
                            channel_labels[config.channel_ap - 1].Text = "Manual mode";
                        else if (rcinput.GetPwm(config.channel_ap) > 1350)
                            channel_labels[config.channel_ap - 1].Text = "Stabilized mode";
                        else if (rcinput.GetPwm(config.channel_ap) > 900)
                            channel_labels[config.channel_ap - 1].Text = "Autopilot mode";
                        else
                            channel_labels[config.channel_ap - 1].Text = "Undetermined";
                    }

                    if (config.channel_motor > 0 && config.channel_motor <= channel_labels.Length)
                    {
                        if (rcinput.GetPwm(config.channel_motor) > 1500)
                            channel_labels[config.channel_motor - 1].Text = "Throttle high (" + (ci == null ? "?)" : ci.Throttle.ToString() + "%)");
                        else if (rcinput.GetPwm(config.channel_motor) > 920)
                            channel_labels[config.channel_motor - 1].Text = "Throttle low (" + (ci == null ? "?)" : ci.Throttle.ToString() + "%)");
                        else if (rcinput.GetPwm(config.channel_motor) > 800)
                            channel_labels[config.channel_motor - 1].Text = "Throttle in autopilot failsafe";
                        else
                            channel_labels[config.channel_motor - 1].Text = "Undetermined";
                    }

                    if (config.channel_pitch > 0 && config.channel_pitch <= channel_labels.Length)
                    {
                        if (rcinput.GetPwm(config.channel_pitch) > 1750)
                            channel_labels[config.channel_pitch - 1].Text = "Pitching UP";
                        else if (rcinput.GetPwm(config.channel_pitch) > 1250)
                            channel_labels[config.channel_pitch - 1].Text = "Pithing +- neutral";
                        else if (rcinput.GetPwm(config.channel_pitch) > 900)
                            channel_labels[config.channel_pitch - 1].Text = "Pithing DOWN";
                        else
                            channel_labels[config.channel_pitch - 1].Text = "Undetermined";
                    }

                    if (config.channel_roll > 0 && config.channel_roll <= channel_labels.Length)
                    {
                        if (rcinput.GetPwm(config.channel_roll) > 1750)
                            channel_labels[config.channel_roll - 1].Text = "Rolling RIGHT";
                        else if (rcinput.GetPwm(config.channel_roll) > 1250)
                            channel_labels[config.channel_roll - 1].Text = "Roll +- neutral";
                        else if (rcinput.GetPwm(config.channel_roll) > 900)
                            channel_labels[config.channel_roll - 1].Text = "Rolling LEFT";
                        else
                            channel_labels[config.channel_roll - 1].Text = "Undetermined";
                    }
                };

                try
                {
                    BeginInvoke(m);
                }
                catch
                {
                }
            }
        }
Exemple #17
0
        void serial_AllConfigCommunicationReceived(Communication.Frames.Configuration.AllConfig config)
        {
            if (this.config_original == null)
                config_original = config;

            guiUpdateBusy = true;
            _tmrGuiUpdateBusy.Enabled = true;
            _tmrGuiUpdateBusy.Start();

            this.config = config;

            MethodInvoker m = delegate()
            {
                _cbInvert1.Checked = config.servo_reverse[0];
                _cbInvert2.Checked = config.servo_reverse[1];
                _cbInvert3.Checked = config.servo_reverse[2];
                _cbInvert4.Checked = config.servo_reverse[3];
                _cbInvert5.Checked = config.servo_reverse[4];
                _cbInvert6.Checked = config.servo_reverse[5];

                ComboBox[] cbn = { _cbInputFunction1, _cbInputFunction2, _cbInputFunction3, _cbInputFunction4, _cbInputFunction5, _cbInputFunction6 };
                cbn[0].SelectedIndex = 5;
                cbn[1].SelectedIndex = 5;
                cbn[2].SelectedIndex = 5;
                cbn[3].SelectedIndex = 5;
                cbn[4].SelectedIndex = 5;
                cbn[5].SelectedIndex = 5;

                if (config.channel_ap <= 6 && config.channel_ap > 0)
                    cbn[config.channel_ap - 1].SelectedIndex = 4;
                if (config.channel_motor <= 6 && config.channel_motor > 0)
                    cbn[config.channel_motor - 1].SelectedIndex = 3;
                if (config.channel_pitch <= 6 && config.channel_pitch > 0)
                    cbn[config.channel_pitch - 1].SelectedIndex = 0;
                if (config.channel_roll <= 6 && config.channel_roll > 0)
                    cbn[config.channel_roll - 1].SelectedIndex = 1;
                if (config.channel_yaw <= 6 && config.channel_yaw > 0)
                    cbn[config.channel_yaw - 1].SelectedIndex = 2;

                if (config.control_mixing < _cbMixing.Items.Count)
                    _cbMixing.SelectedIndex = config.control_mixing;

                _hsPitchSensitivity.Value = Math.Max(0, (int)(config.pid_pitch2elevator_p * 10.0));
                _hsRollSensitivity.Value = Math.Max(0, (int)(config.pid_roll2aileron_p * 10.0));
                //_hsRollSensitivity_ValueChanged(null, ScrollEventArgs.Empty);
                //_hsPitchSensitivity_ValueChanged(null, ScrollEventArgs.Empty);

                _cbAutothrottle.Checked = config.auto_throttle_enabled;
                _hsbCruiseThrottle.Value = Math.Max(0, config.auto_throttle_cruise_pct);
                _hsbCruiseThrottle_Scroll(null, new ScrollEventArgs(ScrollEventType.EndScroll, _hsbCruiseThrottle.Value));
            };

            try
            {
                BeginInvoke(m);
            }
            catch
            {
                ;
            }
        }
Exemple #18
0
 void serial_ControlInfoCommunicationReceived(Communication.Frames.Incoming.ControlInfo ci)
 {
     pressure_height_m = ci.Altitude;
 }
Exemple #19
0
 public virtual bool InsertTrip(UserNodeCore context, Communication.Trip trip)
 {
     return false;
 }
Exemple #20
0
        void serial_AttitudeCommunicationReceived(Communication.Frames.Incoming.Attitude attitude)
        {
            MethodInvoker m = delegate()
            {
                artificialHorizon.pitch_angle = attitude.PitchDeg;
                artificialHorizon.roll_angle = -attitude.RollDeg;
                _lblPitch.Text = "Pitch: " + ((int)attitude.PitchDeg).ToString();
                _lblRoll.Text = "Roll: " + ((int)attitude.RollDeg).ToString();
            };

            try
            {
                BeginInvoke(m);
            }
            catch
            {
            }
        }