Ejemplo n.º 1
0
        /// <inheritdoc/>
        public override string ToString()
        {
            StringBuilder message = new StringBuilder();

            foreach (string item in new string[] { ParatextId, Name, ShortName, LanguageTag, ProjectId,
                                                   IsConnectable.ToString(), IsConnected.ToString(), IsInstalled.ToString(),
                                                   AvailableRevision.ToString(), InstalledRevision.ToString() })
            {
                message.Append(item);
                message.Append(',');
            }

            return(message.ToString());
        }
Ejemplo n.º 2
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(CarInfo)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(IsConnected), IsConnected.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarModel), CarModel.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarSkin), CarSkin.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverName), DriverName.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverTeam), DriverTeam.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverGuid), DriverGuid.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Ejemplo n.º 3
0
    public void OnStatusChanged(StatusCode statusCode)
    {
        switch (statusCode)
        {
        case StatusCode.Connect:
            IsConnected = true;
            TLogger.DEBUG(IsConnected.ToString());
            break;

        case StatusCode.Disconnect:
        case StatusCode.DisconnectByServer:
        case StatusCode.DisconnectByServerLogic:
            IsConnected = false;
            break;
        }
    }
Ejemplo n.º 4
0
        void tmrCheckService_InterfaceChanged(object sender, EventArgs e)
        {
            lblIsConnected.Text    = IsConnected.ToString();
            lblServerTime.Text     = ServerTime.ToString();
            lblServiceVersion.Text = ServiceVersion;
            lblStatus.Text         = Status;

            if (varXml.RebootComputer)
            {
                lblFault.Text = string.Format("{0} / {1}", FaultCount, varXml.FaultCountLimit);
            }
            else
            {
                lblFault.Text = string.Format("{0}", FaultCount);
            }
        }
            public override void Run()
            {
                Logger.Log("ConnectedThread: Run");

                byte[] buffer = new byte[16];

                int bytes;

                Logger.Log("IsConnected = " + IsConnected.ToString());

                while (IsConnected)
                {
                    try
                    {
                        //Logger.Log("READ READ READ HAHAHAHA1");
                        bytes = inStream.Read(buffer, 0, buffer.Length);// (buffer, 0, buffer.Length);


                        //inStream.FlushAsync();

                        //                    bytes = inStream.Read (buffer);
                        //string readMessage = new string(buffer, 0, bytes);
                        //                    Logger.Log ("READ READ READ HAHAHAHA2");
                        //                    string message = Encoding.ASCII.GetString (buffer, 0, bytes);

                        service.handler
                        .ObtainMessage(2, bytes, -1, buffer)
                        .SendToTarget();

                        //Logger.Log(message);


                        // Send the obtained bytes to the UI Activity
                        //                    service.handler
                        //                           .ObtainMessage(2, bytes, -1, buffer)
                        //                           .SendToTarget();
                    }
                    catch (IOException e)
                    {
                        Logger.Log(e.Message);
                        IsConnected = false;
                    }
                }
            }
Ejemplo n.º 6
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(Driver)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarModel), CarModel.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarSkin), CarSkin.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Name), Name.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Team), Team.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(GUID), GUID.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(IsConnected), IsConnected.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Position), Position.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(VelocityVector), VelocityVector.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Speed), Speed.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(SplinePosition), SplinePosition.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Gear), Gear.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(EngineRPM), EngineRPM.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Ejemplo n.º 7
0
        protected virtual bool InitBase(string friendlyNamePrefix, string deviceType)
        {
            if (TheCommonUtils.CGuid(MyBaseThing.ID) == Guid.Empty)
            {
                MyBaseThing.ID = Guid.NewGuid().ToString();
                if (string.IsNullOrEmpty(MyBaseThing.FriendlyName))
                {
                    MyBaseThing.FriendlyName = $"{friendlyNamePrefix}: {MyBaseThing.ID}";
                }
            }

            MyBaseThing.LastUpdate = DateTimeOffset.Now;

            MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
            MyBaseThing.DeviceType = deviceType;

            TheBaseEngine.WaitForStorageReadiness((pThing, pReady) =>
            {
                if (pReady != null)
                {
                    var receiverThings                      = new TheStorageMirror <TConnectionThing>(TheCDEngines.MyIStorageService);
                    receiverThings.CacheTableName           = nameof(TConnectionThing) + TheThing.GetSafeThingGuid(MyBaseThing, nameof(TConnectionThing));
                    receiverThings.IsRAMStore               = true;
                    receiverThings.CacheStoreInterval       = 1;
                    receiverThings.IsStoreIntervalInSeconds = true;
                    receiverThings.IsCachePersistent        = true;
                    receiverThings.UseSafeSave              = true;
                    receiverThings.RegisterEvent(eStoreEvents.StoreReady, (args) =>
                    {
                        var result = args.Para as TSM;
                        if (result != null && result.LVL == eMsgLevel.l1_Error)
                        {
                            MyBaseThing.SetStatus(3, "Error loading things");
                            TheBaseAssets.MySYSLOG.WriteToLog(98201, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseThing.EngineName, "Initialization", eMsgLevel.l6_Debug, String.Format("Error loading things for connection {0}", this.GetBaseThing().Address)));
                        }
                        else
                        {
                            MyConnectionThings = receiverThings;
                            if (MyConnectionThingsForm != null)
                            {
                                MyConnectionThingsForm.defDataSource = MyConnectionThings.StoreMID.ToString();
                            }
                            TheBaseAssets.MySYSLOG.WriteToLog(95272, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM(MyBaseThing.EngineName, "Initialization", eMsgLevel.l6_Debug, String.Format("Things loaded for connection {0}", this.GetBaseThing().Address)));

                            if (AutoConnect)
                            {
                                Connect();
                                if (!IsConnected)
                                {
                                    TheCommonUtils.cdeRunTaskAsync("receiverAutoConnect", async o =>
                                    {
                                        await TheCommonUtils.TaskDelayOneEye(30000, 100).ConfigureAwait(false);
                                        while (!IsConnected && AutoConnect && TheBaseAssets.MasterSwitch)
                                        {
                                            Connect();
                                            await TheCommonUtils.TaskDelayOneEye(30000, 100).ConfigureAwait(false);
                                        }
                                    }).ContinueWith(t => t.Exception);
                                }
                            }
                            mIsInitialized = true;
                            FireEvent(eThingEvents.Initialized, this, true, true);
                            FireEvent("ServerInit", this, IsConnected.ToString(), true);
                        }
                    }
                                                 );
                    receiverThings.InitializeStore(false, false);
                }
            }, true);
            return(mIsInitialized);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// ToString representation
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            if (m_Socket == null)
            {
                return("Not connected");
            }
            string rep = m_Socket.RemoteEndPoint.ToString();
            string lep = m_Socket.LocalEndPoint.ToString();

            return
                (m_Socket.ProtocolType.ToString() + String.Format(" State = {0} sockets L = {1} R = {2}", IsConnected.ToString(), lep, rep));
        }