Beispiel #1
0
        private bool IsShapeBasedComponentBodies6(byte[] data)
        {
            string str = Encoding.Default.GetString(data);

            return(str.Contains("MODEL.CHECKSUM="));

            TypeBinary typebinary = ByteArrayToStructure <TypeBinary>(data);

            if (typebinary.Type != 0x0C)
            {
                return(false);
            }
            if (typebinary.Next + 5 > data.Length)
            {
                return(false);
            }
            if (typebinary.Next + 5 == data.Length)
            {
                return(true);
            }
            if (data[typebinary.Next + 5] != 0x0C)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
 public void Visit(TypeBinary type)
 {
     sw.WriteLine(prefix + "public " + TypeName.GetName(type) + " " + var.NameUpper1);
     sw.WriteLine(prefix + "{");
     sw.WriteLine(prefix + "    get");
     sw.WriteLine(prefix + "    {");
     sw.WriteLine(prefix + "        if (false == this.IsManaged)");
     sw.WriteLine(prefix + "            return " + var.NamePrivate + ";");
     sw.WriteLine(prefix + "        var txn = Zeze.Transaction.Transaction.Current;");
     sw.WriteLine(prefix + "        if (txn == null) return " + var.NamePrivate + ";");
     sw.WriteLine(prefix + "        txn.VerifyRecordAccessed(this, true);");
     sw.WriteLine(prefix + "        var log = (Log_" + var.NamePrivate + ")txn.GetLog(this.ObjectId + " + var.Id + ");");
     sw.WriteLine(prefix + "        return log != null ? log.Value : " + var.NamePrivate + ";");
     sw.WriteLine(prefix + "    }");
     sw.WriteLine(prefix + "    set");
     sw.WriteLine(prefix + "    {");
     sw.WriteLine(prefix + "        if (null == value) throw new System.ArgumentNullException();");
     sw.WriteLine(prefix + "        if (false == this.IsManaged)");
     sw.WriteLine(prefix + "        {");
     sw.WriteLine(prefix + "            " + var.NamePrivate + " = value;");
     sw.WriteLine(prefix + "            return;");
     sw.WriteLine(prefix + "        }");
     sw.WriteLine(prefix + "        var txn = Zeze.Transaction.Transaction.Current;");
     sw.WriteLine(prefix + "        txn.VerifyRecordAccessed(this);");
     sw.WriteLine(prefix + "        txn.PutLog(new Log_" + var.NamePrivate + "(this, value));"); //
     sw.WriteLine(prefix + "    }");
     sw.WriteLine(prefix + "}");
     sw.WriteLine();
 }
Beispiel #3
0
 public void Visit(TypeBinary type)
 {
     if (id >= 0)
     {
         sw.WriteLine(prefix + bufname + ".WriteInt(Zeze.ByteBuffer.BYTES | " + id + " << Zeze.ByteBuffer.TAG_SHIFT);");
     }
     sw.WriteLine(prefix + bufname + ".WriteBytes(" + varname + ");");
 }
Beispiel #4
0
 void Visitor.Visit(TypeBinary type)
 {
     if (id >= 0)
     {
         sw.WriteLine(prefix + "case (Zeze.ByteBuffer.BYTES | " + id + " << Zeze.ByteBuffer.TAG_SHIFT): ");
         sw.WriteLine(prefix + "    " + varname + " = " + bufname + ".ReadBytes();");
         sw.WriteLine(prefix + "    break;");
     }
     else
     {
         sw.WriteLine(prefix + varname + " = " + bufname + ".ReadBytes();");
     }
 }
Beispiel #5
0
        public void NextStatus()
        {
            int count = 0;

            if (((GameOfLife)Top).BeforeStatus == TypeBinary.life)
            {
                count++;
            }
            if (((GameOfLife)TopLeft).BeforeStatus == TypeBinary.life)
            {
                count++;
            }
            if (((GameOfLife)TopRight).BeforeStatus == TypeBinary.life)
            {
                count++;
            }
            if (((GameOfLife)Left).BeforeStatus == TypeBinary.life)
            {
                count++;
            }
            if (((GameOfLife)Right).BeforeStatus == TypeBinary.life)
            {
                count++;
            }
            if (((GameOfLife)Bottom).BeforeStatus == TypeBinary.life)
            {
                count++;
            }
            if (((GameOfLife)BottomLeft).BeforeStatus == TypeBinary.life)
            {
                count++;
            }
            if (((GameOfLife)BottomRight).BeforeStatus == TypeBinary.life)
            {
                count++;
            }

            //System.Windows.Forms.MessageBox.Show(string.Format("x: {0}, y: {1}, vecinos : {2},  estado: {3}, estado: {4}", X, Y, count, BeforeStatus, Status));
            if (((count >= 2 && count <= 3) && BeforeStatus == TypeBinary.life) || (count == 3 && BeforeStatus == TypeBinary.death))
            {
                Status = TypeBinary.life;
            }
            else
            {
                Status = TypeBinary.death;
            }
        }
Beispiel #6
0
        public void NextStatus()
        {
            if (Status == TypeBinary.life)
            {
                return;
            }
            int count = 0;

            if (((Rule30)TopLeft).BeforeStatus == TypeBinary.life &&
                ((Rule30)Top).BeforeStatus == TypeBinary.death &&
                ((Rule30)TopRight).BeforeStatus == TypeBinary.death)
            {
                //caso 4
                count = 1;
            }
            else if (((Rule30)TopLeft).BeforeStatus == TypeBinary.death &&
                     ((Rule30)Top).BeforeStatus == TypeBinary.life &&
                     ((Rule30)TopRight).BeforeStatus == TypeBinary.life)
            {
                //caso 5
                count = 1;
            }
            else if (((Rule30)TopLeft).BeforeStatus == TypeBinary.death &&
                     ((Rule30)Top).BeforeStatus == TypeBinary.life &&
                     ((Rule30)TopRight).BeforeStatus == TypeBinary.death)
            {
                //caso 6
                count = 1;
            }
            else if (((Rule30)TopLeft).BeforeStatus == TypeBinary.death &&
                     ((Rule30)Top).BeforeStatus == TypeBinary.death &&
                     ((Rule30)TopRight).BeforeStatus == TypeBinary.life)
            {
                //caso 7
                count = 1;
            }

            if (count == 1)
            {
                Status = TypeBinary.life;
            }
            else
            {
                Status = TypeBinary.death;
            }
        }
Beispiel #7
0
        private bool IsArcs6(byte[] data)
        {
            TypeBinary typebinary = ByteArrayToStructure <TypeBinary>(data);

            if (typebinary.Type != 1)
            {
                return(false);
            }
            if (typebinary.Next > data.Length)
            {
                return(false);
            }
            if (data[typebinary.Next + 5] != 1)
            {
                return(false);
            }
            return(true);
        }
Beispiel #8
0
 public void Visit(TypeBinary type)
 {
     sw.WriteLine(prefix + "this." + variable.Name + " = new Uint8Array(0);");
 }
Beispiel #9
0
 void Visitor.Visit(TypeBinary type)
 {
 }
Beispiel #10
0
 void Visitor.Visit(TypeBinary type)
 {
     ChangeVariableCollectorName = "Zeze.Transaction.ChangeVariableCollectorChanged()";
 }
Beispiel #11
0
 public void Visit(TypeBinary type)
 {
     text = varname + ".GetHashCode()";
 }
Beispiel #12
0
 public void Visit(TypeBinary type)
 {
     DefineStack(type);
 }
Beispiel #13
0
 void Visitor.Visit(TypeBinary type)
 {
     throw new NotImplementedException();
 }
Beispiel #14
0
 public void Visit(TypeBinary type)
 {
     WriteProperty(type);
 }
Beispiel #15
0
 public GameOfLife(int x, int y, TypeBinary type) : base(x, y)
 {
     Status = BeforeStatus = type;
 }
Beispiel #16
0
 public Rule30(int x, int y, TypeBinary type) : base(x, y)
 {
     Status = BeforeStatus = type;
 }
Beispiel #17
0
 public void Visit(TypeBinary type)
 {
     WriteLogValue(type);
 }
Beispiel #18
0
 void Visitor.Visit(TypeBinary type)
 {
     Value = "null";
 }
Beispiel #19
0
        void CMConvert(CompoundFile cf)
        {
            IList <IDirectoryEntry> entries = cf.GetDirectories();

            // extract Circuit maker files and then try and rename directories
            // to match .pcbdoc entries
            string CurrentDir = "";

            foreach (var entry in entries)
            {
                if (false && entry.Name == "Root Entry")
                {
                    DirectoryInfo Info = Directory.CreateDirectory(entry.Name);
                    if (!Info.Exists)
                    {
                        // for some reason the create directory failed so try again
                        Info = Directory.CreateDirectory(entry.Name);
                    }
                    Thread.Sleep(500); // TODO this is a frig sort out
                    ClearFolder(entry.Name);
                    Directory.SetCurrentDirectory(entry.Name);
                    CurrentDir = entry.Name;
                }
                else
                {
                    if (entry.StgType == StgType.StgStorage)
                    {
                        CurrentDir = entry.Name;
                        //                  Directory.CreateDirectory(entry.Name);
                        CFStorage storage    = cf.RootStorage.TryGetStorage(entry.Name);
                        CFStream  datastream = storage.GetStream("Data");
                        // get file contents and write to file
                        byte[] data = datastream.GetData();
                        if (data.Length == 0)
                        {
                            OutputString($"Deleted '{CurrentDir}' no data");
                            // remove empty directory
                            //                     Directory.Delete(CurrentDir);
                        }
                        else
                        {
                            // create the file
                            //                        File.WriteAllBytes(CurrentDir + "\\" + "Data.dat", data);
                            // now try and determine which file it is by examining the contents
                            TextFile   textfile   = ByteArrayToStructure <TextFile>(data);
                            TypeBinary typebinary = ByteArrayToStructure <TypeBinary>(data);
                            TextFile2  textfile2  = ByteArrayToStructure <TextFile2>(data);
                            if (IsPads(data))
                            {
                                RenameDirectory(CurrentDir, "Pads6", data);
                            }
                            else
                            if (IsVias(data))
                            {
                                RenameDirectory(CurrentDir, "Vias6", data);
                            }
                            else
                            if (IsTracks(data))
                            {
                                RenameDirectory(CurrentDir, "Tracks6", data);
                            }
                            else
                            if (IsComponentBodies(data))
                            {
                                RenameDirectory(CurrentDir, "ComponentBodies6", data);
                            }
                            else
                            if (IsBoard6(data))
                            {
                                RenameDirectory(CurrentDir, "Board6", data);
                            }
                            else
                            if (IsPolygons6(data))
                            {
                                RenameDirectory(CurrentDir, "Polygons6", data);
                            }
                            else
                            if (IsShapeBasedComponentBodies6(data))
                            {
                                RenameDirectory(CurrentDir, "ShapeBasedComponentBodies6", data);
                            }
                            else
                            if (IsArcs6(data))
                            {
                                RenameDirectory(CurrentDir, "Arcs6", data);
                            }
                            else
                            if (IsTexts6(data))
                            {
                                RenameDirectory(CurrentDir, "Texts6", data);
                            }
                            else
                            if (IsDimensions6(data))
                            {
                                RenameDirectory(CurrentDir, "Dimensions6", data);
                            }
                            else
                            if (IsRules6(data))
                            {
                                RenameDirectory(CurrentDir, "Rules6", data);
                            }
                            else
                            if (IsModels6(data))
                            {
                                RenameDirectory(CurrentDir, "Models", data);
                                // now need to get all of the model files
                                CFStream models;
                                byte[]   modeldata;
                                int      i = 0;
                                while ((models = storage.TryGetStream($"{i}")) != null)
                                {
                                    OutputString($"Creating {i}.dat model file");
                                    // get file contents and write to file
                                    modeldata = models.GetData();
                                    // uncompress the x.dat file to a .step file
                                    // step file is renamed to it's actual name later in the process
                                    //                 string Inflated = ZlibCodecDecompress(modeldata);
                                    //                 File.WriteAllText($"Models\\{i}.step", Inflated);
                                    i++;
                                }
                            }
                            else
                            if ((textfile2.type == 0x0001 && textfile2.Length < data.Length) || textfile.Length < data.Length)
                            {
                                // could be text file
                                string str = Encoding.Default.GetString(data);
                                if (str.Contains("ORIGINX"))
                                {
                                    RenameDirectory(CurrentDir, "Board6", data);
                                }
                                else
                                if (str.Contains("AdvancedPlacerOptions"))
                                {
                                    RenameDirectory(CurrentDir, "Advanced Placer Options6", data);
                                }
                                else
                                if (str.Contains("SUPERCLASS"))
                                {
                                    RenameDirectory(CurrentDir, "Classes6", data);
                                }
                                else
                                if (str.Contains("SOURCEFOOTPRINTLIBRARY"))
                                {
                                    RenameDirectory(CurrentDir, "Components6", data);
                                }
                                else
                                if (str.Contains("DesignRuleCheckerOptions"))
                                {
                                    RenameDirectory(CurrentDir, "Design Rule Checker Options6", data);
                                }
                                else
                                if (str.Contains("POSITIVENETNAME"))
                                {
                                    RenameDirectory(CurrentDir, "DifferentialPairs6", data);
                                }
                                else
                                if (str.Contains("FWDMSG"))
                                {
                                    RenameDirectory(CurrentDir, "FileVersionInfo", data);
                                }
                                else
                                if (str.Contains("LOOPREMOVAL="))
                                {
                                    RenameDirectory(CurrentDir, "Nets6", data);
                                }
                                else
                                if (str.Contains("PinSwapOptions"))
                                {
                                    RenameDirectory(CurrentDir, "Pin Swap Option6", data);
                                }
                                else
                                if (str.Contains("REMOVEDEAD"))
                                {
                                    RenameDirectory(CurrentDir, "Polygons6", data);
                                }
                                else
                                {
                                    OutputError($"Failed to convert possible text file '{CurrentDir}'");
                                }
                            }
                            else if (typebinary.Next < data.Length)
                            {
                                if (typebinary.Type == 0x03)
                                {
                                    RenameDirectory(CurrentDir, "Vias6", data);
                                }
                                else
                                if (typebinary.Type == 0x04)
                                {
                                    RenameDirectory(CurrentDir, "Tracks6", data);
                                }
                                else
                                if (typebinary.Type == 0x0B)
                                {
                                    RenameDirectory(CurrentDir, "Regions6", data);
                                }
                                else
                                if (typebinary.Type == 0x06)
                                {
                                    RenameDirectory(CurrentDir, "Fills6", data);
                                }
                                else
                                {
                                    OutputError($"Failed to convert possible binary file '{CurrentDir}'");
                                }
                            }
                        }
                    }

                    /*
                     * else
                     * if (entry.StgType == StgType.StgStream)
                     * {
                     *  CFStream stream = cf.RootStorage.TryGetStream(CurrentDir + "\\" + entry.Name);
                     *  if (stream != null && stream.Size != 0)
                     *  {
                     *      var data = new byte[stream.Size];
                     *      stream.Read(data, 0, data.Length);
                     *      File.WriteAllBytes(CurrentDir + "\\" + entry.Name, data);
                     *  }
                     * }
                     */
                }
                //    cf.RootStorage..DirEntry.EntryName.
                //OutputString($"{entry.ToString()}");
            }
            Directory.SetCurrentDirectory("..");
        }
Beispiel #20
0
 void Visitor.Visit(TypeBinary type)
 {
     Type = Zeze.Serialize.ByteBuffer.BYTES;
 }
Beispiel #21
0
 public void Visit(TypeBinary type)
 {
     name = "Zeze.Net.Binary";
 }
Beispiel #22
0
 void Visitor.Visit(TypeBinary type)
 {
     Name = "Zeze.ByteBuffer.BYTES";
 }
Beispiel #23
0
 public void Visit(TypeBinary type)
 {
     name = "Uint8Array";
 }
Beispiel #24
0
 public void Visit(TypeBinary type)
 {
     sw.WriteLine(prefix + variable.NamePrivate + " = Zeze.Net.Binary.Empty;");
 }
Beispiel #25
0
 void Visitor.Visit(TypeBinary type)
 {
     sw.WriteLine(prefix + $"sb.Append(new string(' ', level * 4)).Append(\"{var}\").Append(\"=\").Append({var}).Append(\"{sep}\").Append(Environment.NewLine);");
 }