Пример #1
0
        private byte ReadTOD(TOD register)
        {
            bool latch = _todLatch;

            if (register == TOD.TENTH)
            {
                _todLatch = false;
            }
            else if (register == TOD.HOURS)
            {
                for (sbyte i = (sbyte)(_tod.GetLength(1) - 1); i >= 0; i--)
                {
                    _tod[(byte)TOD_R.LATCH, i] = _tod[(byte)TOD_R.CURRENT, i];
                }

                _todLatch = true;
            }

            byte value = ToBCD(_tod[latch ? (byte)TOD_R.CURRENT : (byte)TOD_R.LATCH, (byte)register]);

            if (register == TOD.HOURS)
            {
                value |= (byte)(value << 7);
            }

            return(value);
        }
Пример #2
0
    private void Update()
    {
        _speedOfTime   = Mathf.Abs(_speedOfTime);
        _totalMinutes += _speedOfTime * Time.deltaTime;

        // There are 1,440 minutes in a 24-hour day.
        if (_totalMinutes >= 1440)
        {
            // I do not set it to zero in case the speed of time is not a multiple of 1,440 (aka the time ends up X seconds after midnight).
            _totalMinutes -= 1440;
            _daysSinceStart++;
        }

        // Calculates the percentage through the day it currently is, then multiplies that by the maximum rotation, 360.
        _dayPercentage = _totalMinutes / 1440f;
        float angleOfSun = _dayPercentage * 360f;

        _dayNightLight.transform.eulerAngles            = new Vector3(angleOfSun - 90f, 0f, 0f); // TODO allow any Y-rotation, atm it makes the light flicker after midday
        _dayNightLight.GetComponent <Light>().intensity = _brightnessCurve.Evaluate(_dayPercentage);

        if (_dayPercentage >= 0.25f && _dayPercentage <= 0.875f)
        {
            _TimeOfDay = TOD.Day;
        }
        else
        {
            _TimeOfDay = TOD.Night;
        }

        DisplayTime();
    }
Пример #3
0
        private void WriteTOD(TOD register, byte value)
        {
            byte pm = (byte)(value >> 7);

            if (register == TOD.HOURS)
            {
                value &= 0x7f;
            }

            value = FromBCD(value);

            if ((_timerB._controlReg & (byte)TB_CR.TDA) == 0)
            {
                if (register == TOD.TENTH)
                {
                    _todPause = false;
                }
                else if (register == TOD.HOURS)
                {
                    _todPause = true;
                    _tod[(byte)TOD_R.CURRENT, (byte)TOD.AM_PM] = pm;
                }

                _tod[(byte)TOD_R.CURRENT, (byte)register] = value;
            }
            else
            {
                if (register == TOD.HOURS)
                {
                    _tod[(byte)TOD_R.ALARM, (byte)TOD.AM_PM] = pm;
                }

                _tod[(byte)TOD_R.ALARM, (byte)register] = value;
            }
        }
Пример #4
0
        protected void MontarTod(string plazoEntregaCodificado4053)
        {
            var tod = new TOD(null, null,
                              new PlazoEntrega(plazoEntregaCodificado4053, null, null, null, null));

            Segmentos.Add(tod);
            Mensaje += tod.getSegmento();
        }
Пример #5
0
        public static DateTime AtTime(this DateTime @this, int hours, int minutes, TOD timeOfDay)
        {
            if (timeOfDay == TOD.PM)
            {
                hours += 12;
            }

            return(@this.Add(new TimeSpan(hours, minutes, 0)));
        }
Пример #6
0
	// Use this for initialization
	void Start () {
        weather = GetComponent<Weather>();
        tod = GetComponentInChildren<TOD>();
	}
Пример #7
0
        public AdsErrorCode ReadAny(uint indexGroup, uint indexOffset, Type type, bool throwAdsException, out object value)
        {
            AdsErrorCode code;

            if (!type.IsPrimitive)
            {
                if (type == typeof(string))
                {
                    throw new ArgumentException("Use overload ReadAnyString(uint indexGroup, uint indexOffset,  Type type, int characters) for strings.", "type");
                }
                if (type.IsArray)
                {
                    throw new ArgumentException("Use overload ReadAny(uint indexGroup, uint indexOffset,  Type type, int[] args) for arrays.", "type");
                }
                if (type == typeof(TimeSpan))
                {
                    uint milliseconds = base.ReadUInt32(indexGroup, indexOffset, throwAdsException, out code);
                    value = PlcOpenTimeConverter.MillisecondsToTimeSpan(milliseconds);
                }
                else if (type == typeof(DateTime))
                {
                    uint dateValue = base.ReadUInt32(indexGroup, indexOffset, throwAdsException, out code);
                    value = PlcOpenDateConverterBase.ToDateTime(dateValue);
                }
                else if (type == typeof(TIME))
                {
                    uint timeValue = base.ReadUInt32(indexGroup, indexOffset, throwAdsException, out code);
                    value = new TIME(timeValue);
                }
                else if (type == typeof(LTIME))
                {
                    ulong timeValue = base.ReadUInt64(indexGroup, indexOffset, throwAdsException, out code);
                    value = new LTIME(timeValue);
                }
                else if (type == typeof(TOD))
                {
                    uint time = base.ReadUInt32(indexGroup, indexOffset, throwAdsException, out code);
                    value = new TOD(time);
                }
                else if (type == typeof(DATE))
                {
                    uint dateValue = base.ReadUInt32(indexGroup, indexOffset, throwAdsException, out code);
                    value = new DATE(dateValue);
                }
                else if (type != typeof(DT))
                {
                    value = base.ReadStruct(indexGroup, indexOffset, type, throwAdsException, out code);
                }
                else
                {
                    uint dateValue = base.ReadUInt32(indexGroup, indexOffset, throwAdsException, out code);
                    value = new DT(dateValue);
                }
            }
            else if (type == typeof(bool))
            {
                value = base.ReadBoolean(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(int))
            {
                value = base.ReadInt32(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(short))
            {
                value = base.ReadInt16(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(byte))
            {
                value = base.ReadUInt8(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(float))
            {
                value = base.ReadReal32(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(double))
            {
                value = base.ReadReal64(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(long))
            {
                value = base.ReadInt64(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(uint))
            {
                value = base.ReadUInt32(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(ushort))
            {
                value = base.ReadUInt16(indexGroup, indexOffset, throwAdsException, out code);
            }
            else if (type == typeof(ulong))
            {
                value = base.ReadUInt64(indexGroup, indexOffset, throwAdsException, out code);
            }
            else
            {
                if (type != typeof(sbyte))
                {
                    throw new ArgumentException("Unable to marshal type.", "type");
                }
                value = base.ReadInt8(indexGroup, indexOffset, throwAdsException, out code);
            }
            return(code);
        }
Пример #8
0
        private void WriteTOD(TOD register, byte value)
        {
            byte pm = (byte)(value >> 7);
            if (register == TOD.HOURS)
                value &= 0x7f;

            value = FromBCD(value);

            if ((_timerB._controlReg & (byte)TB_CR.TDA) == 0)
            {
                if (register == TOD.TENTH)
                    _todPause = false;
                else if (register == TOD.HOURS)
                {
                    _todPause = true;
                    _tod[(byte)TOD_R.CURRENT, (byte)TOD.AM_PM] = pm;
                }

                _tod[(byte)TOD_R.CURRENT, (byte)register] = value;
            }
            else
            {
                if (register == TOD.HOURS)
                    _tod[(byte)TOD_R.ALARM, (byte)TOD.AM_PM] = pm;

                _tod[(byte)TOD_R.ALARM, (byte)register] = value;
            }
        }
Пример #9
0
        private byte ReadTOD(TOD register)
        {
            bool latch = _todLatch;

            if (register == TOD.TENTH)
                _todLatch = false;
            else if (register == TOD.HOURS)
            {
                for (sbyte i = (sbyte)(_tod.GetLength(1) - 1); i >= 0; i--)
                    _tod[(byte)TOD_R.LATCH, i] = _tod[(byte)TOD_R.CURRENT, i];

                _todLatch = true;
            }

            byte value = ToBCD(_tod[latch ? (byte)TOD_R.CURRENT : (byte)TOD_R.LATCH, (byte)register]);
            if (register == TOD.HOURS)
                value |= (byte)(value << 7);

            return value;
        }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     inventory = GameObject.Find("Inventory").GetComponent<InventarScript>();
     ui = GameObject.Find ("GUI").GetComponent<UIScript> ();
     if(tod == null)
         tod = GameObject.Find ("TOD").GetComponent<TOD> ();
     lastTimeFish = -1F;
 }
Пример #11
0
 void Start()
 {
     todScript = GetComponent<TOD>();
     GameObject.FindGameObjectWithTag ("GameManager").GetComponent<GameManager> ().todScript = todScript;
 }
Пример #12
0
 public TODAnimation(TOD tod, List <Mesh> objectTable, Material mat)
 {
     Tod         = tod;
     ObjectTable = objectTable;
     Material    = mat;
 }