public CommunicationPCs(Fuelstation fuelstation)
        {
            this.fuelstation = fuelstation;

            sendTo = 1;
            retrieveFrom = 2;

            string serveradress = ShowIpDialog(); 
           

            myTrafficMessageProxy = new CarCenter.TrafficMessageService.TrafficMessageClient();

            try
            {
                EndpointAddress endPointAddress = new EndpointAddress("http://" + serveradress + "/MessageService");
                myTrafficMessageProxy.Endpoint.Address = endPointAddress;

                //check of er een connectie is
                myTrafficMessageProxy.GetServerName();
            }
            catch (Exception)
            {
                Environment.Exit(0);
            }
            
        }
示例#2
0
        public Form1()
        {
            InitializeComponent();
        
            fuelstation = new Fuelstation();
            pcconnection = new CommunicationPCs(fuelstation);
            fuelstation.setPC(pcconnection);
            arduino1 = new CommunicationArduino(fuelstation, "COM12");
            arduino2 = new CommunicationArduino(fuelstation, "COM13");
            fuelstation.setArduinos(arduino1, arduino2);

            foreach (Car caritem in fuelstation.AllCars)
            {
                listBoxCars.Items.Add(caritem);
            }
        }
        public CommunicationArduino(Fuelstation fuelstation, string compoort)
        {
            this.fuelstation = fuelstation;

            mySerialPort = new SerialPort(compoort);

            mySerialPort.BaudRate = 9600;
            mySerialPort.Parity = Parity.None;
            mySerialPort.StopBits = StopBits.One;
            mySerialPort.DataBits = 8;
            mySerialPort.Handshake = Handshake.None;
            mySerialPort.RtsEnable = true;

            mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);


            // mySerialPort.Open();

        }