public EdCustomAdapterCommon(SendDataDelegate sendDataFunc, ReceiveDataDelegate receiveDataFunc,
                                     DiscardInBufferDelegate discardInBufferFunc, ReadInBufferDelegate readInBufferFunc,
                                     int readTimeoutOffsetLong, int readTimeoutOffsetShort, int echoTimeout, bool echoFailureReconnect)
        {
            _readTimeoutOffsetLong  = readTimeoutOffsetLong;
            _readTimeoutOffsetShort = readTimeoutOffsetShort;
            _echoTimeout            = echoTimeout;
            _echoFailureReconnect   = echoFailureReconnect;
            _sendDataFunc           = sendDataFunc;
            _receiveDataFunc        = receiveDataFunc;
            _discardInBufferFunc    = discardInBufferFunc;
            _readInBufferFunc       = readInBufferFunc;

            RawMode           = false;
            CurrentProtocol   = EdInterfaceObd.Protocol.Uart;
            ActiveProtocol    = EdInterfaceObd.Protocol.Uart;
            CurrentBaudRate   = 0;
            ActiveBaudRate    = -1;
            CurrentWordLength = 0;
            ActiveWordLength  = -1;
            CurrentParity     = EdInterfaceObd.SerialParity.None;
            ActiveParity      = EdInterfaceObd.SerialParity.None;
            InterByteTime     = 0;
            CanTxId           = -1;
            CanRxId           = -1;
            CanFlags          = EdInterfaceObd.CanFlags.Empty;
            AdapterType       = -1;
            AdapterVersion    = -1;
            AdapterSerial     = null;
        }
Example #2
0
        void ICallback.test()
        {
            ReceiveDataDelegate rdd = ReceiveData;

            if (rdd != null)
            {
                rdd();
            }
        }
		/// <summary>
		/// Page load event handler.
		/// </summary>
		/// <param name="sender">Event sender.</param>
		/// <param name="e">Event arguments.</param>
		private void MainFrameControl_Load(object sender, System.EventArgs e)
		{
            receiveDelegate += new ReceiveDataDelegate(addReceiveData);
            this.comboBox1.Items.AddRange(DataReceiver.GetPortNames());
            this.comboBox1.SelectedIndex = 0;

            // 按钮状态设置
            connectBtn.Text = resources.GetString("Connect");
            connectBtn.Enabled = true;
            toggleBtn.Visible = false;
		}
        public void UnsubscribeFrom(string topic, ReceiveDataDelegate subscriberHandler)
        {
            if (subscriptions.ContainsKey(topic) && subscriberHandler != null)
            {
                subscriptions[topic].OnReceiveData -= subscriberHandler;

                if (!subscriptions[topic].HasSubscribers)
                {
                    CloseSubscriptionSocket(topic);
                }
            }
        }
        public void SubscribeTo(string topic, ReceiveDataDelegate subscriberHandler)
        {
            if (!subscriptions.ContainsKey(topic))
            {
                string       connectionStr = requestCtrl.GetConnectionString();
                Subscription subscription  = new Subscription(connectionStr, topic);

                subscriptions.Add(topic, subscription);
                // subscriptions[topic].OnReceiveData += Logging;
            }

            subscriptions[topic].OnReceiveData += subscriberHandler;
        }
        public void SubscribeTo(string topic, ReceiveDataDelegate subscriberHandler)
        {
            if (!IsConnected)
            {
                Debug.LogWarning("Not connected!");
                return;
            }

            if (!subscriptions.ContainsKey(topic))
            {
                string       connectionStr = requestCtrl.GetSubConnectionString();
                Subscription subscription  = new Subscription(connectionStr, topic);

                subscriptions.Add(topic, subscription);
            }

            subscriptions[topic].OnReceiveData += subscriberHandler;
        }
        public static void GetData(ReceiveDataDelegate callback)
        {
            //string url = "http://api.krisinformation.se/v1/feed?format=json";
            string url = "http://192.168.1.118:8080/all";

            var httpReq = (HttpWebRequest)HttpWebRequest.Create (new Uri (url));

            httpReq.BeginGetResponse ((ar) => {
                var request = (HttpWebRequest)ar.AsyncState;
                using (var response = (HttpWebResponse)request.EndGetResponse (ar))
                {
                    var s = response.GetResponseStream ();
                    var j = (JsonObject)JsonObject.Load (s);

                    var results = (from result in (JsonArray)j ["Entries"]
                                   let jResult = result as JsonObject
                                   select jResult).ToArray();

                    callback(results);
                }
            } , httpReq);
        }