//Chris Han add DeviceId to Json
        public async Task<DataSet> Process(DataSet dataset, CancellationToken ct, string DeviceId)
        {
#if AggravatedSerialization
            //Serialize the whole dataset as single json string
            var json = await Task.Factory.StartNew(
                new Func<object, string>(JsonConvert.SerializeObject),
                dataset,
                ct);

            var data = new Data();
            data.Add("stringContent", json);

            var output = new DataSet();
            output.Add(data);
            return output;

#else
            //Serialize each data as one json string
            foreach (var data in dataset)
            {
                data["DeviceId"] = DeviceId;//Chris han add DeviceId to Json
                var json = await Task.Factory.StartNew(
                    new Func<object, string>(JsonConvert.SerializeObject),
                    data,
                    ct);

                data.Add("stringContent", json);
            }

            return dataset;
#endif
        }
        public override Data Read()
        {
            _t += _delta;

            var output = new Data();
            output.Add("Temp", (Math.Sin(_t) * _k + _b) * _rand.Next(Fluctuating));
            output.Add("Volt", 200 + 20 * _rand.Next(Fluctuating)); //200 +- 20 V
            return output;
        }
 public override Data Read()
 {
     var output = new Data();
     output.Add("voltdrop", _rand.Next(VoltdropBoundary));
     output.Add("powerdraw", _rand.Next(PowerdrawBoundary));
     output.Add("dutycycle", _rand.Next(DutycycleBoundary));
     output.Add("vibration", _rand.Next(VibrationBoundary));
     output.Add("temperature", _rand.Next(TemperaturBoundary));
     return output;
 }
Example #4
0
        public Data Sample(int n)
        {
            var data = new Data();

            var currentVector = parameters.Current; 
            var currentProbability = probability(currentVector); 

            for(int i=0; i<n; i++)
            {
                var proposedVector = parameters.ProposeNewVector();
                var proposedProbability = probability(proposedVector);

                var pMove = Min(1.0, proposedProbability / currentProbability);
                var shouldMove = rng.RandomNumber() < pMove; 

                if(shouldMove)
                {
                    currentVector = parameters.UpdateToProposedValue();
                    currentProbability = probability(currentVector); 
                }

                data.Add(currentVector); 
            }

            return data; 
        }
        public async Task<DataSet> Read(CancellationToken ct)
        {
            var output = new DataSet();

            using (var stream = new MemoryStream())
            {
                while (true)
                {
                    var status = await _transport.ReceiveCommand(stream, ct);
                    if (status != HttpStatusCode.OK)
                    {
                        break;
                    }

                    var data = new Data();
                    data.Add("bytesContent", stream.ToArray());

                    output.Add(data);
                }
            }

            return output;
        }
Example #6
0
 public OrderedHashTree(Object key) : this()
 {
     Data.Add(key, new OrderedHashTree());
     order.Add(key);
 }
Example #7
0
 public Data ToData()
 {
     Data result = new Data ();
     result.Add ("id", this._id);
     result.Add ("createtimestamp", this._createtimestamp);
     result.Add ("updatetimestamp", this._updatetimestamp);
     return result;
 }
Example #8
0
 protected void SetLineNumber(int lineNumber, int linePosition)
 {
     Data.Add("LineNumber", lineNumber);
     Data.Add("LinePosition", linePosition);
 }
Example #9
0
 public BadRequestException(string message, object data) : base(message)
 {
     Data.Add("Data", data);
 }
Example #10
0
 public AuthenticationError(string message) : base(message)
 {
     Code = "UNAUTHENTICATED";
     Data.Add(Constants.ExecutionErrorStatusCode, StatusCodes.Status401Unauthorized);
 }
Example #11
0
 public InvalidValuesException(IProcess process, IReadOnlySlimRow row)
     : base(process, "invalid values found")
 {
     Data.Add("Row", row.ToDebugString(true));
 }
Example #12
0
 public BaseException()
 {
     Data.Add("Type", GetType().ToString());
 }
 public StartupFailedException(StartupFailReason sfr)
 {
     Data.Add("StartupFailReason", sfr);
 }
 public StartupFailedException(Exception innerException, StartupFailReason sfr) :
     base(sfr.ToString(), innerException)
 {
     Data.Add("StartupFailReason", sfr);
 }
Example #15
0
 public InvalidWithDrawalException(string reason)
     : base($"Withdrawal is not valid: {reason}")
 {
     Data.Add(nameof(reason), reason);
 }
Example #16
0
 public ProcessExecutionException(IProcess process, IReadOnlySlimRow row, string message, Exception innerException)
     : base(process, message, innerException)
 {
     Data.Add("Row", row.ToDebugString(true));
 }
Example #17
0
        protected override void Init()
        {
            SetMode((Mode)0);
            Size = new Vector2 {
                X = 840, Y = 630
            };

            Titles = new Dictionary <Items, FF8String> {
                { Items.Junction, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 217) },
                { Items.Off, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 219) },
                { Items.Auto, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 221) },
                { Items.Ability, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 223) },
                { Items.HP, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 225) },
                { Items.Str, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 227) },
                { Items.Vit, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 229) },
                { Items.Mag, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 231) },
                { Items.Spr, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 233) },
                { Items.Spd, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 235) },
                { Items.Luck, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 237) },
                { Items.Hit, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 239) },
                { Items.ST_A, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 243) },
                { Items.ST_D, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 245) },
                { Items.EL_A, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 247) },
                { Items.EL_D, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 249) },
                { Items.ST_A_D, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 251) },
                { Items.EL_A_D, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 253) },
                { Items.Stats, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 255) },
                { Items.ST_A2, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 257) },
                { Items.GF, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 262) },
                { Items.Magic, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 264) },
                { Items.AutoAtk, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 269) },
                { Items.AutoMag, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 271) },
                { Items.AutoDef, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 273) },
                { Items.RemAll, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 275) },
                { Items.RemMag, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 277) },
            };

            Misc = new Dictionary <Items, FF8String> {
                { Items.CurrentEXP, Memory.Strings.Read(Strings.FileID.MNGRP, 0, 23) },
                { Items.NextLEVEL, Memory.Strings.Read(Strings.FileID.MNGRP, 0, 24) },
                { Items._, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 266) },
                { Items.HP, Memory.Strings.Read(Strings.FileID.MNGRP, 0, 26) },
                { Items.LV, Memory.Strings.Read(Strings.FileID.MNGRP, 0, 27) },
                { Items.ForwardSlash, Memory.Strings.Read(Strings.FileID.MNGRP, 0, 25) },
                { Items.Percent, Memory.Strings.Read(Strings.FileID.MNGRP, 0, 29) },
            };

            Descriptions = new Dictionary <Items, FF8String> {
                { Items.Junction, Memory.Strings.Read(Strings.FileID.MNGRP, 2, 218) }
            };
            Data.Add(SectionName.CharacterInfo, new IGMData_CharacterInfo());
            Data.Add(SectionName.Commands, new IGMData_Commands(new Rectangle(615, 150, 210, 192)));
            Data.Add(SectionName.Help, new IGMData_Help());
            Data.Add(SectionName.TopMenu, new IGMData_TopMenu());
            Data.Add(SectionName.Title, new IGMData_Container(
                         new IGMDataItem_Box(Titles[Items.Junction], pos: new Rectangle(615, 0, 225, 66))));
            Data.Add(SectionName.Mag_Group, new IGMData_Mag_Group(
                         new IGMData_Mag_Stat_Slots(),
                         new IGMData_Mag_PageTitle(),
                         new IGMData_Mag_Pool(),
                         new IGMData_Mag_EL_A_D_Slots(),
                         new IGMData_Mag_EL_A_Values(),
                         new IGMData_Mag_EL_D_Values(),
                         new IGMData_Mag_ST_A_D_Slots(),
                         new IGMData_Mag_ST_A_Values(),
                         new IGMData_Mag_ST_D_Values()
                         ));
            Data.Add(SectionName.TopMenu_Junction, new IGMData_TopMenu_Junction());
            Data.Add(SectionName.TopMenu_Off, new IGMData_TopMenu_Off_Group(
                         new IGMData_Container(
                             new IGMDataItem_Box(Titles[Items.Off], pos: new Rectangle(0, 12, 169, 54), options: Box_Options.Center | Box_Options.Middle)),
                         new IGMData_TopMenu_Off()
                         ));
            Data.Add(SectionName.TopMenu_Auto, new IGMData_TopMenu_Auto_Group(
                         new IGMData_Container(
                             new IGMDataItem_Box(Titles[Items.Auto], pos: new Rectangle(0, 12, 169, 54), options: Box_Options.Center | Box_Options.Middle)),
                         new IGMData_TopMenu_Auto()));
            Data.Add(SectionName.TopMenu_Abilities, new IGMData_Abilities_Group(
                         new IGMData_Abilities_CommandSlots(),
                         new IGMData_Abilities_AbilitySlots(),
                         new IGMData_Abilities_CommandPool(),
                         new IGMData_Abilities_AbilityPool()
                         ));
            FF8String Yes = Memory.Strings.Read(Strings.FileID.MNGRP, 0, 57);
            FF8String No  = Memory.Strings.Read(Strings.FileID.MNGRP, 0, 58);

            Data.Add(SectionName.TopMenu_GF_Group, new IGMData_GF_Group(
                         new IGMData_GF_Junctioned(),
                         new IGMData_GF_Pool(),
                         new IGMData_Container(new IGMDataItem_Box(pos: new Rectangle(440, 345, 385, 66)))
                         ));

            Data.Add(SectionName.RemMag, new IGMData_ConfirmRemMag(data: Memory.Strings.Read(Strings.FileID.MNGRP, 2, 280), title: Icons.ID.NOTICE, opt1: Yes, opt2: No, pos: new Rectangle(180, 174, 477, 216)));
            Data.Add(SectionName.RemAll, new IGMData_ConfirmRemAll(data: Memory.Strings.Read(Strings.FileID.MNGRP, 2, 279), title: Icons.ID.NOTICE, opt1: Yes, opt2: No, pos: new Rectangle(170, 174, 583, 216)));
            Data.Add(SectionName.ConfirmChanges, new IGMData_ConfirmChanges(data: Memory.Strings.Read(Strings.FileID.MNGRP, 0, 73), title: Icons.ID.NOTICE, opt1: Yes, opt2: Memory.Strings.Read(Strings.FileID.MNGRP, 2, 268), pos: new Rectangle(280, 174, 367, 216)));

            base.Init();
        }
 public ErrorResponseModel(string key, string message) : this()
 {
     Data.Add(new ErrorModel(key, message));
 }
Example #19
0
 public PmxFormatException(byte[] got, byte[] expected) : this(string.Format("Value could not be parsed. Expected {0} ({2} bytes), got {1} ({3} bytes).", BitConverter.ToString(expected), BitConverter.ToString(got), expected.Length, got.Length))
 {
     Data.Add("ValueExpected", expected);
     Data.Add("ValueGot", got);
 }
Example #20
0
 /// <summary>
 /// Add a new key and value pair.
 /// </summary>
 /// <param name="key">The configuration key.</param>
 /// <param name="value">The configuration value.</param>
 public void Add(string key, string value)
 {
     Data.Add(key, value);
 }
Example #21
0
 /// <summary>
 /// Write a boolean value.
 /// </summary>
 /// <param name="v">The value to write</param>
 public void Write(bool v)
 {
     Data.Add((byte)(v ? 1 : 0));
 }
Example #22
0
        public override string ParseDAT(string[] filePath)
        {
            foreach (var s in filePath)
            {
                try
                {
                    xmls.Add(XDocument.Load(s));
                }
                catch
                {
                    var res = MessageBox.Show("Could not parse document as valid XML:\n\n" + s + "\n\nDo you wish to continue any other processing?", "Parsing Error", MessageBoxButtons.YesNo);
                    if (res != DialogResult.Yes)
                    {
                        return("");
                    }
                }
            }

            int startIndex = 0;

            // actual tosec parsing
            foreach (var obj in xmls)
            {
                startIndex = Data.Count > 0 ? Data.Count - 1 : 0;
                // get header info
                var header      = obj.Root.Descendants("header").First();
                var category    = header.Element("category").Value;
                var name        = header.Element("name").Value;
                var version     = header.Element("version").Value;
                var description = header.Element("description").Value;

                // start comment block
                List <string> comments = new List <string>
                {
                    $"Type:\t{category}",
                    $"Source:\t{description}",
                    $"FileGen:\t{DateTime.UtcNow:yyyy-MM-dd HH:mm:ss} (UTC)",
                };

                AddCommentBlock(comments.ToArray());

                // process each entry
                var query = obj.Root.Descendants("game");
                foreach (var g in query)
                {
                    GameDB item = new GameDB();
                    item.Name   = g.Value;
                    item.SHA1   = g.Elements("rom").First().Attribute("sha1").Value.ToUpper();
                    item.MD5    = g.Elements("rom").First().Attribute("md5").Value.ToUpper();
                    item.System = GameDB.GetSystemCode(SysType);

                    ParseTOSECFlags(item);

                    Data.Add(item);
                }

                // add this file's data to the stringbuilder
                // first we will sort into various ROMSTATUS groups
                var working = Data.Skip(startIndex).ToList();

                var baddump = working.Where(st => st.Status == "B").OrderBy(na => na.Name).ToList();
                AddCommentBlock("Bad Dumps");
                AppendCSVData(baddump);

                var hack = working.Where(st => st.Status == "H").OrderBy(na => na.Name).ToList();
                AddCommentBlock("Hacks");
                AppendCSVData(hack);

                var over = working.Where(st => st.Status == "O").OrderBy(na => na.Name).ToList();
                AddCommentBlock("Over Dumps");
                AppendCSVData(over);

                var trans = working.Where(st => st.Status == "T").OrderBy(na => na.Name).ToList();
                AddCommentBlock("Translated");
                AppendCSVData(trans);

                var pd = working.Where(st => st.Status == "D").OrderBy(na => na.Name).ToList();
                AddCommentBlock("Home Brew");
                AppendCSVData(pd);

                var good = working.Where(st => st.Status == "" || st.Status == null).OrderBy(na => na.Name).ToList();
                AddCommentBlock("Believed Good");
                AppendCSVData(good);
            }

            string result = sb.ToString();

            return(sb.ToString());
        }
Example #23
0
 /// <summary>
 /// Write an unsigned byte value.
 /// </summary>
 /// <param name="v">The value to write</param>
 public void Write(byte v)
 {
     Data.Add(v);
 }
Example #24
0
 public BaseException(int code, string msg) : base(msg)
 {
     Data.Add("Code", code);
     Data.Add("Type", GetType().ToString());
 }
Example #25
0
 public KeyGeneratorException(IProcess process, IReadOnlySlimRow row, Exception innerException)
     : base(process, "error during generating key for a row", innerException)
 {
     Data.Add("Row", row.ToDebugString(true));
 }
Example #26
0
 public BaseException(string msg) : base(msg)
 {
     Data.Add("Type", GetType().ToString());
 }
Example #27
0
 public Data ToData()
 {
     Data result = new Data ();
     result.Add ("id", this._id);
     result.Add ("createtimestamp", this._createtimestamp);
     result.Add ("updatetimestamp", this._updatetimestamp);
     result.Add ("name", this._name);
     result.Add ("ownerid", this._ownerid);
     result.Add ("data", this._data);
     return result;
 }
 internal LocalFileReadException(IProcess process, string message, string fileName)
     : base(process, message)
 {
     Data.Add("FileName", fileName);
 }
Example #29
0
 public void Add(TAggregateRoot aggregateRoot)
 => Data.Add(aggregateRoot);
Example #30
0
 public ProcessExecutionException(IProcess process, IReadOnlySlimRow row, Exception innerException)
     : this(process, "error raised during the execution of a process", innerException)
 {
     Data.Add("Row", row.ToDebugString(true));
 }
Example #31
0
 public void Update(TAggregateRoot aggregateRoot)
 {
     Data.RemoveAll(s => s.Id.Equals(aggregateRoot.Id));
     Data.Add(aggregateRoot);
 }
Example #32
0
 /// <inheritdoc />
 public UnableToGetQueueException(string name, AccessMode accessMode) : base($"Unable to Get Queue Exception ({name})")
 {
     Data.Add(nameof(name), name);
     Data.Add(nameof(accessMode), accessMode);
 }
Example #33
0
 /// <summary>
 /// Set an item in the exception's dictionary with the "Message" key. That
 /// item may be exposed to clients, so it should not contain any sensitive
 /// information.
 /// </summary>
 protected void SetSafeMessage(string message)
 {
     Data.Add("Message", message);
 }
Example #34
0
        /// <summary>
        /// Convert <see cref="SorentoLib.User"/> to <see cref="SorentoLib.Data"/>.
        /// </summary>
        private Data ToData(bool Internal)
        {
            Data result = new Data ();
            result.Add ("id", this._id);
            result.Add ("createtimestamp", this._createtimestamp);
            result.Add ("updatetimestamp", this._updatetimestamp);
            result.Add ("usergroupids", this._usergroupids);
            result.Add ("username", this._username);
            result.Add ("realname", this._realname);
            result.Add ("email", this._email);

            if (Internal)
                result.Add ("password", this._password);

            result.Add ("status", SNDK.Convert.EnumToString (this._status));

            return result;
        }
Example #35
0
 public Task <TAggregateRoot> AddAndReturnAsync(TAggregateRoot aggregateRoot, bool autoExecute = true, CancellationToken cancellationToken = default)
 {
     Data.Add(aggregateRoot);
     return(Task.FromResult(aggregateRoot));
 }
 public DuplicateKeyException(IProcess process, IReadOnlySlimRow row, string key)
     : base(process, "duplicate keys found")
 {
     Data.Add("Key", key);
     Data.Add("Row", row.ToDebugString(true));
 }
Example #37
0
 public Task AddAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken = default)
 {
     Data.Add(aggregateRoot);
     return(Task.CompletedTask);
 }
Example #38
0
 public MatchActionDelegateException(IProcess process, IReadOnlySlimRow row, Exception innerException)
     : base(process, "error during the execution of a " + nameof(MatchAction) + "." + nameof(MatchAction.CustomAction) + " delegate", innerException)
 {
     Data.Add("Row", row.ToDebugString(true));
 }
        public override Data Read()
        {
            double value = _temperature;

            if (_up)
            {
                double delta = _temperature * _multiplier;
                _temperature += delta;
                _multiplier /= UpDecayMult;

                //Turn on "cooling" if over-heat and "cooling failure" was not raised
                if (++_runningSteps >= _stepThreshold || _temperature >= Boundary.Max)
                {
                    _up = false;
                }
            }
            else
            {
                double delta = _temperature * DownDecayMult;
                _temperature -= delta;
                if (_temperature <= Boundary.Min)
                {
                    _temperature = Boundary.Min;

                    //Turn off "cooling" if fully cool-down after waiting for a random period
                    if (_rand.TestProb(HeatingProb))
                    {
                        _up = true;
                        _temperature = Boundary.Min * (1 + InitMult);
                        _multiplier = InitMult * UpDecayMult;
                        _runningSteps = 0;
                        _stepThreshold = _rand.TestProb(CoolingFailureProb) ? int.MaxValue : StepsThreshold;
                    }
                }
            }

            var output = new Data();

            if (_rand.TestProb(SensorFailureProb))
            {
                output.Add("Anomaly", true);
                output.Add("Temperature", _rand.Next(SensorFailureBoundary));
            }
            else
            {
                output.Add("Anomaly", _stepThreshold == int.MaxValue && _temperature > Boundary.Min);
                output.Add("Temperature", value * _rand.Next(Fluctuating));
            }

            return output;
        }