示例#1
0
        public virtual bool Init()
        {
            if (mIsInitCalled)
            {
                return(false);
            }
            mIsInitCalled = true;
            IsStarted     = false;
            if (string.IsNullOrEmpty(MyBaseThing.ID))
            {
                MyBaseThing.ID = Guid.NewGuid().ToString();
            }

            if (MyBaseThing.GetProperty(nameof(PlaybackSpeedFactor), false) == null)
            {
                PlaybackSpeedFactor = 1;
            }
            if (MyBaseThing.GetProperty(nameof(InputFileName), false) == null)
            {
                InputFileName = "meshsenderdata.log";
            }
            if (MyBaseThing.GetProperty(nameof(ParallelPlaybackCount), false) == null)
            {
                ParallelPlaybackCount = 1;
            }

            MyBaseThing.RegisterOnChange(nameof(ParallelPlaybackCount), (o) => {
                if (IsStarted)
                {
                    StopPlaybackAsync("Changed number of things").ContinueWith(t => StartPlaybackAsync(false));
                }
            });

            MyBaseThing.Value       = "0";
            IsActive                = true;
            MyBaseThing.StatusLevel = 0;
            if (AutoStart)
            {
                TheCommonUtils.cdeRunAsync("DataPLayerAutostart", true, async o =>
                {
                    //if (AutoStartDelay > 0)
                    //{
                    //    await TheCommonUtils.TaskDelayOneEye(AutoStartDelay, 100);
                    //}
                    await StartPlaybackAsync(true);
                });
            }

            MyBaseThing.RegisterEvent(eEngineEvents.FileReceived, sinkFileReceived);

            mIsInitialized = true;
            return(true);
        }