public MicroInstruction(int address, NextAddress nextAddress, bool enableValue, int value, JumpCriterion jumpCriterion, bool clearInterrupt, bool affected, AluCmd aluCommand, Source source, Destination destination, DataInput dataInput, ReadWrite readWrite) { this.Address = address; this.NextAddress = nextAddress; this.EnableValue = enableValue; this.Value = value; this.JumpCriterion = jumpCriterion; this.ClearInterrupt = clearInterrupt; this.AffectFlags = affected; this.AluCommand = aluCommand; this.Source = source; this.Destination = destination; this.DataInput = dataInput; this.ReadWrite = readWrite; }
public DeleteResource(Resource resource) { this.resource = resource; MessageBoxResult result = MessageBox.Show("Deleting this resource you will delete all resources on maps. Are you sure you want to perform this action?", "Delete resource", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: { Resource resToDelete = null; ResourceTypeWithResources rtwr = null; foreach (ResourceTypeWithResources rt in MainWindow.types) { foreach (Resource res in rt.Resources) { if (res == this.resource) { resToDelete = res; rtwr = rt; break; } } } if (resToDelete != null) { foreach (ResourceTypeWithResources rt in MainWindow.types) { if (rt == rtwr) { rt.Resources.Remove(resToDelete); } } List <ResourcePoint> rpsToDel = new List <ResourcePoint>(); foreach (ResourcePoint rp in MainWindow.resources) { if (rp.resource.Id == resToDelete.Id) { rpsToDel.Add(rp); } } if (rpsToDel.Count > 0) { foreach (var r in rpsToDel) { MainWindow.resources.Remove(r); //MainWindow.removeResourceFromMap(r); } } MainWindow.removeAllResources(); MainWindow.drawResources(); CollectionViewSource.GetDefaultView(MainWindow.types).Refresh(); ReadWrite rw = new ReadWrite(); rw.writeToFile("../../Data/types.json", MainWindow.types); rw.writeToFile("../../Data/resources.json", MainWindow.resources); MessageBox.Show("You have successfully deleted resource called " + resource.Name + "!", "Deleted resource", MessageBoxButton.OK, MessageBoxImage.Information); } break; } case MessageBoxResult.No: break; } }
public string Generate(int ROOM_NUM, int max) { rnd = new System.Random(System.Environment.TickCount); this.max = max; border = new List <Border>(); ah = this.GetComponent <AnaHori>(); //マップ状態初期化 walls = new List <List <StageChip> >(max); for (int i = 0; i < max; i++) { walls.Add(new List <StageChip>(max)); for (int j = 0; j < max; j++) { walls[i].Add(new StageChip(" ", 0)); //walls[i][j].type = " "; } } //スタート地点の取得 startPos = new int[] { (max - 1) / 2, (max - 1) / 2 }; int[] tmp = startPos; //ランダムでx,yを設定 int len = rnd.Next(minSize, maxSize); List <RoomChip> tmp_room = MakeRoom(startPos, 1, len); MakeObst(len, tmp_room); for (int i = 1; i < ROOM_NUM + 1; i++) { len = rnd.Next(minSize, maxSize); startPos = SearchPos(len, i); tmp_room = MakeRoom(startPos, 1, len); MakeObst(len, tmp_room); } walls[tmp[0]][tmp[1]].type = "S"; int[] RemoveRange = CreateRange(3); for (int i = 0; i < walls.Count; i++) { for (int j = 0; j < walls.Count; j++) { if (walls[i][j].type == "b") { for (int h = 0; h < RemoveRange.Length; h++) { for (int w = 0; w < RemoveRange.Length; w++) { if (walls[i + RemoveRange[h]][j + RemoveRange[w]].type == "+") { walls[i + RemoveRange[h]][j + RemoveRange[w]].type = "#"; } } } } } } string StageFile = Application.dataPath + "/" + "Resources" + "/" + "stage3.txt"; ReadWrite.ListWrite(StageFile, walls, max, max); string data = ""; for (int i = 0; i < max; i++) { for (int j = 0; j < max; j++) { data = data + walls[i][j].type; } data = data + "\n"; } return(data); }
public override TemplateObject Handle(TagData data) { data.Shrink(); if (data.Remaining == 0) { return(new TextTag(ToString())); } switch (data[0]) { // <--[tag] // @Name ServerTag.item_assets // @Group Server Information // @ReturnType ListTag // @Returns a list of all item assets in the game. // --> case "item_assets": { List <TemplateObject> items = new List <TemplateObject>(); foreach (ItemAsset it in ItemAssetTag.Items) { items.Add(new ItemAssetTag(it)); } return(new ListTag(items).Handle(data.Shrink())); } // <--[tag] // @Name ServerTag.online_players // @Group Server Information // @ReturnType ListTag // @Returns a list of all online players. // --> case "online_players": { List <TemplateObject> players = new List <TemplateObject>(); foreach (SteamPlayer player in Provider.clients) { players.Add(new PlayerTag(player)); } return(new ListTag(players).Handle(data.Shrink())); } // <--[tag] // @Name ServerTag.offline_players // @Group Server Information // @ReturnType ListTag // @Returns a list of all offline players. // @Other This specifically excludes any online players. // --> case "offline_players": { List <TemplateObject> players = new List <TemplateObject>(); foreach (string playerFolder in ReadWrite.getFolders(ServerSavedata.directory + "/" + Provider.serverID + "/Players")) { string[] split = playerFolder.Substring(playerFolder.LastIndexOf('\\') + 1).Split('_'); if (split.Length == 2) { ulong steamID = Utilities.StringToULong(split[0]); bool online = false; foreach (SteamPlayer onlinePlayer in Provider.clients) { if (onlinePlayer.playerID.steamID.m_SteamID == steamID) { online = true; break; } } if (!online) { OfflinePlayerTag player = OfflinePlayerTag.For(Utilities.StringToULong(split[0]), Utilities.StringToByte(split[1])); if (player != null) { players.Add(player); } } } } return(new ListTag(players).Handle(data.Shrink())); } default: return(new TextTag(ToString()).Handle(data)); } }
private static void GetControlByteValuesV07(byte controlByte, out ReadWrite readWrite, out Source source, out int derefDepth) { derefDepth = 0x0F & controlByte; readWrite = (controlByte >> 7) == 1 ? ReadWrite.Write : ReadWrite.Read; source = (Source)(0b0111_0000 & controlByte); }
static void Main(string[] args) { bool ReloadRequired = false; Enums.ExitCodeEnum ExitReason = Enums.ExitCodeEnum.NoError; SnippitInstal si = ReadWrite.ReadCurrentInstall(); if (si == null) { ExitReason = Enums.ExitCodeEnum.NoInstall; } if (ExitReason <= Enums.ExitCodeEnum.NoError) { if (si.profile == null) { ExitReason = Enums.ExitCodeEnum.NoProfile; } } if (ExitReason <= Enums.ExitCodeEnum.NoError) { var ProfileHashExitReason = WriteProfileHash(si); if (ProfileHashExitReason == Enums.ExitCodeEnum.ReloadRequired) { ReloadRequired = true; ExitReason = Enums.ExitCodeEnum.NoError; } else if (ProfileHashExitReason != Enums.ExitCodeEnum.NoError) { ExitReason = ProfileHashExitReason; } } if (ExitReason <= Enums.ExitCodeEnum.NoError) { var EndCharExitReason = WriteEndChars(si); if (EndCharExitReason == Enums.ExitCodeEnum.ReloadRequired) { ReloadRequired = true; ExitReason = Enums.ExitCodeEnum.NoError; } else if (EndCharExitReason != Enums.ExitCodeEnum.NoError) { ExitReason = EndCharExitReason; } } if (ExitReason <= Enums.ExitCodeEnum.NoError) { var HotStringExitReason = WriteHotStrings(si); if (HotStringExitReason == Enums.ExitCodeEnum.ReloadRequired) { ReloadRequired = true; ExitReason = Enums.ExitCodeEnum.NoError; } else if (HotStringExitReason == Enums.ExitCodeEnum.NoPlugins) { ExitReason = Enums.ExitCodeEnum.NoError; } else if (HotStringExitReason != Enums.ExitCodeEnum.NoError) { ExitReason = HotStringExitReason; } } if (ExitReason <= Enums.ExitCodeEnum.NoError) { var HotKeyExitReason = WriteHotKeys(si); if (HotKeyExitReason == Enums.ExitCodeEnum.ReloadRequired) { ReloadRequired = true; ExitReason = Enums.ExitCodeEnum.NoError; } else if (HotKeyExitReason == Enums.ExitCodeEnum.NoPlugins) { ExitReason = Enums.ExitCodeEnum.NoError; } else if (HotKeyExitReason > Enums.ExitCodeEnum.NoError) { ExitReason = HotKeyExitReason; } } if (ExitReason <= Enums.ExitCodeEnum.NoError) { var IncExitReason = WriteIncludePlugins(si); if (IncExitReason == Enums.ExitCodeEnum.ReloadRequired) { ReloadRequired = true; ExitReason = Enums.ExitCodeEnum.NoError; } else if ((IncExitReason > Enums.ExitCodeEnum.NoError) && (IncExitReason != Enums.ExitCodeEnum.NoPlugins)) { ExitReason = IncExitReason; } } if (ExitReason <= Enums.ExitCodeEnum.NoError) { var DataExitReason = WriteDataFiles(si); if (DataExitReason == Enums.ExitCodeEnum.ReloadRequired) { ReloadRequired = true; ExitReason = Enums.ExitCodeEnum.NoError; } else if ((DataExitReason > Enums.ExitCodeEnum.NoError) && (DataExitReason != Enums.ExitCodeEnum.NoPlugins)) { ExitReason = DataExitReason; } } if (ReloadRequired == true && ExitReason <= Enums.ExitCodeEnum.NoError) { IniHelper.SetWriterExitReason((int)Enums.ExitCodeEnum.ReloadRequired); } else { IniHelper.SetWriterExitReason((int)ExitReason); } Environment.Exit((int)ExitReason); }
private void ImportType_SelectedIndexChanged(object sender, EventArgs e) { if ((string)ImportType.SelectedItem == "Orbital Elements") { Browse.Enabled = false; TCEFile.Enabled = false; SMAValue.Enabled = true; EccValue.Enabled = true; IncValue.Enabled = true; RAANValue.Enabled = true; AoPValue.Enabled = true; TAValue.Enabled = true; NameValue.Enabled = true; MainFilter.Enabled = false; SpecificFilter.Enabled = false; ElementsBox.Visible = true; DatabaseBox.Visible = false; } else if ((string)ImportType.SelectedItem == "TLE/TCE") { Browse.Enabled = true; TCEFile.Enabled = true; SMAValue.Enabled = false; EccValue.Enabled = false; IncValue.Enabled = false; RAANValue.Enabled = false; AoPValue.Enabled = false; TAValue.Enabled = false; NameValue.Enabled = false; MainFilter.Enabled = false; SpecificFilter.Enabled = false; DatabaseBox.Visible = false; ElementsBox.Visible = false; TimeSlip.Enabled = false; TimeSlip.Visible = false; SlipTime.Visible = false; SlipTime.Enabled = false; TimeLabel.Visible = false; } else if ((string)ImportType.SelectedItem == "Satellite Database") { Browse.Enabled = false; TCEFile.Enabled = false; SMAValue.Enabled = false; EccValue.Enabled = false; IncValue.Enabled = false; RAANValue.Enabled = false; AoPValue.Enabled = false; TAValue.Enabled = false; NameValue.Enabled = false; MainFilter.Enabled = true; SpecificFilter.Enabled = true; ElementsBox.Visible = false; DatabaseBox.Visible = true; if (CommonData.SatCatItemList.Count == 0 || CommonData.SatCatItemList == null) { ReadWrite.ReadSatCat(); } PopulateMainFilter(); MainFilter.SelectedIndex = 0; PopulateSpecificFilter(); SpecificFilter.SelectedIndex = 0; PopulateSatelliteList(); } else if ((string)ImportType.SelectedItem == "Ephemeris") { Browse.Enabled = true; TCEFile.Enabled = true; SMAValue.Enabled = false; EccValue.Enabled = false; IncValue.Enabled = false; RAANValue.Enabled = false; AoPValue.Enabled = false; TAValue.Enabled = false; NameValue.Enabled = false; MainFilter.Enabled = false; SpecificFilter.Enabled = false; DatabaseBox.Visible = false; ElementsBox.Visible = false; TimeSlip.Enabled = true; TimeSlip.Visible = true; TimeSlip.Checked = false; SlipTime.Visible = true; SlipTime.Enabled = false; TimeLabel.Visible = true; } }
public static bool Prefix(CSteamID steamID, byte[] packet, int offset, int size, int channel) { if (!Dedicator.isDedicated) { return(true); } byte index1 = packet[offset]; if (!(index1 < (byte)26)) { UnityEngine.Debug.LogWarning((object)("Received invalid packet index from " + (object)steamID + ", so we're refusing them")); SDG.Unturned.Provider.refuseGarbageConnection(steamID, "sv invalid packet index"); } else { ESteamPacket packet1 = (ESteamPacket)index1; if (packet1 == ESteamPacket.AUTHENTICATE || packet1 == ESteamPacket.CONNECT) { Console.WriteLine(packet1); } if (packet1 == ESteamPacket.CONNECT) { RocketPlayer player = new RocketPlayer(steamID.ToString()); bool result = player.HasPermission("QueueBypasser.Skip"); Console.WriteLine(result); if (!result) { return(true); //We don't need to do jack shit because he doesn't have the right permission. } for (int index2 = 0; index2 < SDG.Unturned.Provider.pending.Count; ++index2) { if (SDG.Unturned.Provider.pending[index2].playerID.steamID == steamID) { Console.WriteLine("line 1"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.ALREADY_PENDING); return(true); } } for (int index2 = 0; index2 < SDG.Unturned.Provider.clients.Count; ++index2) { if (SDG.Unturned.Provider.clients[index2].playerID.steamID == steamID) { Console.WriteLine("line 2"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.ALREADY_CONNECTED); return(true); } } object[] objects = SteamPacker.getObjects(steamID, offset, 0, packet, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_TYPE, Types.UINT32_TYPE, Types.BOOLEAN_TYPE, Types.SINGLE_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.BOOLEAN_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_ARRAY_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.UINT32_TYPE); SteamPlayerID newPlayerID = new SteamPlayerID(steamID, (byte)objects[1], (string)objects[2], (string)objects[3], (string)objects[11], (CSteamID)objects[12]); if (objects[8].ToString() != SDG.Unturned.Provider.APP_VERSION && (int)(uint)objects[8] != Parser.getUInt32FromIP(SDG.Unturned.Provider.APP_VERSION)) { Console.WriteLine("line 3"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_VERSION); return(true); } if (newPlayerID.playerName.Length < 2) { Console.WriteLine("line 4"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_SHORT); return(true); } if (newPlayerID.characterName.Length < 2) { Console.WriteLine("line 5"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT); return(true); } if (newPlayerID.playerName.Length > 32) { Console.WriteLine("line 6"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_LONG); return(true); } if (newPlayerID.characterName.Length > 32) { Console.WriteLine("line 7"); //Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_LONG); return(true); } long result1; double result2; if (long.TryParse(newPlayerID.playerName, out result1) || double.TryParse(newPlayerID.playerName, out result2)) { Console.WriteLine("line 8"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER); return(true); } long result3; double result4; if (long.TryParse(newPlayerID.characterName, out result3) || double.TryParse(newPlayerID.characterName, out result4)) { Console.WriteLine("line 9"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER); return(true); } if (SDG.Unturned.Provider.filterName) { if (!NameTool.isValid(newPlayerID.playerName)) { Console.WriteLine("line 10"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return(true); } if (!NameTool.isValid(newPlayerID.characterName)) { Console.WriteLine("line 11"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return(true); } } if (NameTool.containsRichText(newPlayerID.playerName)) { Console.WriteLine("line 12"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return(true); } if (NameTool.containsRichText(newPlayerID.characterName)) { Console.WriteLine("line 13"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return(true); } P2PSessionState_t pConnectionState; uint ip = !SteamGameServerNetworking.GetP2PSessionState(steamID, out pConnectionState) ? 0U : pConnectionState.m_nRemoteIP; SteamBlacklistID blacklistID; if (SteamBlacklist.checkBanned(steamID, ip, out blacklistID)) { //int size1; //byte[] bytes = SteamPacker.getBytes(0, out size1, (object)(byte)9, (object)blacklistID.reason, (object)blacklistID.getTime()); //SDG.Unturned.Provider.send(steamID, ESteamPacket.BANNED, bytes, size1, 0); Console.WriteLine("line 15"); return(true); } bool flag3 = SteamWhitelist.checkWhitelisted(steamID); if (SDG.Unturned.Provider.isWhitelisted && !flag3) { Console.WriteLine("line 16"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WHITELISTED); return(true); } byte[] hash_0_1 = (byte[])objects[4]; if (hash_0_1.Length != 20) { Console.WriteLine("line 17"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD); return(true); } byte[] hash_0_2 = (byte[])objects[5]; if (hash_0_2.Length != 20) { Console.WriteLine("line 18"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL); return(true); } byte[] h = (byte[])objects[6]; if (h.Length != 20) { Console.WriteLine("line 19"); //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY); return(true); } string str1 = (string)objects[29]; ModuleDependency[] moduleDependencyArray; if (string.IsNullOrEmpty(str1)) { moduleDependencyArray = new ModuleDependency[0]; } else { string[] strArray1 = str1.Split(';'); moduleDependencyArray = new ModuleDependency[strArray1.Length]; for (int index2 = 0; index2 < moduleDependencyArray.Length; ++index2) { string[] strArray2 = strArray1[index2].Split(','); if (strArray2.Length == 2) { moduleDependencyArray[index2] = new ModuleDependency(); moduleDependencyArray[index2].Name = strArray2[0]; uint.TryParse(strArray2[1], out moduleDependencyArray[index2].Version_Internal); } } } critMods.Clear(); ModuleHook.getRequiredModules(critMods); bool flag4 = true; for (int index2 = 0; index2 < moduleDependencyArray.Length; ++index2) { bool flag2 = false; if (moduleDependencyArray[index2] != null) { for (int index3 = 0; index3 < critMods.Count; ++index3) { if (critMods[index3] != null && critMods[index3].config != null && (critMods[index3].config.Name == moduleDependencyArray[index2].Name && critMods[index3].config.Version_Internal >= moduleDependencyArray[index2].Version_Internal)) { flag2 = true; return(true); } } } if (!flag2) { flag4 = false; return(true); } } if (!flag4) { //SDG.Unturned.Provider.reject(steamID, ESteamRejection.CLIENT_MODULE_DESYNC); Console.WriteLine("line 20"); return(true); } bool flag5 = true; for (int index2 = 0; index2 < critMods.Count; ++index2) { bool flag2 = false; if (critMods[index2] != null && critMods[index2].config != null) { for (int index3 = 0; index3 < moduleDependencyArray.Length; ++index3) { if (moduleDependencyArray[index3] != null && moduleDependencyArray[index3].Name == critMods[index2].config.Name && moduleDependencyArray[index3].Version_Internal >= critMods[index2].config.Version_Internal) { flag2 = true; return(true); } } } if (!flag2) { flag5 = false; return(true); } } if (!flag5) { //SDG.Unturned.Provider.reject(steamID, ESteamRejection.SERVER_MODULE_DESYNC); Console.WriteLine("line 21"); return(true); } Console.WriteLine("section 1"); if (SDG.Unturned.Provider.serverPassword == string.Empty || Hash.verifyHash(hash_0_1, _serverPasswordHash)) { Console.WriteLine("section 2"); if (Hash.verifyHash(hash_0_2, Level.hash)) { Console.WriteLine("section 3"); if (ReadWrite.appIn(h, (byte)objects[7])) { Console.WriteLine("section 4"); if ((double)(float)objects[10] < (double)SDG.Unturned.Provider.configData.Server.Max_Ping_Milliseconds / 1000.0) { Console.WriteLine("section 5"); //var pending = new SteamPending(newPlayerID, (bool)objects[9], (byte)objects[13], (byte)objects[14], (byte)objects[15], (Color)objects[16], (Color)objects[17], (Color)objects[18], (bool)objects[19], (ulong)objects[20], (ulong)objects[21], (ulong)objects[22], (ulong)objects[23], (ulong)objects[24], (ulong)objects[25], (ulong)objects[26], (ulong[])objects[27], (EPlayerSkillset)(byte)objects[28], (string)objects[30], (CSteamID)objects[31]); //Provider.pending.Insert(0, pending); //pending.sendVerifyPacket(); //Console.WriteLine($"Accepting {pending.playerID.steamID}."); return(false); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.PING); Console.WriteLine("line 22"); return(true); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY); Console.WriteLine("line 23"); return(true); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL); Console.WriteLine("line 24"); return(true); } //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD); Console.WriteLine("line 25"); return(true); } } return(true); }
public void BarDown(Vector3 pos) { if (height % 2 == 0) { height++; } int iwidth = height; //幅 int iheight = height; //高さ int idepth = depth; //深さ string[,] Stage = new string[iwidth, iheight]; //ステージデータ string StageFile = System.IO.Path.GetFileName(@"C:\\AutoCreate\Assets\Scripts\stage.txt"); //ステージデータパス /*--------------------------ステージの素材生成--------------------------*/ //縦はiheight、横はiweight for (int h = 0; h < iheight; h++) { for (int w = 0; w < iwidth; w++) { //外周は壁に、内は偶数の配列番号のときに壁を生成 if (h == 0 || w == 0 || w == (iwidth - 1) || h == (iheight - 1) || (h > 0 && w > 0 && h % 2 == 0 && w % 2 == 0)) { Stage[w, h] = "#"; } else if (h == 1 && w == 1) { //左上にゴール Stage[w, h] = "S"; } else if ((h == (iheight - 2) && w == (iwidth - 2))) { //右下にゴール Stage[w, h] = "G"; } else { //壁でもスタートでもゴールにないところは通路 Stage[w, h] = " "; } } } /*------------------------------ここまで---------------------------------*/ /*-------------------------素材から迷路を生成(棒倒し法)-----------------------*/ int hw = 0; //壁を生成する向きを代入 for (int h = 2; h < iheight - 1; h += 2) { for (int w = 2; w < iwidth - 1; w += 2) { //壁を作れるまでループ while (true) { //一番最初の行以外は上向きにに壁を作れない if (h == 2) { hw = Random.Range(0, 4); } else { hw = Random.Range(0, 3); } int Barh = h; //現在のx座標を代入 int Barw = w; //現在のy座標を代入 //0:右 1:左 2:下 3:上 switch (hw) { case 0: Barw++; break; case 1: Barw--; break; case 2: Barh++; break; case 3: Barh--; break; } //壁のない所に壁を生成 if (Stage[Barw, Barh] != "#") { Stage[Barw, Barh] = "#"; break; } } } } /*------------------------------------ここまで--------------------------------*/ /*--------------------------ステージのデータをもとにUnityでCubeを生成-------------------*/ ReadWrite.Write(StageFile, Stage, iheight, iwidth); //ステージのデータをファイルに書き込み string textdata = ReadWrite.Read(StageFile); //ファイルからデータを取り出す GameObject obj = null; //テキストデータから文字を取り出し、string型の変数cに代入 foreach (char c in textdata) { if (c == '#') { obj = Instantiate(gwall, pos, Quaternion.identity) as GameObject; //壁を生成 obj.name = gwall.name; //壁の名前をwallに for (int i = 1; i < idepth; i++) // { pos.z -= 1; // z軸に-1する obj = Instantiate(gwall, pos, Quaternion.identity) as GameObject; // idepthの分だけの高さを壁に設定する obj.name = gwall.name; // } pos.z += (idepth - 1); //z軸を元(z = 0)に戻す pos.x += obj.transform.lossyScale.x; //x軸を次に進める icnt++; } else if (c == '\n') { Vector3 origin = new Vector3((float)icnt, 1.0f, 0f); //x軸の初期値をoriginに代入 pos.y -= spaceScale.y; //改行コードであればy軸を一つ下にずらす pos.x -= origin.x; //改行コードであればx軸を初期値に戻す icnt = 0; } else if (c == ' ' || c == '-' || c == 'S' || c == 'G') { obj = Instantiate(gstage, pos, Quaternion.identity) as GameObject; obj.name = gstage.name; pos.x += spaceScale.x; icnt++; } } /*-----------------------------------------ここまで---------------------------------------*/ }
private string WriteReadString_NIUSB(string ioaddr, string str_Write, ReadWrite operation, int count = 0) { return(this.WriteReadString_GPIB(ioaddr, str_Write, operation, count)); }
private void Apply_Click(object sender, EventArgs e) { int fieldCheck = FieldCheck(); if (fieldCheck == 0) { //Assign new data string placeName = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id + "-" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Name; string path = "*/Place/" + placeName; string currentType = CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Type; SubObjectList.SmallImageList = imageList1; CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Latitude = LatitudeValue.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Longitude = LongitudeValue.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Name = NameValue.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].ZoomLevel = GetZoomLevelFromIndex(); CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Type = SubObjectType.Text; //Set interface values int index = GroundEventFunctions.GetSubObjectImageIndex(CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex]); SubObjectList.Items[CommonData.SubObjectIndex].ImageIndex = index; SubObjectList.Items[CommonData.SubObjectIndex].SubItems[0].Text = NameValue.Text; SubObjectList.Refresh(); //Rename STK object string cmd; try { cmd = "Rename " + path + " " + CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id + "-" + NameValue.Text; CommonData.StkRoot.ExecuteCommand(cmd); } catch (Exception) { //MessageBox.Show("Error renaming object"); } //Reassign position. Check is for when the renaming is not successful placeName = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id + "-" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Name; path = "Place/" + placeName; if (CommonData.StkRoot.ObjectExists(path)) { IAgPlace place = CommonData.StkRoot.GetObjectFromPath(path) as IAgPlace; place.Position.AssignGeodetic(Double.Parse(LatitudeValue.Text), Double.Parse(LongitudeValue.Text), 0); } //Change object marker if type changed if (currentType != SubObjectType.Text) { string filePath = GroundEventFunctions.GetImagePath(CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Type); try { cmd = "VO */Place/" + placeName + " marker show on markertype imagefile imagefile \"" + filePath + "\" Size 32"; CommonData.StkRoot.ExecuteCommand(cmd); } catch (Exception) { } } else { CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].Type = SubObjectType.Text; } //Apply zoom level string zoom = CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects[CommonData.SubObjectIndex].ZoomLevel + "000"; try { cmd = "VO */Place/" + placeName + " ModelDetail Set ModelLabel " + zoom + " MarkerLabel " + zoom + " Marker " + zoom + " Point " + zoom; CommonData.StkRoot.ExecuteCommand(cmd); } catch (Exception) { string mes = "Could not Modify Zoom for SubObject"; MessageBox.Show(mes); } //Rewrite output file to reflect changes ReadWrite.WriteEventFile(CommonData.EventFileStr); } }
private string WriteReadString_GPIB(string ioaddr, string str_Write, ReadWrite operation, int count = 0) { string buf = Status.Failed.ToString(); try { lock (syncRoot_GPIB) { if (rm == null || myDmm == null || myDmm.IO == null) { rm = new Ivi.Visa.Interop.ResourceManager(); //Open up a new resource manager myDmm = new Ivi.Visa.Interop.FormattedIO488(); //Open a new Formatted IO 488 session myDmm.IO = (IMessage)rm.Open(ioaddr, AccessMode.NO_LOCK, 5000, ""); //Open up a handle to the DMM with a 2 second timeout myDmm.IO.Timeout = 5000; //You can also set your timeout by doing this command, sets to 3 seconds //myDmm.IO.Clear(); //Send a device clear first to stop any measurements in process //myDmm.WriteString("*RST", true); dicMyDmm = new Dictionary <string, IMessage>(); dicMyDmm.Add(ioaddr, myDmm.IO); } if (myDmm.IO != null && dicMyDmm.ContainsKey(ioaddr)) { myDmm.IO = dicMyDmm[ioaddr]; } else { Thread.Sleep(100); myDmm.IO = (IMessage)rm.Open(ioaddr, AccessMode.NO_LOCK, 5000, ""); //Open up a handle to the DMM with a 2 second timeout myDmm.IO.Timeout = 5000; //You can also set your timeout by doing this command, sets to 3 seconds dicMyDmm.Add(ioaddr, myDmm.IO); } //if (myDmm.IO != null && myDmm.IO.ResourceName != ioaddr + "::INSTR") //{ // Thread.Sleep(100); // myDmm.IO = (IMessage)rm.Open(ioaddr, AccessMode.NO_LOCK, 5000, ""); //Open up a handle to the DMM with a 2 second timeout // myDmm.IO.Timeout = 5000; //You can also set your timeout by doing this command, sets to 3 seconds // Thread.Sleep(100); //} //myDmm.IO.Clear(); //Send a device clear first to stop any measurements in process //myDmm.WriteString("*RST", true); if (operation == ReadWrite.Write) { myDmm.WriteString(str_Write, true); buf = Status.Pass.ToString(); } else if (count == 0) { buf = myDmm.ReadString(); //myDmm.IO.Clear(); //Send a device clear first to stop any measurements in process } else { byte[] arr = new byte[count]; arr = myDmm.IO.Read(count); buf = System.Text.Encoding.Default.GetString(arr); } Thread.Sleep(50); return(buf); } } catch (Exception ex) { Log.SaveLogToTxt(ex.Message + "\r\n" + "failed to operate GPIB"); return(buf); } }
public static void IShit(CSteamID steamID, byte[] packet, int offset, int size, int channel) { Provider._bytesReceived += (uint)size; Provider._packetsReceived++; if (Dedicator.isDedicated) { ESteamPacket packet2 = (ESteamPacket)packet[offset]; if (Provider.isUpdate(packet2)) { if (steamID == Provider.server) { for (int i = 0; i < Provider.receivers.Count; i++) { if (Provider.receivers[i].id == channel) { Provider.receivers[i].receive(steamID, packet, offset, size); return; } } } else { for (int j = 0; j < Provider.clients.Count; j++) { if (Provider.clients[j].playerID.steamID == steamID) { for (int k = 0; k < Provider.receivers.Count; k++) { if (Provider.receivers[k].id == channel) { Provider.receivers[k].receive(steamID, packet, offset, size); return; } } return; } } } } else { SteamPending pending; switch (packet2) { case ESteamPacket.WORKSHOP: { ulong num8; List <ulong> list = new List <ulong>(); string[] strArray = ReadWrite.getFolders("/Bundles/Workshop/Content"); for (int m = 0; m < strArray.Length; m++) { ulong num5; if (ulong.TryParse(ReadWrite.folderName(strArray[m]), out num5)) { list.Add(num5); } } string[] strArray2 = ReadWrite.getFolders(ServerSavedata.directory + "/" + Provider.serverID + "/Workshop/Content"); for (int n = 0; n < strArray2.Length; n++) { ulong num7; if (ulong.TryParse(ReadWrite.folderName(strArray2[n]), out num7)) { list.Add(num7); } } if (ulong.TryParse(new DirectoryInfo(Level.info.path).Parent.Name, out num8)) { list.Add(num8); } byte[] array = new byte[2 + (list.Count * 8)]; array[0] = 1; array[1] = (byte)list.Count; for (byte num9 = 0; num9 < list.Count; num9 = (byte)(num9 + 1)) { BitConverter.GetBytes(list[num9]).CopyTo(array, (int)(2 + (num9 * 8))); } Provider.send(steamID, ESteamPacket.WORKSHOP, array, array.Length, 0); return; } case ESteamPacket.TICK: { int num10; object[] objects = new object[] { (byte)14, Provider.net }; byte[] buffer2 = SteamPacker.getBytes(0, out num10, objects); Provider.send(steamID, ESteamPacket.TIME, buffer2, num10, 0); return; } case ESteamPacket.TIME: for (int num11 = 0; num11 < Provider.clients.Count; num11++) { if (Provider.clients[num11].playerID.steamID == steamID) { if (Provider.clients[num11].lastPing > 0f) { Provider.clients[num11].lastNet = Time.realtimeSinceStartup; Provider.clients[num11].lag(Time.realtimeSinceStartup - Provider.clients[num11].lastPing); Provider.clients[num11].lastPing = -1f; } return; } } return; case ESteamPacket.CONNECT: { long num14; double num15; long num16; double num17; SteamBlacklistID tid; for (int num12 = 0; num12 < Provider.pending.Count; num12++) { if (Provider.pending[num12].playerID.steamID == steamID) { Provider.Reject(steamID, ESteamRejection.ALREADY_PENDING); return; } } for (int num13 = 0; num13 < Provider.clients.Count; num13++) { if (Provider.clients[num13].playerID.steamID == steamID) { Provider.Reject(steamID, ESteamRejection.ALREADY_CONNECTED); return; } } Type[] types = new Type[] { Types.BYTE_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.BOOLEAN_TYPE, Types.SINGLE_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.BOOLEAN_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_ARRAY_TYPE, Types.BYTE_TYPE }; object[] objArray = SteamPacker.getObjects(steamID, offset, 0, packet, types); SteamPlayerID newPlayerID = new SteamPlayerID(steamID, (byte)objArray[1], (string)objArray[2], (string)objArray[3], (string)objArray[11], (CSteamID)objArray[12]); if (((string)objArray[8]) != Provider.Version) { Provider.Reject(steamID, ESteamRejection.WRONG_VERSION); return; } if (newPlayerID.SteamName.Length < 2) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_SHORT); return; } if (newPlayerID.CharacterName.Length < 2) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT); return; } if (newPlayerID.SteamName.Length > 0x20) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_LONG); return; } if (newPlayerID.CharacterName.Length > 0x20) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_LONG); return; } if (long.TryParse(newPlayerID.SteamName, out num14) || double.TryParse(newPlayerID.SteamName, out num15)) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER); return; } if (long.TryParse(newPlayerID.CharacterName, out num16) || double.TryParse(newPlayerID.CharacterName, out num17)) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER); return; } if (Provider.filterName) { if (!NameTool.isValid(newPlayerID.SteamName)) { Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_INVALID); return; } if (!NameTool.isValid(newPlayerID.CharacterName)) { Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID); return; } } if (SteamBlacklist.checkBanned(steamID, out tid)) { int num18; object[] objArray2 = new object[] { (byte)9, tid.reason, tid.getTime() }; byte[] buffer3 = SteamPacker.getBytes(0, out num18, objArray2); Provider.send(steamID, ESteamPacket.BANNED, buffer3, num18, 0); return; } if (!SteamWhitelist.checkWhitelisted(steamID)) { Provider.Reject(steamID, ESteamRejection.WHITELISTED); return; } if ((Provider.clients.Count + 1) > Provider.maxPlayers) { Provider.Reject(steamID, ESteamRejection.SERVER_FULL); return; } byte[] buffer4 = (byte[])objArray[4]; if (buffer4.Length != 20) { Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } byte[] buffer5 = (byte[])objArray[5]; if (buffer5.Length != 20) { Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } byte[] h = (byte[])objArray[6]; if (h.Length != 20) { Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } if ((Provider.serverPassword == string.Empty) || Hash.verifyHash(buffer4, Provider._serverPasswordHash)) { if (Hash.verifyHash(buffer5, Level.hash)) { if (ReadWrite.appIn(h, (byte)objArray[7])) { if (((float)objArray[10]) < Provider.timeout) { Provider.pending.Add(new SteamPending(newPlayerID, (bool)objArray[9], (byte)objArray[13], (byte)objArray[14], (byte)objArray[15], (Color)objArray[0x10], (Color)objArray[0x11], (bool)objArray[0x12], (ulong)objArray[0x13], (ulong)objArray[20], (ulong)objArray[0x15], (ulong)objArray[0x16], (ulong)objArray[0x17], (ulong)objArray[0x18], (ulong)objArray[0x19], (ulong[])objArray[0x1a], (EPlayerSpeciality)((byte)objArray[0x1b]))); byte[] buffer1 = new byte[] { 3 }; Provider.send(steamID, ESteamPacket.VERIFY, buffer1, 1, 0); return; } Provider.Reject(steamID, ESteamRejection.PING); return; } Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } Provider.Reject(steamID, ESteamRejection.WRONG_HASH); return; } Provider.Reject(steamID, ESteamRejection.WRONG_PASSWORD); return; } default: if (packet2 != ESteamPacket.AUTHENTICATE) { Debug.LogError("Failed to handle message: " + packet2); return; } pending = null; for (int num19 = 0; num19 < Provider.pending.Count; num19++) { if (Provider.pending[num19].playerID.steamID == steamID) { pending = Provider.pending[num19]; break; } } break; } if (pending == null) { Provider.Reject(steamID, ESteamRejection.NOT_PENDING); } else if ((Provider.clients.Count + 1) > Provider.maxPlayers) { Provider.Reject(steamID, ESteamRejection.SERVER_FULL); } else { ushort count = BitConverter.ToUInt16(packet, 1); byte[] dst = new byte[count]; Buffer.BlockCopy(packet, 3, dst, 0, count); ushort num21 = BitConverter.ToUInt16(packet, 3 + count); byte[] buffer8 = new byte[num21]; Buffer.BlockCopy(packet, 5 + count, buffer8, 0, num21); if (!Provider.verifyTicket(steamID, dst)) { Provider.Reject(steamID, ESteamRejection.AUTH_VERIFICATION); } else if (num21 > 0) { if (!SteamGameServerInventory.DeserializeResult(out pending.inventoryResult, buffer8, num21, false)) { Provider.Reject(steamID, ESteamRejection.AUTH_ECON); } } else { pending.shirtItem = 0; pending.pantsItem = 0; pending.hatItem = 0; pending.backpackItem = 0; pending.vestItem = 0; pending.maskItem = 0; pending.glassesItem = 0; pending.skinItems = new int[0]; pending.packageShirt = 0L; pending.packagePants = 0L; pending.packageHat = 0L; pending.packageBackpack = 0L; pending.packageVest = 0L; pending.packageMask = 0L; pending.packageGlasses = 0L; pending.packageSkins = new ulong[0]; pending.inventoryResult = SteamInventoryResult_t.Invalid; pending.inventoryDetails = new SteamItemDetails_t[0]; pending.hasProof = true; } } } } }
private void Apply_Click(object sender, EventArgs e) { CommonData.TypeChanged = false; int check = FieldCheck(); if (check == 0) { string path = "*/Place/" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id; GroundEventFunctions.RemoveTimelineComponent(CommonData.CurrentEvents[CommonData.EventSelectedIndex]); CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id = IDText.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].Country = CountryText.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].Latitude = Latitude.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].Longitude = Longitude.Text; string start = GroundEventFunctions.ConvertMilTime(StartTimeText.Text); if (start == "Unspecified") { CommonData.CurrentEvents[CommonData.EventSelectedIndex].StartTime = "Unspecified"; CommonData.CurrentEvents[CommonData.EventSelectedIndex].MilStartTime = "Unspecified"; } else { CommonData.CurrentEvents[CommonData.EventSelectedIndex].MilStartTime = StartTimeText.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].StartTime = StartTimeText.Text; } string stop = ReadWrite.CheckTimeCell(StopTimeText.Text); if (stop == "Unspecified") { CommonData.CurrentEvents[CommonData.EventSelectedIndex].StopTime = "Unspecified"; CommonData.CurrentEvents[CommonData.EventSelectedIndex].MilStopTime = "Unspecified"; } else { CommonData.CurrentEvents[CommonData.EventSelectedIndex].MilStopTime = StopTimeText.Text; CommonData.CurrentEvents[CommonData.EventSelectedIndex].StopTime = StopTimeText.Text; } CommonData.CurrentEvents[CommonData.EventSelectedIndex].Description = DesciptionText.Text; //Rename Object/sub-objects string cmd = "Rename " + path + " " + CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id; CommonData.StkRoot.ExecuteCommand(cmd); if (CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects != null) { foreach (SubObject item in CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects) { cmd = "Rename " + path + "-" + item.Name + " " + CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id + "-" + item.Name; CommonData.StkRoot.ExecuteCommand(cmd); } } //Reassign position path = "Place/" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id; IAgPlace place = CommonData.StkRoot.GetObjectFromPath(path) as IAgPlace; place.Position.AssignGeodetic(Double.Parse(Latitude.Text), Double.Parse(Longitude.Text), 0); //Change object marker if type changed string currentType = CommonData.CurrentEvents[CommonData.EventSelectedIndex].SsrType; if (currentType != TypeSelect.Text) { CommonData.CurrentEvents[CommonData.EventSelectedIndex].SsrType = TypeSelect.Text; CommonData.TypeChanged = true; string filePath = GroundEventFunctions.GetImagePath(CommonData.CurrentEvents[CommonData.EventSelectedIndex].SsrType); cmd = "VO */Place/" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id + " marker show on markertype imagefile imagefile \"" + filePath + "\" Size 32"; CommonData.StkRoot.ExecuteCommand(cmd); } else { CommonData.CurrentEvents[CommonData.EventSelectedIndex].SsrType = TypeSelect.Text; } ReadWrite.WriteEventFile(CommonData.EventFileStr); this.Close(); } }
/// <summary> /// Prefetch a pointer. /// </summary> /// <param name="v">The pointer to prefetch.</param> /// <param name="rw">Whether the pointer will be used for reading or writing.</param> /// <param name="locality">The cache locality of the pointer.</param> public static unsafe void Prefetch(void *v, ReadWrite rw, Locality locality = Locality.HighTemporalLocality) { }
private void Button_Click(object sender, RoutedEventArgs e) { if (Id.Equals("") || Name.Equals("") || cmbColors.SelectedItem == null) { MessageBox.Show("You must fill all required fields"); return; } Color selectedColor = (Color)(cmbColors.SelectedItem as PropertyInfo).GetValue(null, null); foreach (Tag t in MainWindow.tags) { if (t.Id == Id.Text && tag.Id != Id.Text) { MessageBox.Show("Id you entered is already in use. Please choose another."); return; } else if (t.Name == Name.Text && tag.Name != Name.Text) { MessageBox.Show("Name you entered is already in use. Please choose another."); return; } else if (t.Color == selectedColor.ToString() && tag.Color != selectedColor.ToString()) { MessageBox.Show("Color you choose is already in use. Please choose another."); return; } } foreach (Tag t in MainWindow.tags) { if (t.Id == tag.Id) { t.Id = Id.Text; t.Name = Name.Text; t.Description = Description.Text; t.Color = selectedColor.ToString(); } } foreach (ResourcePoint rp in MainWindow.resources) { foreach (Tag t in rp.resource.Tags) { if (t.Id == tag.Id) { t.Id = Id.Text; t.Name = Name.Text; t.Description = Description.Text; t.Color = selectedColor.ToString(); } } } MainWindow.removeAllResources(); MainWindow.drawResources(); ReadWrite rw = new ReadWrite(); rw.writeToFile("../../Data/tags.json", MainWindow.tags); rw.writeToFile("../../Data/resources.json", MainWindow.resources); this.Close(); MessageBox.Show("You have successfully edited tag."); }
private void CreateButton_Click(object sender, EventArgs e) { if (ManualSSR.Checked) { int fieldCheck = FieldCheck(); if (fieldCheck == 0) { GroundEvent current = new GroundEvent(); current.Id = Regex.Replace(IDText.Text, @"[^0-9a-zA-Z_]+", ""); current.Country = CountryText.Text; current.Latitude = Latitude.Text; current.Longitude = Longitude.Text; string start = ReadWrite.CheckTimeCell(StartTimeText.Text); if (start == "Unspecified") { current.StartTime = "Unspecified"; current.MilStartTime = "Unspecified"; } else { current.MilStartTime = StartTimeText.Text; current.StartTime = StartTimeText.Text; } string stop = ReadWrite.CheckTimeCell(StopTimeText.Text); if (stop == "Unspecified") { current.StopTime = "Unspecified"; current.MilStopTime = "Unspecified"; } else { current.MilStopTime = StopTimeText.Text; current.StopTime = StopTimeText.Text; } current.Description = DesciptionText.Text; current.SsrType = TypeSelect.Text; if (!String.IsNullOrEmpty(_contactEvent.Poc)) { current.Poc = _contactEvent.Poc; } if (!String.IsNullOrEmpty(_contactEvent.PocPhone)) { current.PocPhone = _contactEvent.PocPhone; } if (!String.IsNullOrEmpty(_contactEvent.PocEmail)) { current.PocEmail = _contactEvent.PocEmail; } current.ColorOption = ColorSelection.Text; CommonData.CurrentEvents.Add(current); GroundEventFunctions.CreateGroundEvent(current); CreatorFunctions.ChangeObjectColor("Place/" + current.Id, (CustomUserInterface.ColorOptions)Enum.Parse(typeof(CustomUserInterface.ColorOptions), ColorSelection.Text)); ReadWrite.WriteEventFile(CommonData.EventFileStr); } CommonData.NewSsrCreated = true; } else if (SSRFromFile.Checked) { int importOption = 0; if (ImportAll.Checked) { importOption = 1; } ReadWrite.ImportEventSheet(FileText.Text, importOption, SheetColor.Text); CommonData.NewSsrCreated = true; } this.Close(); }
private static byte[] ReadWriteReg(int deviceIndex, int deviceAddress, int regAddress, bool regAddressWide, ReadWrite operate, byte[] buffer) { byte[] arr = new byte[buffer.Length + 8]; arr[0] = regAddressWide ? (byte)1 : (byte)0; arr[1] = (byte)(regAddress / 256); arr[2] = i2c_soft_enable ? (byte)1 : (byte)0;; //soft arr[3] = (byte)operate; arr[4] = (byte)deviceAddress; arr[5] = (byte)(regAddress & 0xFF); arr[6] = (byte)buffer.Length; arr[7] = I2C_standard_speed ? (byte)1 : (byte)0;////400k:0, 100k:1 buffer.CopyTo(arr, 8); //USB虚拟串口一次只能穿64个字节 if (arr.Length > 64) { return(null); } //semaphore.WaitOne(); byte[] readBytes = new byte[buffer.Length]; try { string comIndex = "COM2"; switch (deviceIndex) { case 1: comIndex = "COM2"; break; case 2: comIndex = "COM3"; break; case 3: comIndex = "COM4"; break; case 4: comIndex = "COM5"; break; default: comIndex = "COM2"; break; } if (_serialPort == null) { _serialPort = new SerialPort(comIndex, 9600, Parity.None, 8, StopBits.One); dicMyPort = new Dictionary <string, SerialPort>(); dicMyPort.Add(comIndex, _serialPort); } if (_serialPort != null && dicMyPort.ContainsKey(comIndex)) { _serialPort = dicMyPort[comIndex]; } else { _serialPort = new SerialPort(comIndex, 9600, Parity.None, 8, StopBits.One); dicMyPort = new Dictionary <string, SerialPort>(); dicMyPort.Add(comIndex, _serialPort); } // Set the read/write timeouts _serialPort.ReadTimeout = 500; _serialPort.WriteTimeout = 500; if (_serialPort.IsOpen == true) { _serialPort.Close(); } try { _serialPort.Open(); } catch { _serialPort.Close(); _serialPort.Open(); } _serialPort.DiscardInBuffer(); _serialPort.Write(arr, 0, arr.Length); //System.Threading.Thread.Sleep(300);//support ADI MCU with FTDI USB to UART System.Threading.Thread.Sleep(50);//support STM32L073 MCU with USB if (operate == ReadWrite.Read) { _serialPort.Read(readBytes, 0, buffer.Length); } _serialPort.Close(); //semaphore.Release(); System.Threading.Thread.Sleep(10); return(readBytes); } catch (Exception ex) { //semaphore.Release(); _serialPort.Close(); _serialPort = null; readBytes = null; return(null); } }
public static void ParseDDA(IRawFileThreadManager rawFileThreadManager, WorkflowParameters parameters) { MethodDataContainer methodData; CentroidStreamCollection centroidStreams; SegmentScanCollection segmentScans; TrailerExtraCollection trailerExtras; PrecursorMassCollection precursorMasses; RetentionTimeCollection retentionTimes; ScanEventReactionCollection reactions; ScanMetaDataCollectionDDA metaData = null; PrecursorPeakCollection peakData = null; RawMetricsDataDDA rawMetrics = null; QuantDataCollection quantData = null; var staticRawFile = rawFileThreadManager.CreateThreadAccessor(); staticRawFile.SelectInstrument(Device.MS, 1); //staticRawFile.CheckIfBoxcar(); (ScanIndex Index, PrecursorScanCollection precursorScans, ScanDependentsCollections scanDependents) = Extract.ScanIndicesPrecursorsDependents(rawFileThreadManager); using (var rawFile = rawFileThreadManager.CreateThreadAccessor()) { reactions = Extract.ScanEvents(rawFile, Index); methodData = Extract.MethodData(rawFile, Index); (centroidStreams, segmentScans) = Extract.MsData(rawFile: rawFile, index: Index); trailerExtras = Extract.TrailerExtras(rawFile, Index); precursorMasses = Extract.PrecursorMasses(rawFile, precursorScans, trailerExtras, Index); retentionTimes = Extract.RetentionTimes(rawFile, Index); } if (parameters.ParseParams.Parse | parameters.ParseParams.Quant | parameters.ParseParams.Metrics | parameters.RefineMassCharge) { peakData = AnalyzePeaks.AnalyzeAllPeaks(centroidStreams, retentionTimes, precursorMasses, precursorScans, Index); if (parameters.RefineMassCharge) { MonoIsoPredictor.RefineMonoIsoMassChargeValues(centroidStreams, precursorMasses, trailerExtras, peakData, precursorScans); } metaData = MetaDataProcessingDDA.AggregateMetaDataDDA(centroidStreams, segmentScans, methodData, precursorScans, trailerExtras, precursorMasses, retentionTimes, scanDependents, reactions, Index); } if (parameters.ParseParams.Quant) { quantData = Quantification.Quantify(centroidStreams, segmentScans, parameters, methodData, Index); } if (parameters.ParseParams.Metrics) { rawMetrics = MetaDataProcessingDDA.GetMetricsDataDDA(metaData, methodData, staticRawFile.FileName, retentionTimes, Index, peakData, precursorScans, quantData); MetricsWriter.WriteMatrix(rawMetrics, null, staticRawFile.FileName, parameters.ParseParams.OutputDirectory); } if (parameters.ParseParams.Parse | parameters.ParseParams.Quant) { string matrixFileName = ReadWrite.GetPathToFile(parameters.ParseParams.OutputDirectory, staticRawFile.FileName, "_Matrix.txt"); /* * ParseWriter writerDDA = new ParseWriter(matrixFileName, centroidStreams, segmentScans, metaData, retentionTimes, * precursorMasses, precursorScans, peakData, trailerExtras, Index, quantData); * writerDDA.WriteMatrixDDA(methodData.AnalysisOrder); */ MatrixWriter.ParseQuantDDA(matrixFileName, centroidStreams, segmentScans, metaData, retentionTimes, precursorMasses, precursorScans, peakData, trailerExtras, Index, quantData); } if (parameters.ParseParams.WriteMgf) { //ParseWriter writerMGF = new ParseWriter(centroidStreams, segmentScans, parameters, retentionTimes, precursorMasses, precursorScans, trailerExtras, methodData, Index); //writerMGF.WriteMGF(staticRawFile.FileName); MgfWriter.WriteMGF(staticRawFile.FileName, centroidStreams, segmentScans, parameters, retentionTimes, precursorMasses, precursorScans, trailerExtras, methodData, Index); } if (parameters.ParseParams.Chromatogram != null) { ChromatogramWriter.WriteChromatogram(centroidStreams, segmentScans, retentionTimes, methodData, Index, parameters, staticRawFile.FileName); } }
public static void WriteMGF(RawDataCollection rawData, IRawDataPlus rawFile, string outputDirectory, double cutoff = 0, int[] scans = null, double intensityCutoff = 0.01) { double intCutoff = 0; string fileName = ReadWrite.GetPathToFile(outputDirectory, rawData.rawFileName, ".mgf"); MassAnalyzerType ms2MassAnalyzer = rawData.methodData.MassAnalyzers[MSOrderType.Ms2]; List <Operations> operations = new List <Operations> { Operations.ScanIndex, Operations.MethodData, Operations.TrailerExtras, Operations.RetentionTimes }; if (ms2MassAnalyzer == MassAnalyzerType.MassAnalyzerFTMS) { operations.Add(Operations.Ms2CentroidStreams); } else { operations.Add(Operations.Ms2SegmentedScans); } CheckIfDone.Check(rawData, rawFile, operations); const int BufferSize = 65536; // 64 Kilobytes using (StreamWriter f = new StreamWriter(fileName, false, Encoding.UTF8, BufferSize)) //Open a new file, the MGF file { // if the scans argument is null, use all scans if (scans == null) { scans = rawData.scanIndex.ScanEnumerators[MSOrderType.Ms2]; } ProgressIndicator progress = new ProgressIndicator(scans.Count(), String.Format("Writing MGF file")); foreach (int i in scans) { f.WriteLine("\nBEGIN IONS"); f.WriteLine("RAWFILE={0}", rawData.rawFileName); f.WriteLine("TITLE=Spectrum_{0}", i); f.WriteLine("SCAN={0}", i); f.WriteLine("RTINSECONDS={0}", rawData.retentionTimes[i]); f.WriteLine("PEPMASS={0}", rawData.trailerExtras[i].MonoisotopicMZ); f.WriteLine("CHARGE={0}", rawData.trailerExtras[i].ChargeState); if (ms2MassAnalyzer == MassAnalyzerType.MassAnalyzerFTMS) { CentroidStreamData centroid = rawData.centroidStreams[i]; if (centroid.Intensities.Length > 0) { intCutoff = centroid.Intensities.Max() * intensityCutoff; } else { intCutoff = 0; } for (int j = 0; j < centroid.Masses.Length; j++) { //f.WriteLine(Math.Round(centroid.Masses[j], 4).ToString() + " " + Math.Round(centroid.Intensities[j], 4).ToString()); if (centroid.Masses[j] > cutoff & centroid.Intensities[j] > intCutoff) { f.WriteLine("{0} {1}", Math.Round(centroid.Masses[j], 5), Math.Round(centroid.Intensities[j], 4)); } } } else { SegmentedScanData segments = rawData.segmentedScans[i]; if (segments.Intensities.Length > 0) { intCutoff = segments.Intensities.Max() * intensityCutoff; } else { intCutoff = 0; } for (int j = 0; j < segments.Positions.Length; j++) { if (segments.Positions[j] > cutoff & segments.Intensities[j] > intCutoff) { f.WriteLine("{0} {1}", Math.Round(segments.Positions[j], 5), Math.Round(segments.Intensities[j], 4)); } } } f.WriteLine("END IONS"); progress.Update(); } progress.Done(); } Utilities.ConsoleUtils.ClearLastLine(); }
public static void Read(MainActivity thisActivity) { ReadWrite.ReadData(); }
public static void WriteMatrix(RawDataCollection rawData, ScanMetaDataCollection metaData, IRawDataPlus rawFile, QuantDataCollection quantData = null, string outputDirectory = null) { string fileName = ReadWrite.GetPathToFile(outputDirectory, rawData.rawFileName, "_Matrix.txt"); CheckIfDone.Check(rawData, rawFile, new List <Operations> { Operations.ScanIndex, Operations.MethodData, Operations.PrecursorScans, Operations.RetentionTimes, Operations.PrecursorMasses, Operations.TrailerExtras, Operations.MetaData }); using (StreamWriter f = new StreamWriter(fileName)) //Open a new file { List <int> scans; if (!rawData.isBoxCar) { scans = rawData.scanIndex.ScanEnumerators[rawData.scanIndex.AnalysisOrder].ToList(); } else { scans = rawData.precursorScans.Keys.ToList(); scans.Sort(); } ProgressIndicator progress = new ProgressIndicator(scans.Count(), "Writing matrix to disk"); f.Write("MS3ScanNumber\tMS2ScanNumber\tMS1ScanNumber\tQuantScanRetTime\tParentScanRetTime\tDutyCycle" + "\tMS2ScansPerCycle\tParentIonMass\tMonoisotopicMass\tPrecursorCharge\tMS1IsolationInterference"); if (!rawData.isBoxCar) { f.Write("\tParentPeakFound"); } if (rawData.Performed.Contains(Operations.PeakArea) & !rawData.isBoxCar) { f.Write("\tParentPeakArea"); } if (!rawData.isBoxCar) { f.Write("\tPeakFirstScan\tPeakMaxScan\tPeakLastScan\tBaseLinePeakWidth(s)\tPeakParentScanIntensity\tPeakMaxIntensity"); } f.Write("\tMS1IonInjectionTime\tMS2IonInjectionTime" + "\tMS3IonInjectionTime\tHCDEnergy\tMS1MedianIntensity\tMS2MedianIntensity\t"); if (quantData != null) { string reagents = quantData.LabelingReagents; foreach (string label in new LabelingReagents().Reagents[reagents].Labels) { f.Write(label + "Intensity\t"); } foreach (string label in new LabelingReagents().Reagents[reagents].Labels) { f.Write(label + "Mass\t"); } foreach (string label in new LabelingReagents().Reagents[reagents].Labels) { f.Write(label + "Noise\t"); } foreach (string label in new LabelingReagents().Reagents[reagents].Labels) { f.Write(label + "Resolution\t"); } foreach (string label in new LabelingReagents().Reagents[reagents].Labels) { f.Write(label + "Baseline\t"); } } f.Write("\n"); foreach (int scan in scans) { int ms3scan, ms2scan, masterScan; if (rawData.scanIndex.AnalysisOrder == MSOrderType.Ms3) { ms3scan = rawData.precursorScans[scan].MS3Scan; ms2scan = rawData.precursorScans[scan].MS2Scan; masterScan = rawData.precursorScans[scan].MasterScan; } else { ms3scan = -1; ms2scan = rawData.precursorScans[scan].MS2Scan; masterScan = rawData.precursorScans[scan].MasterScan; } f.Write(ms3scan.ToString() + "\t" + ms2scan.ToString() + "\t" + masterScan.ToString() + "\t"); f.Write(rawData.retentionTimes[scan].ToString() + "\t" + rawData.retentionTimes[masterScan].ToString() + "\t"); f.Write(metaData[masterScan].DutyCycle.ToString() + "\t" + metaData[masterScan].MS2ScansPerCycle.ToString() + "\t"); f.Write(rawData.precursorMasses[ms2scan].ParentMZ.ToString() + "\t"); f.Write(rawData.precursorMasses[ms2scan].MonoisotopicMZ.ToString() + "\t"); f.Write(rawData.trailerExtras[ms2scan].ChargeState.ToString() + "\t"); f.Write(rawData.metaData[scan].Ms1IsolationInterference.ToString() + "\t"); if (!rawData.isBoxCar) { f.Write(rawData.peakData[ms2scan].PeakFound.ToString() + "\t"); } if (rawData.Performed.Contains(Operations.PeakArea) & !rawData.isBoxCar) { f.Write(rawData.peakData[ms2scan].Area.ToString() + "\t"); } if (!rawData.isBoxCar) { f.Write(rawData.peakData[ms2scan].FirstScan.ToString() + "\t"); f.Write(rawData.peakData[ms2scan].MaxScan.ToString() + "\t"); f.Write(rawData.peakData[ms2scan].LastScan.ToString() + "\t"); f.Write((rawData.peakData[ms2scan].BaselineWidth * 60).ToString() + "\t"); f.Write(rawData.peakData[ms2scan].ParentIntensity.ToString() + "\t"); f.Write(rawData.peakData[ms2scan].MaximumIntensity.ToString() + "\t"); } f.Write(rawData.trailerExtras[masterScan].InjectionTime.ToString() + "\t"); if (rawData.scanIndex.AnalysisOrder == MSOrderType.Ms3) { f.Write(rawData.trailerExtras[ms2scan].InjectionTime.ToString() + "\t"); f.Write(rawData.trailerExtras[ms3scan].InjectionTime.ToString() + "\t"); } else { f.Write(rawData.trailerExtras[ms2scan].InjectionTime.ToString() + "\t"); f.Write("-1\t"); } f.Write(rawData.trailerExtras[scan].HCDEnergy + "\t"); f.Write(metaData[masterScan].IntensityDistribution.P50 + "\t"); f.Write(metaData[ms2scan].IntensityDistribution.P50 + "\t"); if (quantData != null) { foreach (string label in quantData[scan].Keys) { f.Write(quantData[scan][label].Intensity + "\t"); } foreach (string label in quantData[scan].Keys) { f.Write(quantData[scan][label].Mass + "\t"); } foreach (string label in quantData[scan].Keys) { f.Write(quantData[scan][label].Noise + "\t"); } foreach (string label in quantData[scan].Keys) { f.Write(quantData[scan][label].Resolution + "\t"); } foreach (string label in quantData[scan].Keys) { f.Write(quantData[scan][label].Baseline + "\t"); } } f.Write("\n"); progress.Update(); } progress.Done(); } }
private static void GetControlByteValuesV08(byte controlByte, out ReadWrite readWrite, out int derefdepth) { derefdepth = 0x0F & controlByte; readWrite = (ReadWrite)((controlByte >> 6) & 0b0000_0011); }
public static void WriteChromatogram(this RawDataCollection rawData, IRawDataPlus rawFile, MSOrderType order, bool TIC, bool BP, string outputDirectory) { List <Operations> operations = new List <Operations>() { Operations.RetentionTimes }; //MSOrderType order = (MSOrderType)msOrder; MassAnalyzerType analyzer = rawData.methodData.MassAnalyzers[order]; if (analyzer == MassAnalyzerType.MassAnalyzerFTMS) { if (order == MSOrderType.Ms) { operations.Add(Operations.Ms1CentroidStreams); } if (order == MSOrderType.Ms2) { operations.Add(Operations.Ms2CentroidStreams); } if (order == MSOrderType.Ms3) { operations.Add(Operations.Ms3CentroidStreams); } } else { if (order == MSOrderType.Ms) { operations.Add(Operations.Ms1SegmentedScans); } if (order == MSOrderType.Ms2) { operations.Add(Operations.Ms2SegmentedScans); } if (order == MSOrderType.Ms3) { operations.Add(Operations.Ms3SegmentedScans); } } CheckIfDone.Check(rawData, rawFile, operations); int[] scans = rawData.scanIndex.ScanEnumerators[order]; if (TIC) { ProgressIndicator progress = new ProgressIndicator(scans.Length, String.Format("Writing {0} TIC chromatogram", order)); progress.Start(); string fileName = ReadWrite.GetPathToFile(outputDirectory, rawData.rawFileName, "_" + order + "_TIC_chromatogram.txt"); using (StreamWriter f = new StreamWriter(fileName)) { f.WriteLine("RetentionTime\tIntensity"); if (analyzer == MassAnalyzerType.MassAnalyzerFTMS) { foreach (int scan in scans) { if (rawData.centroidStreams[scan].Intensities.Length > 0) { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], rawData.centroidStreams[scan].Intensities.Sum()); } else { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], 0); } progress.Update(); } } else { foreach (int scan in scans) { if (rawData.segmentedScans[scan].Intensities.Length > 0) { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], rawData.segmentedScans[scan].Intensities.Sum()); } else { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], 0); } progress.Update(); } } } progress.Done(); } if (BP) { ProgressIndicator progress = new ProgressIndicator(scans.Length, String.Format("Writing {0} base peak chromatogram", order)); progress.Start(); string fileName = ReadWrite.GetPathToFile(outputDirectory, rawData.rawFileName, "_" + order + "_BP_chromatogram.txt"); using (StreamWriter f = new StreamWriter(fileName)) { f.WriteLine("RetentionTime\tIntensity"); if (analyzer == MassAnalyzerType.MassAnalyzerFTMS) { foreach (int scan in scans) { if (rawData.centroidStreams[scan].Intensities.Length > 0) { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], rawData.centroidStreams[scan].Intensities.Max()); } else { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], 0); } progress.Update(); } } else { foreach (int scan in scans) { if (rawData.segmentedScans[scan].Intensities.Length > 0) { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], rawData.segmentedScans[scan].Intensities.Max()); } else { f.WriteLine("{0}\t{1}", rawData.retentionTimes[scan], 0); } progress.Update(); } } } progress.Done(); } }
public static bool ValidateRunAs(ProjectionMode mode, ReadWrite readWrite, IPrincipal existingRunAs, Command.ControlMessage message, bool replace = false) { if (mode > ProjectionMode.Transient && readWrite == ReadWrite.Write && (message.RunAs == null || message.RunAs.Principal == null || !message.RunAs.Principal.IsInRole(SystemRoles.Admins))) { message.Envelope.ReplyWith(new NotAuthorized()); return false; } if (replace && message.RunAs.Principal == null) { message.Envelope.ReplyWith(new NotAuthorized()); return false; } if (replace && message.RunAs.Principal != null) return true; // enable this operation while no projection permissions are defined return true; //if (existingRunAs == null) // return true; //if (message.RunAs1.Principal == null // || !string.Equals( // existingRunAs.Identity.Name, message.RunAs1.Principal.Identity.Name, // StringComparison.OrdinalIgnoreCase)) //{ // message.Envelope.ReplyWith(new NotAuthorized()); // return false; //} //return true; }
//main function to do stuff private void btn_makeRequest_Click(object sender, EventArgs e) { if (NameBasedOnCatalog.Checked) { if (CommonData.SatCatItemList != null) { if (!(CommonData.SatCatItemList.Count > 0)) { ReadWrite.ReadSatCat(); } } else { CommonData.SatCatItemList = new List <SatCatItem>(); CommonData.MetadataTypeList = new List <string>(); CommonData.MetadataOptions1 = new List <string>(); CommonData.MetadataOptions2 = new List <string>(); CommonData.MetadataOptions3 = new List <string>(); CommonData.MetadataOptions4 = new List <string>(); CommonData.MetadataOptions5 = new List <string>(); CommonData.SatCatFofo = new List <string>(); ReadWrite.ReadSatCat(); } } try { //encode password and username string creds = "Basic " + Base64Encode(tb_userName.Text + ":" + tb_password.Text); List <string> allSsCs = tb_ssc.Text.Split(new char[] { '\r', '\n', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); for (int i = 0; i < allSsCs.Count; i++) { allSsCs[i] = allSsCs[i].Trim(); } if (allSsCs.Count > 0) { //build requestString //https://unifieddatalibrary.com/udl/elset?epoch=2020-01-01T00:00:00.000000Z..2020-01-05T00:00:00.000000Z&satNo=40258 string timeString = "epoch=" + dtp_start.Value.AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ss.000000Z") + ".." + dtp_end.Value.ToString("yyyy-MM-ddTHH:mm:ss.000000Z"); string satString = ""; for (int i = 0; i < allSsCs.Count; i++) { satString += "&satNo=" + int.Parse(allSsCs[i]).ToString("00000"); } //init connection and form request //TODO -- change to HTTPClient Class at some point HttpWebRequest zrequest = (HttpWebRequest)WebRequest.Create(_httpbaseUrl + timeString + satString); zrequest.Method = "GET"; zrequest.Headers["Authorization"] = creds; //get response WebResponse apiresponse = zrequest.GetResponse(); Stream zcontent = apiresponse.GetResponseStream(); if (zcontent != null) { //write file to temp directory StreamReader sr = new StreamReader(zcontent); string tempData = sr.ReadToEnd(); //StreamWriter tempfile = new StreamWriter(Path.Combine(workingUserDirectory, "UDLResponse.txt")); //tempfile.Write(sr.ReadToEnd()); //tempfile.Close(); sr.Close(); zcontent.Close(); apiresponse.Close(); //create satellites from source file JavaScriptSerializer zjss = new JavaScriptSerializer(); List <UdlJsonTleResponse> responseDataInFormat = zjss.Deserialize <List <UdlJsonTleResponse> >(tempData); Dictionary <string, List <UdlJsonTleResponse> > sourceListandData = new Dictionary <string, List <UdlJsonTleResponse> >(); for (int zz = 0; zz < responseDataInFormat.Count; zz++) { if (!sourceListandData.ContainsKey(responseDataInFormat[zz].Source)) { //doesnt exist, create it sourceListandData.Add(responseDataInFormat[zz].Source, new List <UdlJsonTleResponse>()); } //add to existing list sourceListandData[responseDataInFormat[zz].Source].Add(responseDataInFormat[zz]); } //create a tle file for each source foreach (string zsource in sourceListandData.Keys) { using (StreamWriter sw = new StreamWriter(Path.Combine(_workingUserDirectory, zsource + "_UDLResponse.tce"))) { for (int zz = 0; zz < sourceListandData[zsource].Count; zz++) { sw.WriteLine(sourceListandData[zsource][zz].Line1); sw.WriteLine(sourceListandData[zsource][zz].Line2); } sw.Close(); } //create satellites foreach (string ssc in allSsCs) { if (CreateSats.Checked) { try { CreateSatellite(ssc, zsource, Path.Combine(_workingUserDirectory, zsource + "_UDLResponse.tce")); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } } } //update label before creating satellites SafelyUpdateLabel("TLE File written " + Environment.NewLine + "Created Satellites"); //stkRoot.ExecuteCommand(string.Format("ImportTLEFile * \"{0}\" Merge On AutoPropagate On", Path.Combine(workingUserDirectory, "UDLResponse.tce"))); } else { SafelyUpdateLabel("No data returned " + Environment.NewLine + "Not Creating Satellites"); } } else { SafelyUpdateLabel("No SSCs were input..."); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } PopulateExistingConstellations(); }