Example #1
0
		bool GetDelays(XBase xBase)
		{
			SendResult sendResult = null;
			var expectedBytesCount = 68;
			if (xBase.KauDatabaseParent != null)
			{
				sendResult = SendManager.Send(xBase.KauDatabaseParent, 2, 12, 32, BytesHelper.ShortToBytes(xBase.KAUDescriptorNo));
				expectedBytesCount = 32;
			}
			else
			{
				sendResult = SendManager.Send(xBase.GkDatabaseParent, 2, 12, 68, BytesHelper.ShortToBytes(xBase.GKDescriptorNo));
				expectedBytesCount = 68;
			}

			if (sendResult.HasError || sendResult.Bytes.Count != expectedBytesCount)
			{
				ConnectionChanged(false);
				return false;
			}
			ConnectionChanged(true);
			var descriptorStateHelper = new DescriptorStateHelper();
			descriptorStateHelper.Parse(sendResult.Bytes, xBase);

			xBase.BaseState.LastDateTime = DateTime.Now;
			xBase.BaseState.OnDelay = descriptorStateHelper.OnDelay;
			xBase.BaseState.HoldDelay = descriptorStateHelper.HoldDelay;
			xBase.BaseState.OffDelay = descriptorStateHelper.OffDelay;
			return true;
		}
Example #2
0
		void GetState(XBase xBase, bool delaysOnly = false)
		{
			var sendResult = SendManager.Send(xBase.GkDatabaseParent, 2, 12, 68, BytesHelper.ShortToBytes(xBase.GKDescriptorNo));
			if (sendResult.HasError || sendResult.Bytes.Count != 68)
			{
				ConnectionChanged(false);
				return;
			}
			ConnectionChanged(true);
			var descriptorStateHelper = new DescriptorStateHelper();
			descriptorStateHelper.Parse(sendResult.Bytes, xBase);
			CheckDBMissmatch(xBase, descriptorStateHelper);

			xBase.BaseState.LastDateTime = DateTime.Now;
			if (!delaysOnly)
			{
				xBase.BaseState.StateBits = descriptorStateHelper.StateBits;
				xBase.BaseState.AdditionalStates = descriptorStateHelper.AdditionalStates;
			}
			xBase.BaseState.OnDelay = descriptorStateHelper.OnDelay;
			xBase.BaseState.HoldDelay = descriptorStateHelper.HoldDelay;
			xBase.BaseState.OffDelay = descriptorStateHelper.OffDelay;
		}
Example #3
0
		bool GetDelays(GKBase gkBase)
		{
			gkBase.InternalState.LastDateTime = DateTime.Now;

			SendResult sendResult = null;
			if (gkBase.KauDatabaseParent != null)
			{
				sendResult = SendManager.Send(gkBase.KauDatabaseParent, 2, 12, 32, BytesHelper.ShortToBytes(gkBase.KAUDescriptorNo));
				if (sendResult.HasError || sendResult.Bytes.Count != 32)
				{
					gkBase.InternalState.ZeroHoldDelayCount = 10;
					return false;
				}
			}
			else
			{
				sendResult = SendManager.Send(gkBase.GkDatabaseParent, 2, 12, 68, BytesHelper.ShortToBytes(gkBase.GKDescriptorNo));
				if (sendResult.HasError || sendResult.Bytes.Count != 68)
				{
					gkBase.InternalState.ZeroHoldDelayCount = 10;
					ConnectionChanged(false);
					return false;
				}
			}

			ConnectionChanged(true);
			var descriptorStateHelper = new DescriptorStateHelper();
			descriptorStateHelper.Parse(sendResult.Bytes, gkBase);

			gkBase.InternalState.OnDelay = descriptorStateHelper.OnDelay;
			gkBase.InternalState.HoldDelay = descriptorStateHelper.HoldDelay;
			gkBase.InternalState.OffDelay = descriptorStateHelper.OffDelay;
			gkBase.InternalState.RunningTime = descriptorStateHelper.RunningTime;
			return true;
		}