61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using static LibrarySDR.Helpers.BinaryHexHelper;
|
|||
|
|
|||
|
namespace LibrarySDR.Flags
|
|||
|
{
|
|||
|
public class DataFlag
|
|||
|
{
|
|||
|
|
|||
|
private bool isConsumedConfirmationRequested;
|
|||
|
public bool IsConsumedConfirmationRequested { get { return isConsumedConfirmationRequested; } }
|
|||
|
|
|||
|
private bool isReceivedConfirmationRequested;
|
|||
|
public bool IsReceivedConfirmationRequested { get { return isReceivedConfirmationRequested; } }
|
|||
|
|
|||
|
private bool isStorageAllowed;
|
|||
|
public bool IsStorageAllowed { get { return isStorageAllowed; } }
|
|||
|
|
|||
|
|
|||
|
private bool isIndividualServiceOnly;
|
|||
|
public bool IsIndividualServiceOnly { get { return isIndividualServiceOnly; } }
|
|||
|
|
|||
|
private bool isOnlyStandardReportAllowed;
|
|||
|
public bool IsOnlyStandardReportAllowed { get { return isOnlyStandardReportAllowed; } }
|
|||
|
|
|||
|
public bool IsUseOfShortFormReportRecommended { get { return !isOnlyStandardReportAllowed; } }
|
|||
|
|
|||
|
public DataFlag(int flags)
|
|||
|
{
|
|||
|
int i = 0;
|
|||
|
Int16 output = 0;
|
|||
|
// first bit is 7 , and the last one is 0
|
|||
|
String binary = GetBits(flags, 8);
|
|||
|
Int16.TryParse(binary.Substring(i++, 1), out output);
|
|||
|
isConsumedConfirmationRequested = output == 1;
|
|||
|
|
|||
|
Int16.TryParse(binary.Substring(i++, 1), out output);
|
|||
|
isReceivedConfirmationRequested = output == 1;
|
|||
|
|
|||
|
bool Data_Ind = false;
|
|||
|
bool Data_Req = true;
|
|||
|
bool resp = false;
|
|||
|
if (Data_Ind)
|
|||
|
{
|
|||
|
Boolean.TryParse(binary.Substring(i++, 1), out resp);
|
|||
|
isIndividualServiceOnly = !resp; // 0 - Data-Ind: Individual service | 1 - Group or individual service
|
|||
|
}
|
|||
|
else if (Data_Req)
|
|||
|
Boolean.TryParse(binary.Substring(i++, 1), out isOnlyStandardReportAllowed);
|
|||
|
|
|||
|
|
|||
|
Boolean.TryParse(binary.Substring(i++, 1), out isStorageAllowed);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|