Exemplo n.º 1
0
	void tick(TimerTick e)
	{
		GetComponent<SpriteRenderer>().sprite = sprite_passive;
		if(e.note%4 == 0){
			GetComponent<SpriteRenderer>().sprite = sprite_active;
		}
	}
Exemplo n.º 2
0
    void tick(TimerTick e)
    {
        previousPoints = points;
        points = playerScript.points;
        Debug.Log("points: " + points);
        correctInput = points > previousPoints;

       // if (Input.GetKey(KeyCode.Space) && e.note % 2 == 0) // for testing
        if (correctInput && e.note%2 == 0)
        {
            randomDirection = beatTurningScript.randomDirection;
            Debug.Log("King movement: randomDirection: " + randomDirection + ", euler z: " + transform.rotation.eulerAngles.z);

            if (level == OUTER_CIRCLE && points == 16)
            {
                level = MIDDLE_CIRCLE;
                //MOVE TO MIDDLE CIRCLE
                Vector3 target = transform.localPosition - new Vector3(-2 , 0, 0);

                tweenTranslation(e.interval, target);
            }
            else if (level == MIDDLE_CIRCLE && points == 32)
            {
                level = INNER_CIRCLE;
                //MOVE TO INNER CIRCLE

                Vector3 target = transform.localPosition - new Vector3(-2, 0, 0);
                tweenTranslation(e.interval, target);
            }
            tweenRotation(e.interval);

        }
    }
Exemplo n.º 3
0
	void tick(TimerTick e)
	{
		GetComponent<SpriteRenderer>().sprite = arrowPassive;
		if(e.note%2 == 0){
			GetComponent<SpriteRenderer>().sprite = arrowActive;
		}

	}
Exemplo n.º 4
0
	void tick(TimerTick e)
	{   
		if(!playing){
			anim.Play("tree");
			anim.speed = 1/e.interval*2/8;
			playing = true;
		}
	}
Exemplo n.º 5
0
	void tick (TimerTick e){
		if(e.note%2 == 0){
            randomDirection = (Random.Range(0, 3) - 1);
            HOTween.To(transform, e.interval, new TweenParms()
				.Prop("rotation", new Vector3(0,0, gameObject.transform.rotation.eulerAngles.z + (22.5f * randomDirection)))
				.Ease(EaseType.EaseOutBounce));
		}

	}
    void tick(TimerTick e)
	{
		GetComponent<SpriteRenderer>().sprite = sprite_passive;
	    if(e.note%2 == 0){
		    GetComponent<SpriteRenderer>().sprite = sprite_color_1;
	    }
	    if(e.note%4 == 0){
		    GetComponent<SpriteRenderer>().sprite = sprite_color_2;
	    }

    }
Exemplo n.º 7
0
        public void TestTimer()
        {
            TimerTick t = new TimerTick();
            t.StartTimer();
            TimerService.TimerTick.TimerTicked tick = new TimerTick.TimerTicked(funcRetorno);
            t.Ticked = tick;

            while(ret==false){
            }

            Assert.AreEqual(ret, true);
        }
Exemplo n.º 8
0
	void tick(TimerTick e){
		if(e.note%2 == 0){
			audio.PlayOneShot(kick, 1F);
		}
   
		if( e.note%3 == 0){
			audio.PlayOneShot(closed, 1F);
		}
		if(e.note == 4){
			audio.PlayOneShot(snare, 1F);
		}
		if(e.note%2 == 0){
			audio.PlayOneShot(rim, 1F);
		}
		if( e.note%1 == Random.Range(0,2)){
			audio.PlayOneShot(shake, 1F);
			audio.PlayOneShot(clap, 0.2F);
		}

	}
Exemplo n.º 9
0
 private void TimerOnTick(Object sender, EventArgs e)
 {
     TimerTick?.Invoke(this, e);
 }
Exemplo n.º 10
0
 private void OnTimer(uint id, uint msg, ref uint userCtx, uint rsv1, uint rsv2)
 {
     TimerTick?.Invoke();
 }
Exemplo n.º 11
0
 /// <summary>
 /// One-time data initialization, since we only ever create one <see cref="App"/> instance!
 /// </summary>
 public App()
 {
     timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Send, (s, e) => TimerTick?.Invoke(startTime), Dispatcher);
     timer.Stop();
 }
Exemplo n.º 12
0
 void Metronome_Tick(object sender, EventArgs e)
 {
     TimerTick?.Invoke(this, e);
 }
Exemplo n.º 13
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     TimerTick?.Invoke(this, DateTime.UtcNow); // UTC time
 }
Exemplo n.º 14
0
 public UITimerTask(TimerTick tickAction)
 {
     this.tickAction = tickAction;
     RunOnce         = false;
 }
Exemplo n.º 15
0
 public void Update(TimerTick item)
 {
     _timerTalkContext.TimerTicks.Update(item);
 }
Exemplo n.º 16
0
 private void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     TimerTick?.Invoke();
 }
Exemplo n.º 17
0
 private void RaiseTimerTickEvent()
 {
     TimerTick?.Invoke(this, new TimerTickEventArgs(ElapsedTimeString));
 }
Exemplo n.º 18
0
 public void Add(TimerTick item)
 {
     _timerTalkContext.TimerTicks.Add(item);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Timer event. Counts up in increments of 1 second
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnTimerEvent(object sender, System.Timers.ElapsedEventArgs args)
        {
            countedTime++;

            TimerTick?.Invoke(this, EventArgs.Empty);
        }
 /// <summary>
 /// Adds a new handler (method) to the delegate to be called when the timer ticks.
 /// </summary>
 /// <param name="tick"></param>
 public void RegisterTimerListener(TimerTick tick)
 {
     handler += tick;
 }
 public TimeTickObserver(TimerTick tick)
 {
     handler += tick;
 }
Exemplo n.º 22
0
 public void OnTimerTick(int numberMovingBy)
 {
     TimerTick?.Invoke(this, numberMovingBy);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Called when [tick].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="eventArgs">The event arguments.</param>
 private void OnTick(object sender, TimerTickEvenArgs eventArgs)
 {
     TimerTick?.Invoke(this, eventArgs);
 }
Exemplo n.º 24
0
        public void Delete(int id, string userId)
        {
            TimerTick toRemove = GetSingle(id, userId);

            _timerTalkContext.TimerTicks.Remove(toRemove);
        }
Exemplo n.º 25
0
 public DrawEventArgs(TimerTick timer, Size renderSize, WriteableBitmap target)
 {
     Timer      = timer;
     RenderSize = renderSize;
     Target     = target;
 }
Exemplo n.º 26
0
        public void Start()
        {
            m_timer = new TimerTick();

            System.Windows.Media.CompositionTarget.Rendering += CompositionTarget_Rendering;
        }
Exemplo n.º 27
0
        /// <summary>
        /// 获取下设帧数据域内容
        /// 数据字典的键需要拆分成标志和类型(以空格隔开),方便组织
        /// !注意:dictionary的可以通过参数传递或者共享同步变量得来
        /// </summary>
        /// <param name="unitvalue"> web端传来的消息</param>
        /// <returns>数据域</returns>
        public static byte[] GetData(Dictionary <string, string> unitvalue)
        {
            byte []   data;
            string [] collect;
            string    flag;
            ushort    unit;
            string    value;
            //方便动态组织数据
            List <byte> datalist = new List <byte>();

            for (int i = 0; i < unitvalue.Count; i++)
            {
                collect = unitvalue.ElementAt(i).Key.Split(' ');
                flag    = collect[0];
                unit    = (ushort)Convert.ToUInt16(collect[1]);
                value   = unitvalue.ElementAt(i).Value;
                //单数据类型处理
                if ("o" == flag)
                {
                    //collect[]: collect[0]=大类数据类型   collect[1] = 操作单元
                    switch (unit)
                    {
                    //uchar处理
                    case 0:
                    {
                        //每次循环中只会操作一次unit,下次循环unit会被更新(所以忽略这里的修改)
                        //datalist.Add((byte)unit);
                        //datalist.Add((byte)(unit>>8));
                        AddUnitToList(datalist, unit);
                        datalist.Add((byte)Convert.ToUInt16(value));
                    }
                    break;

                    //ushort处理
                    case 1:
                    {
                        AddUnitToList(datalist, unit);
                        AddUshortToList(datalist, Convert.ToUInt16(value));
                        //datalist.Add((byte)unit);
                        //datalist.Add((byte)(unit>>8));
                        //ushort temp = Convert.ToUInt16(value);
                        //datalist.Add((byte)temp);
                        //datalist.Add((byte)(temp >> 8));
                    }
                    break;

                    //float处理
                    case 2:
                    {
                        //float转换为字节数组
                        //float temp = Convert.ToSingle(value);
                        //byte[] arrtemp = ByteStruct.StructToBytes(temp);
                        AddUnitToList(datalist, unit);
                        AddFloatToList(datalist, Convert.ToSingle(value));
                        //datalist.Add((byte)unit);
                        //datalist.Add((byte)(unit >> 8));
                        //datalist.Add(arrtemp[0]);
                        //datalist.Add(arrtemp[1]);
                        //datalist.Add(arrtemp[2]);
                        //datalist.Add(arrtemp[3]);
                    }
                    break;

                    //datetime处理
                    case 3:
                    {
                        //datalist.Add((byte)unit);
                        //datalist.Add((byte)(unit >> 8));
                        //datetime转换成long来移位保存
                        AddUnitToList(datalist, unit);
                        long date = TimerTick.TimeSpanToSecond(Convert.ToDateTime(collect[2]));
                        datalist.Add((byte)date);
                        datalist.Add((byte)(date >> 8));
                        datalist.Add((byte)(date >> 16));
                        datalist.Add((byte)(date >> 24));
                        datalist.Add((byte)(date >> 32));
                        datalist.Add((byte)(date >> 40));
                        datalist.Add((byte)(date >> 48));
                        datalist.Add((byte)(date >> 56));
                    }
                    break;

                    default:
                        //MessageBox.Show("在解析为单类型数据后没有对应的类型");
                        break;
                    }
                }
                //单类型数组处理
                else if ("s" == flag)
                {
                    switch (unit)
                    {
                        #region   //组织变电站名和网络地址
                        //这里在解析相对数据的时候过滤字符串结束符
                        //case 4:
                        //    {
                        //        //datalist.Add((byte)unit);
                        //        //datalist.Add((byte)(unit >> 8));
                        //        if (16 == MyDictionary.unitlendict[unit])
                        //        {
                        //            AddUnitToList(datalist, unit);
                        //            byte []temp_16 = new byte[16];
                        //            Encoding.Unicode.GetBytes(value).CopyTo(temp_16 , 0);
                        //            for (int j = 0; j < 16; j++)
                        //            {
                        //                datalist.Add(temp_16[j]);
                        //            }
                        //        }
                        //        else
                        //            if (80 == MyDictionary.unitlendict[unit])
                        //            {
                        //                AddUnitToList(datalist, unit);
                        //                byte []temp_80 = new byte[80];
                        //                Encoding.Unicode.GetBytes(value).CopyTo(temp_80 , 0);
                        //                for (int j = 0; j < 80; j++)
                        //                {
                        //                    datalist.Add(temp_80[j]);
                        //                }
                        //            }
                        //            else
                        //                MessageBox.Show("变电站名和软件版本类超出范围");
                        //    }
                        //    break;
                        //组织网络通信地址
                        //传来为ip地址字符串形式,这里不需要对数据点表中给定的uchar数组类型进行分治处理
                        //case 5:
                        //    {
                        //        //datalist.Add((byte)unit);
                        //        //datalist.Add((byte)(unit >> 8));
                        //        AddUnitToList(datalist , unit);
                        //        byte []iparray = IPAddress.Parse(value).GetAddressBytes();
                        //        datalist.Add(iparray[0]);
                        //        datalist.Add(iparray[1]);
                        //        datalist.Add(iparray[2]);
                        //        datalist.Add(iparray[3]);
                        //    }
                        //    break;
                        //ushort[]数组处理,只有ushort[4]类型
                        //数据字典中这类数据的组织:
                        //(A) 118+ushort    (B) 118+ushort  (C) 118+ushort   (D) 118+ushort 括号中不存在
                        //一个数组的四个数据连续组织,装包是检测到第一个顺序装入
                        //解析的时候做同样处理
                        #endregion
                    case 5:
                    {
                        //两个ushort元素数组处理
                        if (2 == MyDictionary.unitlendict[unit])
                        {
                            //给出开头顺序后去一个ushort
                            AddUnitToList(datalist, unit);
                            AddUshortToList(datalist, Convert.ToUInt16(value));
                            AddUshortToList(datalist, Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                            ///datalist.Add((byte)unit);
                            ///datalist.Add((byte)(unit >> 8));
                            ///ushort temp1 = Convert.ToUInt16(value);
                            ///datalist.Add((byte)temp1);
                            ///datalist.Add((byte)(temp1 >> 8));
                            ///i++;
                            ///temp1 = Convert.ToUInt16(unitvalue.ElementAt(i).Value);
                            ///datalist.Add((byte)temp1);
                            ///datalist.Add((byte)(temp1 >> 8));
                        }
                        //四个ushort元素数组处理
                        else
                        if (4 == MyDictionary.unitlendict[unit])
                        {
                            AddUnitToList(datalist, unit);
                            AddUshortToList(datalist, Convert.ToUInt16(value));
                            AddUshortToList(datalist, Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                            AddUshortToList(datalist, Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                            AddUshortToList(datalist, Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                            //datalist.Add((byte)unit);
                            //datalist.Add((byte)(unit >> 8));
                            //ushort temp2 = Convert.ToUInt16(value);
                            //datalist.Add((byte)temp2);
                            //datalist.Add((byte)(unit >> 8));
                            //for (int j = 0; j < 3; j++)
                            //{
                            //    i++;
                            //    temp2 = Convert.ToUInt16(unitvalue.ElementAt(i).Value);
                            //    datalist.Add((byte)temp2);
                            //    datalist.Add((byte)(temp2 >> 8));
                            //}
                        }
                        else
                        {
                            //MessageBox.Show("writeunit_getdata:ushort类型单数组格式出现范围之外数组");
                        }
                    }
                    break;

                    //float类数组处理
                    case 6:
                    {
                        if (MyDictionary.unitlendict[unit] == 2)
                        {
                            AddUnitToList(datalist, unit);
                            AddFloatToList(datalist, Convert.ToSingle(value));
                            AddFloatToList(datalist, Convert.ToSingle(unitvalue.ElementAt(++i).Value));
                        }
                        else
                        if (MyDictionary.unitlendict[unit] == 3)
                        {
                            AddUnitToList(datalist, unit);
                            AddFloatToList(datalist, Convert.ToSingle(unitvalue.ElementAt(++i).Value));
                            AddFloatToList(datalist, Convert.ToSingle(unitvalue.ElementAt(++i).Value));
                        }
                        else
                        if (MyDictionary.unitlendict[unit] == 5)
                        {
                            AddUnitToList(datalist, unit);
                            AddFloatToList(datalist, Convert.ToSingle(unitvalue.ElementAt(++i).Value));
                            AddFloatToList(datalist, Convert.ToSingle(unitvalue.ElementAt(++i).Value));
                            AddFloatToList(datalist, Convert.ToSingle(unitvalue.ElementAt(++i).Value));
                            AddFloatToList(datalist, Convert.ToSingle(unitvalue.ElementAt(++i).Value));
                        }
                        else
                        {
                            //MessageBox.Show("float类型单数组格式出现范围之外的数组");
                        }
                    }
                    break;

                    default:
                    {
                        //MessageBox.Show("单类型数组处理错误!");
                        break;
                    }
                    }
                }
                #region  //混合类型处理
                //都是数据传输接口相关参数,暂时忽略
                //else if ("x" == flag)
                //{
                //    if (157 == unit || 160 == unit)
                //    {
                //        AddUnitToList(datalist , unit);
                //        AddIPToList(datalist , value);
                //        AddUshortToList(datalist , Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                //    }
                //    else
                //        if (158 == unit || 161 == unit)
                //        {
                //            AddUnitToList(datalist, unit);
                //            AddUshortToList(datalist, Convert.ToUInt16(value));
                //            datalist.Add((byte)Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                //            datalist.Add((byte)Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                //            datalist.Add((byte)Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                //        }
                //        else
                //            if (159 == unit || 162 == unit)
                //            {
                //                AddUnitToList(datalist, unit);
                //                AddIPToList(datalist, value);
                //                AddUshortToList(datalist, Convert.ToUInt16(unitvalue.ElementAt(++i).Value));
                //                AddIPToList(datalist, unitvalue.ElementAt(++i).Value);
                //                AddIPToList(datalist, unitvalue.ElementAt(++i).Value);
                //            }
                //            else
                //            {
                //                MessageBox.Show("混合类型处理超出可行范围");
                //            }
                //}
                #endregion
                else
                {
                    //MessageBox.Show("解析完成字符串数据大类标志报错");
                }
            }
            data = datalist.ToArray <byte>();
            return(data);
        }
Exemplo n.º 28
0
 private void RunFromLocalTimer(object sender)
 {
     TimerTick?.Invoke();
     Run();
 }
Exemplo n.º 29
0
        /// <summary>
        /// 未考虑数组的情况,用于解析帧
        /// </summary>
        /// <param name="src">根据操作单元查字典把字节数组翻译为相应的数据类型</param>
        /// <param name="unit">操作单元</param>
        /// <returns></returns>
        public static object GetValue(byte[] src, ushort unit)
        {
            object temp;

            switch (MyDictionary.unittypedict[unit])
            {
            //uchar
            case 0:
            {
                temp = src[0];
            }
            break;

            //ushort
            case 1:
            {
                temp = ByteStruct.BytesToStruct(src, typeof(ushort));
            }
            break;

            //float
            case 2:
            {
                temp = ByteStruct.BytesToStruct(src, typeof(float));
            }
            break;

            //datetime
            case 3:
            {
                long _temp = (long)ByteStruct.BytesToStruct(src, typeof(long));
                temp = TimerTick.TimeSpanToDate(_temp);
            }
            break;

            //char[]
            case 4:
            {
                char[] _temp = new char[src.Length];
                for (int i = 0; i < src.Length; i++)
                {
                    _temp[i] = (char)src[i];
                }
                temp = _temp;
                break;
            }

            //ushort[2]==EraseRange
            case 5:
            {
                temp = (Define.EraseRange)ByteStruct.BytesToStruct(src,
                                                                   typeof(Define.EraseRange));
                break;
            }

            //ushort[4]==GasFixPara_A
            case 6:
            {
                temp = (Define.GasFixPara_A)ByteStruct.BytesToStruct(src,
                                                                     typeof(Define.GasFixPara_A));
                break;
            }

            //ushort[4]==GasFixPara_B
            case 7:
            {
                temp = (Define.GasFixPara_B)ByteStruct.BytesToStruct(src,
                                                                     typeof(Define.GasFixPara_B));
                break;
            }

            //float[2]==EnvironmentSetting
            case 8:
            {
                temp = (Define.EnvironmentSetting)ByteStruct.BytesToStruct(src,
                                                                           typeof(Define.EnvironmentSetting));
                break;
            }

            //float[3]==H2OAnlyParam_AW
            case 9:
            {
                temp = (Define.H2OAnlyParam_AW)ByteStruct.BytesToStruct(src,
                                                                        typeof(Define.H2OAnlyParam_AW));
                break;
            }

            //float[3]==H2OAnlyParam_T
            case 10:
            {
                temp = (Define.H2OAnlyParam_T)ByteStruct.BytesToStruct(src,
                                                                       typeof(Define.H2OAnlyParam_T));
                break;
            }

            //float[5]==GasFixParameters
            case 11:
            {
                temp = (Define.GasFixParameters)ByteStruct.BytesToStruct(src,
                                                                         typeof(Define.GasFixParameters));
                break;
            }

            default:
                //MessageBox.Show("readunit-getdata:这里只做系统类型的处理,自定义类型暂未考虑");
                temp = null;
                break;
            }
            return(temp);
        }
Exemplo n.º 30
0
 public UIHoverMonitorTask(TimerTick targetEventHandler)
     : base(targetEventHandler)
 {
     this.targetEventHandler = targetEventHandler;
 }
Exemplo n.º 31
0
 public void RaiseEvent()
 {
     TimerTick?.Invoke(
         this,
         EventArgs.Empty);
 }
 public void Tick()
 {
     TimerTick?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 33
0
	void tick(TimerTick e){
		if(e.note%4 == 0){
			addCommand(e.interval*4f);
			checkCommand();
		}
	}