Ejemplo n.º 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);
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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 + ");");
 }
Ejemplo n.º 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();");
     }
 }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
 public void Visit(TypeBinary type)
 {
     sw.WriteLine(prefix + "this." + variable.Name + " = new Uint8Array(0);");
 }
Ejemplo n.º 9
0
 void Visitor.Visit(TypeBinary type)
 {
 }
Ejemplo n.º 10
0
 void Visitor.Visit(TypeBinary type)
 {
     ChangeVariableCollectorName = "Zeze.Transaction.ChangeVariableCollectorChanged()";
 }
Ejemplo n.º 11
0
 public void Visit(TypeBinary type)
 {
     text = varname + ".GetHashCode()";
 }
Ejemplo n.º 12
0
 public void Visit(TypeBinary type)
 {
     DefineStack(type);
 }
Ejemplo n.º 13
0
 void Visitor.Visit(TypeBinary type)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 public void Visit(TypeBinary type)
 {
     WriteProperty(type);
 }
Ejemplo n.º 15
0
 public GameOfLife(int x, int y, TypeBinary type) : base(x, y)
 {
     Status = BeforeStatus = type;
 }
Ejemplo n.º 16
0
 public Rule30(int x, int y, TypeBinary type) : base(x, y)
 {
     Status = BeforeStatus = type;
 }
Ejemplo n.º 17
0
 public void Visit(TypeBinary type)
 {
     WriteLogValue(type);
 }
Ejemplo n.º 18
0
 void Visitor.Visit(TypeBinary type)
 {
     Value = "null";
 }
Ejemplo n.º 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("..");
        }
Ejemplo n.º 20
0
 void Visitor.Visit(TypeBinary type)
 {
     Type = Zeze.Serialize.ByteBuffer.BYTES;
 }
Ejemplo n.º 21
0
 public void Visit(TypeBinary type)
 {
     name = "Zeze.Net.Binary";
 }
Ejemplo n.º 22
0
 void Visitor.Visit(TypeBinary type)
 {
     Name = "Zeze.ByteBuffer.BYTES";
 }
Ejemplo n.º 23
0
 public void Visit(TypeBinary type)
 {
     name = "Uint8Array";
 }
Ejemplo n.º 24
0
 public void Visit(TypeBinary type)
 {
     sw.WriteLine(prefix + variable.NamePrivate + " = Zeze.Net.Binary.Empty;");
 }
Ejemplo n.º 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);");
 }