public UnconfirmedTextMessageRequest(ObjectIdentifier textMessageSourceDevice, MessagePriority messagePriority, CharacterString message) { this.textMessageSourceDevice = textMessageSourceDevice; this.messagePriority = messagePriority; this.message = message; }
public void MultipleCharacterStrings() { int endOffset = 0; byte[] content = Helper.ReadFixture("CharacterString", "www.google.com-string"); IList <CharacterString> characterStrings = CharacterString.GetAllFromArray(content, 0, out endOffset); Assert.Equal(3, characterStrings.Count); Assert.Equal(15, endOffset); CharacterString characterString = characterStrings[0]; Assert.Equal("www", characterString.ToString()); Assert.Equal(4, characterString.Size); characterString = characterStrings[1]; Assert.Equal("google", characterString.ToString()); Assert.Equal(7, characterString.Size); characterString = characterStrings[2]; Assert.Equal("com", characterString.ToString()); Assert.Equal(4, characterString.Size); }
public UnconfirmedTextMessageRequest(ObjectIdentifier textMessageSourceDevice, UnsignedInteger messageClass, MessagePriority messagePriority, CharacterString message) { this.textMessageSourceDevice = textMessageSourceDevice; this.messageClass = new Choice(0, messageClass); this.messagePriority = messagePriority; this.message = message; }
public void CharacterStringFromLongString() { var result = CharacterString.FromString(new string('a', 512)); Assert.Equal(3, result.Count); Assert.Equal(new [] { 256, 256, 3 }, result.Select(x => x.Size)); Assert.Equal(new [] { 255, 255, 2 }, result.Select(x => (int)x.ToArray()[0])); }
public void EmptyCharacterString() { CharacterString characterString = new CharacterString(new byte[0]); byte[] content = Helper.ReadFixture("CharacterString", "empty-string"); Assert.Equal(content, characterString.ToArray()); Assert.Equal("", characterString.ToString()); }
public void CharacterStringWithWrongLengthUnder() { var fixture = new byte[] { 0x01, (byte)'f', (byte)'o' }; var result = CharacterString.FromArray(fixture, 0, out var endOffset); Assert.Equal(2, result.Size); Assert.Equal("f", result.ToString()); Assert.Equal(2, endOffset); }
public void SimpleCharacterString() { CharacterString characterString = new CharacterString("www"); byte[] content = Helper.ReadFixture("CharacterString", "www-string"); Assert.Equal(content, characterString.ToArray()); Assert.Equal("www", characterString.ToString()); }
UnconfirmedTextMessageRequest(ByteStream queue) { textMessageSourceDevice = (ObjectIdentifier)read(queue, typeof(ObjectIdentifier), 0); if (readStart(queue) == 1) { messageClass = new Choice(queue, classes); } messagePriority = (MessagePriority)read(queue, typeof(MessagePriority), 2); message = (CharacterString)read(queue, typeof(CharacterString), 3); }
public void EmptyCharacterString() { int endOffset = 0; byte[] content = Helper.ReadFixture("CharacterString", "empty-string"); CharacterString characterString = CharacterString.FromArray(content, 0, out endOffset); Assert.Equal("", characterString.ToString()); Assert.Equal(1, characterString.Size); Assert.Equal(1, endOffset); }
public void SimpleCharacterString() { int endOffset = 0; byte[] content = Helper.ReadFixture("CharacterString", "www-string"); CharacterString characterString = CharacterString.FromArray(content, 0, out endOffset); Assert.Equal("www", characterString.ToString()); Assert.Equal(4, characterString.Size); Assert.Equal(4, endOffset); }
public void CharacterStringFromSimpleString() { var result = CharacterString.FromString("www"); Assert.Equal(1, result.Count); var characterString = result.First(); Assert.Equal("www", characterString.ToString()); Assert.Equal(4, characterString.Size); }
public Task <IResponse> Resolve(IRequest request, CancellationToken cancellationToken = new CancellationToken()) { IResponse response = Response.FromRequest(request); foreach (var question in response.Questions) { if (!question.Name.ToString().EndsWith(_dnsSuffix)) { continue; } var query = question.Name.ToString().Replace(_dnsSuffix, string.Empty); var responseItem = Search(query, question.Type); if (responseItem == null) { continue; } switch (question.Type) { case RecordType.A: case RecordType.AAAA: _logger.LogInformation($"A/AAAA response: {responseItem.Result}"); response.AnswerRecords.Add(new IPAddressResourceRecord(question.Name, responseItem.Result)); break; case RecordType.TXT: var txtResponse = responseItem.RblMessage ?? $"Blocked by {responseItem.Rbl}"; _logger.LogInformation($"TXT response: {txtResponse}"); response.AnswerRecords.Add(new TextResourceRecord(question.Name, CharacterString.FromString(txtResponse))); break; default: response.ResponseCode = ResponseCode.Refused; break; } } if (!response.AnswerRecords.Any()) { _logger.LogInformation("No matches found"); response.ResponseCode = ResponseCode.NameError; } return(Task.FromResult(response)); }
public CharacterString returnCharID(string ID) { CharacterString retVal = null; for (int i = 0; i < characterList.Count; i++) { if (string.Equals(characterList[i].charId, ID)) { retVal = characterList[i]; break; } } return(retVal); }
internal UnconfirmedEventNotificationRequest(ByteStream queue) { processIdentifier = (UnsignedInteger)read(queue, typeof(UnsignedInteger), 0); initiatingDeviceIdentifier = (ObjectIdentifier)read(queue, typeof(ObjectIdentifier), 1); eventObjectIdentifier = (ObjectIdentifier)read(queue, typeof(ObjectIdentifier), 2); timeStamp = (TimeStamp)read(queue, typeof(TimeStamp), 3); notificationClass = (UnsignedInteger)read(queue, typeof(UnsignedInteger), 4); priority = (UnsignedInteger)read(queue, typeof(UnsignedInteger), 5); eventType = (EventType)read(queue, typeof(EventType), 6); messageText = (CharacterString)readOptional(queue, typeof(CharacterString), 7); notifyType = (NotifyType)read(queue, typeof(NotifyType), 8); ackRequired = (BBoolean)readOptional(queue, typeof(BBoolean), 9); fromState = (EventState)readOptional(queue, typeof(EventState), 10); toState = (EventState)read(queue, typeof(EventState), 11); eventValues = NotificationParameters.createNotificationParametersOptional(queue, 12); }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); Monster monster = mThing as Monster; if (monster != null) { // draw the object terminal.Write(GameArt.Get(monster)); // draw its name terminal[2, 0].Write(monster.NounText); // draw its health if alive if (monster.Health.Current > 0) { for (int i = 0; i < 10; i++) { if (monster.Health.Current * 10 / monster.Health.Max >= i) { terminal[-10 + i, 0][TermColor.DarkRed].Write(Glyph.Solid); } else { terminal[-10 + i, 0][TermColor.DarkGray].Write(Glyph.Gray); } } } // draw its description CharacterString text = new CharacterString(monster.GetDescription(mHero), TermColor.LightGray, TermColor.Black); int y = 1; foreach (CharacterString line in text.WordWrap(terminal.Size.X)) { // bail if we run out of room if (y >= terminal.Size.Y) { break; } terminal[0, y++].Write(line); } } }
private readonly NotificationParameters eventValues; // 12 optional public UnconfirmedEventNotificationRequest(UnsignedInteger processIdentifier, ObjectIdentifier initiatingDeviceIdentifier, ObjectIdentifier eventObjectIdentifier, TimeStamp timeStamp, UnsignedInteger notificationClass, UnsignedInteger priority, EventType eventType, CharacterString messageText, NotifyType notifyType, BBoolean ackRequired, EventState fromState, EventState toState, NotificationParameters eventValues) { this.processIdentifier = processIdentifier; this.initiatingDeviceIdentifier = initiatingDeviceIdentifier; this.eventObjectIdentifier = eventObjectIdentifier; this.timeStamp = timeStamp; this.notificationClass = notificationClass; this.priority = priority; this.eventType = eventType; this.messageText = messageText; this.notifyType = notifyType; this.ackRequired = ackRequired; this.fromState = fromState; this.toState = toState; this.eventValues = eventValues; }
public SequencingInteractionActivityDefinition TestValidInit() { var sequence = new CharacterString(new List <string> { "tim", "mike", "ells", "ben", }); var choices = new List <IInteractionComponent> { new InteractionComponent("tim", LanguageMap.EnglishUS("Tim")), new InteractionComponent("ben", LanguageMap.EnglishUS("Ben")), new InteractionComponent("ells", LanguageMap.EnglishUS("Ells")), new InteractionComponent("mike", LanguageMap.EnglishUS("Mike")), }; var def1 = new SequencingInteractionActivityDefinition( new ResponsePattern(sequence), choices, LanguageMap.EnglishUS("Appendix C"), LanguageMap.EnglishUS("Order players by their pong ladder position:")); var def2 = new SequencingInteractionActivityDefinition( new ResponsePattern(sequence), choices, LanguageMap.EnglishUS("Appendix C"), LanguageMap.EnglishUS("Order players by their pong ladder position:"), new Uri("http://example.com/more")); return(new SequencingInteractionActivityDefinition( new ResponsePattern(sequence), choices, LanguageMap.EnglishUS("Appendix C"), LanguageMap.EnglishUS("Order players by their pong ladder position:"), new Uri("http://example.com/more"), new Dictionary <Uri, object> { { new Uri("http://example.com/ext"), "ext" } })); }
void InitBacnetDictionary() { uint deviceId; if (UInt32.TryParse(BacnetDeviceId, out deviceId) == false) { deviceId = 12345; // default value } device = new DeviceObject(deviceId, "Weather2 to Bacnet ", "Weather2 data", false); if ((UserAccessKey != null) && (Latitude != null) && (Longitude != null)) { Temp = new AnalogInput <float> ( 0, "Temperature", "Temperature", 0, BacnetUnitsId.UNITS_DEGREES_CELSIUS ); // 24h trendlog TrendTemp = new TrendLog(0, "Temperature Trend", "Temperature Trend", 6 * 24, BacnetTrendLogValueType.TL_TYPE_SIGN); Windspeed = new AnalogInput <float> ( 1, "Windspeed", "Wind speed", 0, BacnetUnitsId.UNITS_KILOMETERS_PER_HOUR ); Humidity = new AnalogInput <float> ( 2, "Humidity", "Humidity", 0, BacnetUnitsId.UNITS_PERCENT ); Pressure = new AnalogInput <float> ( 3, "Pressure", "Pressure", 0, BacnetUnitsId.UNITS_HECTOPASCALS ); DewPoint = new AnalogInput <float> ( 4, "DewPoint", "Dew Point", 0, BacnetUnitsId.UNITS_DEGREES_CELSIUS ); VaporPressure = new AnalogInput <float> ( 5, "VaporPressure", "Equilibrium Vapor Pressure", 0, BacnetUnitsId.UNITS_HECTOPASCALS ); Windsdir = new CharacterString (0, "Winddir", "Wind Direction", "Not available", false); WeatherDescr = new CharacterString (1, "WeatherDescr", "Weather Description", "Not available", false); SunRise = new BacnetDateTime(0, "Sunrise", "Sun up time"); SunSet = new BacnetDateTime(1, "Sunset", "Sun down time"); Updatetime = new BacnetDateTime(2, "Updatetime", "Date & Time of the current values"); NextUpdatetime = new BacnetDateTime(3, "NextUpdatetime", "Date & Time of the next request"); device.AddBacnetObject(Temp); device.AddBacnetObject(TrendTemp); device.AddBacnetObject(Windspeed); device.AddBacnetObject(Humidity); device.AddBacnetObject(Pressure); device.AddBacnetObject(DewPoint); device.AddBacnetObject(VaporPressure); device.AddBacnetObject(Windsdir); device.AddBacnetObject(WeatherDescr); device.AddBacnetObject(SunRise); device.AddBacnetObject(SunSet); device.AddBacnetObject(Updatetime); device.AddBacnetObject(NextUpdatetime); device.AddBacnetObject(new NotificationClass(0, "Notification", "Notification")); } else { device.m_PROP_SYSTEM_STATUS = BacnetDeviceStatus.NON_OPERATIONAL; } // Force the JIT compiler to make some job before network access device.Cli2Native(); BacnetActivity.StartActivity(device); }
private static IList <CharacterString> FormatAttributeNameValue(string attributeName, string attributeValue) { return(CharacterString.FromString($"{Escape(attributeName)}={attributeValue}")); }
public TextResourceRecord(IResourceRecord record) : base(record) { TextData = CharacterString.GetAllFromArray(Data, 0); }
public TextResourceRecord(IResourceRecord record, byte[] message, int dataOffset) : base(record) { TextData = CharacterString.GetAllFromArray(message, dataOffset); }
public void CharacterStringConstructorTest() { CharacterStringTypes type = new CharacterStringTypes(); // TODO: Initialize to an appropriate value CharacterString target = new CharacterString(type); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void CharacterStringWithWrongOffset() { var fixture = new byte[] { 0x03, (byte)'f', (byte)'o', (byte)'o' }; Assert.Throws <IndexOutOfRangeException>(() => CharacterString.FromArray(fixture, 4)); }
public void CharacterStringWithWrongLengthOver() { var fixture = new byte[] { 0x03, (byte)'f', (byte)'o' }; Assert.Throws <ArgumentException>(() => CharacterString.FromArray(fixture, 0)); }
public void CharacterStringWithEmptyData() { var fixture = new byte[] {}; Assert.Throws <ArgumentException>(() => CharacterString.FromArray(fixture, 0)); }
public IHaveRequest(ByteStream queue) { deviceIdentifier = (ObjectIdentifier)read(queue, typeof(ObjectIdentifier)); objectIdentifier = (ObjectIdentifier)read(queue, typeof(ObjectIdentifier)); objectName = (CharacterString)read(queue, typeof(CharacterString)); }
public IHaveRequest(ObjectIdentifier deviceIdentifier, ObjectIdentifier objectIdentifier, CharacterString objectName) { this.deviceIdentifier = deviceIdentifier; this.objectIdentifier = objectIdentifier; this.objectName = objectName; }
public WhoHasRequest(Limits limits, CharacterString name) { this.limits = limits; @object = new Choice(3, name); }
public void CharacterStringFromEmptyString() { var result = CharacterString.FromString(""); Assert.Empty(result); }