private void SerialPortManager_dataRecived(Object sender, EventArgs e) { portManager.readData(incomingData); LIN linMessage = new LIN(incomingData); linMessageService.PrintIncomintMessage(linMessage.ToString()); }
public static int Execute(List <string> args) { if (args.Count < 1) { Console.WriteLine("Usage: DanganRonpaText_GraceNote -dumptxt text.lin out.txt"); return(-1); } if (args[0] == "-check") { return(Check(args[1])); } else if (args[0] == "-dumpinsertcheck") { int Alignment = 16; LinImport.Importer.Import(args[1], args[2], args[3]); LinExport.Exporter.Export(args[1], args[1] + ".new", args[2], Alignment, false, false); Byte[] OriginalFile = System.IO.File.ReadAllBytes(args[1]); LIN lin = new LIN(OriginalFile); lin.CreateFile(Alignment); return(Compare(OriginalFile, System.IO.File.ReadAllBytes(args[1] + ".new"), lin.UnalignedFilesize, args[1] + ".fail")); } else if (args[0] == "-dumptxt") { return(DumpTxt(args[1], args[2])); } return(-1); }
public static LIN AddLIN(this SegmentCollection doc) { var l = new LIN(); doc.Add(l); return(l); }
public static int Check(String Filename) { Byte[] OriginalFile = System.IO.File.ReadAllBytes(Filename); LIN lin = new LIN(OriginalFile); Byte[] RecreatedFile = lin.CreateFile(1024); LIN linOrig = new LIN(OriginalFile); return(Compare(OriginalFile, RecreatedFile, lin.UnalignedFilesize, Filename + ".fail")); }
public static int Import(String Filename, String NewDB, String GracesDB) { LIN lin; try { lin = new LIN(Filename); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Failed loading text file!"); return(-1); } Console.WriteLine("Importing..."); GraceNoteUtil.GenerateEmptyDatabase(NewDB); List <GraceNoteDatabaseEntry> Entries = new List <GraceNoteDatabaseEntry>(); string TextToInsert = ""; foreach (ScriptEntry s in lin.ScriptData) { if (s.Type == 0x02) { Entries.Add(new GraceNoteDatabaseEntry(TextToInsert, TextToInsert, "", -1, 1, "[Game Code]", 0)); Entries.Add(new GraceNoteDatabaseEntry(s.Text, s.Text, "", 0, 2, s.IdentifyString, 0)); TextToInsert = ""; continue; } TextToInsert = TextToInsert + s.FormatForGraceNote() + '\n'; } if (TextToInsert != null) { Entries.Add(new GraceNoteDatabaseEntry(TextToInsert, TextToInsert, "", -1, 1, "[Game Code]", 0)); } if (lin.UnreferencedText != null) { foreach (KeyValuePair <int, string> u in lin.UnreferencedText) { Entries.Add(new GraceNoteDatabaseEntry(u.Value, u.Value, "", 0, 3, "[Unreferenced Text]", u.Key)); } } GraceNoteDatabaseEntry.InsertSQL(Entries.ToArray(), "Data Source=" + NewDB, "Data Source=" + GracesDB); Console.WriteLine("Successfully imported entries!"); return(0); }
public static int DumpTxt(String Filename, String TxtFilename) { LIN lin; try { lin = new LIN(Filename); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Failed loading text file!"); return(-1); } List <string> Output = new List <string>(); foreach (ScriptEntry s in lin.ScriptData) { if (s.Type == 0x02) { Output.Add("Text: " + s.Text); } else { Output.Add(s.FormatForGraceNote()); } } if (lin.UnreferencedText != null) { foreach (KeyValuePair <int, string> u in lin.UnreferencedText) { Output.Add("Unreferenced Text (" + u.Value + "): " + u.Key); } } System.IO.File.WriteAllLines(TxtFilename, Output.ToArray()); return(0); }
public static int Export(String InFilename, String OutFilename, String DB, int Alignment, bool RefreshNames, bool RefreshCode) { LIN lin; try { lin = new LIN(InFilename); if (RefreshNames) { lin.ReinsertNamesIntoDatabase("Data Source=" + DB); } if (RefreshCode) { lin.ReinsertCodeIntoDatabase("Data Source=" + DB); } lin.GetSQL("Data Source=" + DB); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Failed loading text file!"); return(-1); } byte[] newfile = lin.CreateFile(Alignment); System.IO.File.WriteAllBytes(OutFilename, newfile); return(0); }
public static int AutoImport(List <string> args) { string dir = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfRebuild\umdimage.dat.ex\"; string voicedir = @"d:\_svn\GraceNote\GraceNote\Voices\"; string[] files = System.IO.Directory.GetFiles(dir); List <String> dbsToUp = new List <string>(); foreach (var x in nonstopDict) { string nonstopFile = GetFromSubstring(files, x.Key); string scriptFile = GetFromSubstring(files, x.Value); string scriptFileFilename = new System.IO.FileInfo(scriptFile).Name; string databaseId = scriptFileFilename.Substring(0, 4); string databaseFile = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfDB\DRBO" + databaseId; dbsToUp.Add("DRBO" + databaseId); //continue; LIN lin = new LIN(scriptFile); NonstopFile nonstop = new NonstopFile(nonstopFile); int lastScriptEntry = 0; foreach (var item in nonstop.items) { int stringId = item.data[(int)NonstopSingleStructure.StringID] + 1; int correspondingTextEntry = stringId * 2; int correspondingScriptEntry = correspondingTextEntry - 1; if (item.data[(int)NonstopSingleStructure.Type] == 0) { lastScriptEntry = correspondingTextEntry; } // --- insert comment info --- string comment = (string)SqliteUtil.SelectScalar( "Data Source=" + databaseFile, "SELECT comment FROM Text WHERE id = ?", new object[] { correspondingTextEntry }); bool weakpt = item.data[(int)NonstopSingleStructure.HasWeakPoint] > 0; comment = (comment == "" ? "" : comment + "\n\n") + "Autogenerated Info:\n" + (lastScriptEntry == 0 ? "Corresponds to file: " + scriptFileFilename : "") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "Normal Line\n" : "Background Noise\n") + (weakpt ? "Has a Weak Point\n" : "No Weakpoint\n") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF) != 255 ? "Shot with Evidence Bullet: " + item.data[(int)NonstopSingleStructure.ShootWithEvidence] + "\n" : "") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF) != 255 ? "Shot with Weak Point: " + item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] + "\n" : "") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF) == 255 && (item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF) == 255 ? "Can't be shot\n" : "") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "" : "Appears around Entry #" + lastScriptEntry + "\n") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "Sprite: " + DanganUtil.CharacterIdToName((byte)item.data[(int)NonstopSingleStructure.Character]) + " " + item.data[(int)NonstopSingleStructure.Sprite] + "\n" : "") ; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET comment = ?, updated = 1 WHERE id = ?", new object[] { comment, correspondingTextEntry }); // --- insert voice info --- string script = (string)SqliteUtil.SelectScalar( "Data Source=" + databaseFile, "SELECT english FROM Text WHERE id = ?", new object[] { correspondingScriptEntry }); string voicename; string voicefilecheck; byte charid = (byte)item.data[(int)NonstopSingleStructure.Character]; if (item.data[(int)NonstopSingleStructure.Type] == 0) { while (true) { string charac = DanganUtil.CharacterIdToName(charid); if (charac == "Naegi") { charac = "Neagi"; } voicename = "[" + charac + "] " + item.data[(int)NonstopSingleStructure.Chapter] + " " + (item.data[(int)NonstopSingleStructure.AudioSampleId] >> 8) + " " + (item.data[(int)NonstopSingleStructure.AudioSampleId] & 0xFF) + " 100"; voicefilecheck = voicedir + voicename + ".mp3"; if (System.IO.File.Exists(voicefilecheck)) { break; } charid = 0x12; } script += "<__END__>\n" + "<Voice: " + voicename + ">" ; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET english = ?, updated = 1 WHERE id = ?", new object[] { script, correspondingScriptEntry }); // update the header name thingy string header = DanganUtil.CharacterIdToName(charid); SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?", new object[] { header, correspondingTextEntry }); } else { string header = "Background Noise"; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?", new object[] { header, correspondingTextEntry }); } } } System.IO.File.WriteAllLines( @"d:\_svn\GraceNote\GraceNote\temp.txt", dbsToUp.ToArray()); return(0); }
/// <summary> /// Builds receiving advice. /// Original from https://ps.extra.chrysler.com/sites/itb-ebus/Documents/861GlobalCoreReturnSystemReceivingAdvice.pdf /// </summary> static TS861 BuildReceivingAdvice(string controlNumber) { var result = new TS861(); // Transaction Set Identifier Code = “861” // (Receiving Advice / Acceptance Certificate) // Transaction Set Control Number = 0002 result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "861"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Reference Identification = C000548241 // Date = 02 / 24 / 2009 // Transaction Set Purpose Code = “00” (Original) // Receiving Advice or Acceptance Certificate // = “3” (Disposition Advice) result.BRA = new BRA(); result.BRA.ReferenceIdentification_01 = "C000548241"; result.BRA.Date_02 = "20090224"; result.BRA.TransactionSetPurposeCode_03 = "00"; result.BRA.ReceivingAdviceorAcceptanceCertificateTypeCode_04 = "3"; // Repeating DTM result.DTM = new List <DTM>(); // Date/Time Qualifier = “050” (Received) // Date = 01 / 02 / 2009 // Time = 8:55 AM // Time Code = “ET” (Eastern Time) var dtm1 = new DTM(); dtm1.DateTimeQualifier_01 = "050"; dtm1.Date_02 = "20090102"; dtm1.Time_03 = "0855"; dtm1.TimeCode_04 = "ET"; result.DTM.Add(dtm1); // Repeating N1 Loops result.N1Loop = new List <Loop_N1_861>(); // Begin N1 Loop var n1Loop1 = new Loop_N1_861(); // Entity Identifier Code // = “SU” (Supplier / Manufacturer) // Identification Code Qualifier // = “92” (Assigned by Buyer or Buyer's Agent) // Identification Code = 43677 n1Loop1.N1 = new N1(); n1Loop1.N1.EntityIdentifierCode_01 = "SU"; n1Loop1.N1.IdentificationCodeQualifier_03 = "92"; n1Loop1.N1.IdentificationCode_04 = "43677"; // End N1 Loop result.N1Loop.Add(n1Loop1); // Repeating RCD Loops result.RCDLoop = new List <Loop_RCD_861>(); // Begin RCD Loop var rcdLoop = new Loop_RCD_861(); // Quantity in Question = 1 // Unit or Basis for Measurement Code // = “EA” (Each) // Receiving Condition Code = 09 rcdLoop.RCD = new RCD(); rcdLoop.RCD.QuantityinQuestion_06 = "1"; rcdLoop.RCD.CompositeUnitofMeasure_07 = new C001(); rcdLoop.RCD.CompositeUnitofMeasure_07.UnitorBasisforMeasurementCode_01 = "EA"; rcdLoop.RCD.ReceivingConditionCode_08 = "09"; // Repeating LIN rcdLoop.LIN = new List <LIN>(); // Product/Service ID Qualifier // = “BP” (Buyer's Part Number) // Product / Service ID = U0070062 var lin1 = new LIN(); lin1.ProductServiceIDQualifier_02 = "BP"; lin1.ProductServiceID_03 = "U0070062"; rcdLoop.LIN.Add(lin1); // Repeating REF rcdLoop.REF = new List <REF>(); // Reference Identification Qualifier // = “ACC” (Status) // Reference Identification = A var ref1 = new REF(); ref1.ReferenceIdentificationQualifier_01 = "ACC"; ref1.ReferenceIdentification_02 = "A"; rcdLoop.REF.Add(ref1); // Repeating DTM rcdLoop.DTM = new List <DTM>(); // Date/Time Qualifier = “945” (Activity) // Date = 01 / 02 / 2009 // Time = 8:55 AM // Time Code = “ET” (Eastern Time) var dtm2 = new DTM(); dtm2.DateTimeQualifier_01 = "945"; dtm2.Date_02 = "20090102"; dtm2.Time_03 = "0855"; dtm2.TimeCode_04 = "ET"; rcdLoop.DTM.Add(dtm2); // End RCD Loop result.RCDLoop.Add(rcdLoop); return(result); }
public static void Test1() { var symbols = new E6Pos().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "DECL E6POS XP1={X -132.307266,Y -427.616180,Z 1162.82056,A 95.0179,B -1.98647153,C 1.45468986,S 6,T 50,E1 0.0,E2 0.0,E3 0.0,E4 0.0,E5 0.0,E6 0.0}" } }); Debug.Assert(symbols != null); symbols = new FDAT().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "DECL FDAT FP1={TOOL_NO 1,BASE_NO 0,IPO_FRAME #BASE,POINT2[] \" \",TQ_STATE FALSE}" } }); Debug.Assert(symbols != null); symbols = new PDAT().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "DECL PDAT PPDAT3={VEL 100.000,ACC 100.000,APO_DIST 100.000,APO_MODE #CDIS,GEAR_JERK 50.0000,EXAX_IGN 0}" } }); Debug.Assert(symbols != null); symbols = new LDAT().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "DECL LDAT LCPDAT14={VEL 2.00000,ACC 100.000,APO_DIST 100.000,APO_FAC 50.0000,AXIS_VEL 100.000,AXIS_ACC 100.000,ORI_TYP #VAR,CIRC_TYP #BASE,JERK_FAC 50.0000,GEAR_JERK 50.0000,EXAX_IGN 0}" } }); Debug.Assert(symbols != null); symbols = new SetFDAT().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "FDAT_ACT=FP38" } }); Debug.Assert(symbols != null); symbols = new SetPDAT().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "PDAT_ACT=PPDAT36" } }); Debug.Assert(symbols != null); symbols = new SetLDAT().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "LDAT_ACT=LCPDAT14" } }); Debug.Assert(symbols != null); symbols = new SetPTPParams().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "BAS(#PTP_PARAMS,30)" } }); Debug.Assert(symbols != null); symbols = new SetCPParams().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "BAS(#CP_PARAMS,0.2)" } }); Debug.Assert(symbols != null); symbols = new PTP().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "PTP XP40 C_DIS" } }); Debug.Assert(symbols != null); symbols = new LIN().Parse(new Dictionary <string, object>() { { "file", "" }, { "line", 0 }, { "column", 0 }, { "text", "LIN XP40 C_DIS" } }); Debug.Assert(symbols != null); }