Exemplo n.º 1
0
        public bool TestAttrGeneric()
        {
            NcFile file1 = null;
            NcFile file2 = null;
            NcAtt  attr1;
            NcAtt  attr2;

            UInt64[] buffer1 = new UInt64[1];
            UInt64[] buffer2 = new UInt64[1];
            try {
                file1 = TestHelper.NewFile(filePath);
                file2 = TestHelper.NewFile("other" + filePath);
                attr1 = file1.PutAtt("ConventionCount", NcUint64.Instance, 2);
                attr2 = file2.PutAtt(attr1);
                Assert.Equals(attr1.GetAttLength(), attr2.GetAttLength());
                Assert.Equals(attr1.GetName(), attr2.GetName());
                attr1.GetValues(buffer1);
                attr2.GetValues(buffer2);
                Assert.Equals(buffer1, buffer2);
                attr1 = file1.PutAtt("Other", "StringThing");
                Assert.False(attr1.IsNull());
                attr2 = file2.PutAtt(attr1);
                Assert.False(attr2.IsNull());
                Assert.Equals(attr1.GetValues(), attr2.GetValues());
            } finally {
                file1.Close();
                file2.Close();
            }
            CheckDelete(filePath);
            CheckDelete("other" + filePath);
            return(true);
        }
Exemplo n.º 2
0
        public bool TestGetGroupCount()
        {
            NcGroup group;
            NcFile  file = null;

            try {
                file  = newFile(filePath);
                group = file;
                int groupCount;
                groupCount = group.GetGroupCount(GroupLocation.AllGrps);
                Assert.Equals(groupCount, 1); // Only the root group/file so no groups are defined
                NcGroup childGroup = group.AddGroup("child1");
                Assert.False(childGroup.IsNull());
                Assert.Equals(group.GetGroupCount(GroupLocation.AllGrps), 2);
                Dictionary <string, NcGroup> groups = group.GetGroups(GroupLocation.AllGrps);
                for (int i = 0; i < groups.Count; i++)
                {
                    KeyValuePair <string, NcGroup> k = groups.ElementAt(i);
                    if (i == 0)
                    {
                        Assert.Equals(k.Key, "/");
                    }
                    else if (i == 1)
                    {
                        Assert.Equals(k.Key, "child1");
                    }
                }
            } finally {
                file.Close();
            }

            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 3
0
        public void NcFile_defCtor_notnull()
        {
            var ncfile = new NcFile();

            Assert.IsNotNull(ncfile);
            Assert.AreEqual(0, ncfile.Count);
        }
Exemplo n.º 4
0
        public bool TestVarGeneric()
        {
            NcFile file = null;

            try {
                file = TestHelper.NewFile(filePath);
                NcDim dim1    = file.AddDim("dim1", 5);
                NcVar testVar = file.AddVar("var1", "double", "dim1");
                Assert.False(testVar.IsNull());
                testVar = file.AddVar("var2", NcDouble.Instance, dim1);
                Assert.False(testVar.IsNull());
                testVar = file.AddVar("var3", "double", new List <string>()
                {
                    "dim1"
                });
                Assert.False(testVar.IsNull());
                testVar = file.AddVar("var4", NcDouble.Instance, new List <NcDim>()
                {
                    dim1
                });
                Assert.False(testVar.IsNull());
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 5
0
        public void NcFile_multiLine_countOK()
        {
            var ncfile = new NcFile();
            var mp1    = new MachinePosition()
            {
                X = 1, Adeg = 0
            };
            var mp2 = new MachinePosition()
            {
                X = 1, Adeg = 360
            };
            var f1 = new Feedrate(FeedrateUnits.InPerMin)
            {
                Value = 20
            };
            var f2 = new Feedrate(FeedrateUnits.InverseMins)
            {
                Value = 2
            };
            var ncp1      = new NcPositionCommand(10, mp1, f1, BlockType.LINEAR);
            var ncp2      = new NcPositionCommand(20, mp2, f2, BlockType.LINEAR);
            var ncMachine = new NcMachine(ControllerType.FAGOR8055, MachineGeometry.XA);

            ncfile.Add(ncp1);
            ncfile.Add(ncp2);
            var file = ncfile.AsNcTextFile(ncMachine);

            Assert.AreEqual(2, ncfile.Count);
            Assert.AreEqual(5, file.Count);
        }
Exemplo n.º 6
0
 public static String NewDocXFile(String FileFullName, NcFile ncFile, NcFileDetails ncFileDetails, NcFileFix ncFileFix)
 {
     try
     {
         DocX templateDocument = DocX.Load(@"NcFileDetail.docx");
         foreach (Paragraph paragraph in templateDocument.Paragraphs)
         {
             paragraph.ReplaceText("<Titre-NC>", ncFile.case_title);
             paragraph.ReplaceText("<Createur>", ncFile.nc_user_full_Name);
             paragraph.ReplaceText("<Structure>", ncFile.structure_name);
             paragraph.ReplaceText("<Description>", ncFileDetails.description);
             paragraph.ReplaceText("<N-plan>", ncFileDetails.n_plan);
             paragraph.ReplaceText("<Ens-Partiel>", ncFileDetails.partial_set);
             paragraph.ReplaceText("<Source>", ncFile.source? "interne" : "externe");
             paragraph.ReplaceText("<Date-Creation>", ncFile.creation_date);
             paragraph.ReplaceText("<Cause>", ncFileFix.cause);
             paragraph.ReplaceText("<Description-Action>", ncFileFix.action_description);
             paragraph.ReplaceText("<Type-Action>", ncFileFix.action_type == 1? "correction" : "corrective");
             paragraph.ReplaceText("<Responsable-Action>", ncFileFix.fixer_full_name);
             paragraph.ReplaceText("<Fonction-Responsable-Action>", ncFileFix.fixer_function);
             paragraph.ReplaceText("<Structure-Responsable-Action>", ncFileFix.fixer_structure_name);
             paragraph.ReplaceText("<Temp-Planifie-Debut>", ncFileFix.estimated_start_date);
             paragraph.ReplaceText("<Temp-Planifie-Fin>", ncFileFix.estimated_end_date);
         }
         templateDocument.SaveAs(FileFullName);
         return("ok");
     }
     catch (Exception e) { return(e.Message); }
 }
Exemplo n.º 7
0
        public bool TestGetCoordVars()
        {
            NcFile file = null;

            try {
                file = TestHelper.NewFile(filePath);
                NcDim dim1 = file.AddDim("time", 20);
                NcDim dim2 = file.AddDim("hdg", 20);

                NcVar var1 = file.AddVar("time", NcDouble.Instance, dim1);
                Assert.False(var1.IsNull());
                NcVar var2 = file.AddVar("hdg", NcDouble.Instance, dim2);
                Assert.False(var2.IsNull());
                NcVar var3 = file.AddVar("alt", NcDouble.Instance, new List <NcDim>()
                {
                    dim1, dim2
                });
                Assert.False(var3.IsNull());

                Dictionary <string, NcGroup> coordVars = file.GetCoordVars();
                Assert.True(coordVars.ContainsKey("time") && coordVars["time"].GetId() == file.GetId());
                Assert.True(coordVars.ContainsKey("hdg") && coordVars["hdg"].GetId() == file.GetId());
                Assert.False(coordVars.ContainsKey("alt"));
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 8
0
        public bool TestStrictChecking()
        {
            NcFile file = null;
            NcDim  dim1 = null;
            NcVar  var1 = null;

            Int32[] buffer = new Int32[20];
            for (int i = 0; i < 20; i++)
            {
                buffer[i] = i;
            }
            try {
                FileSetup(ref file, ref dim1, ref var1);
                var1.PutVar(buffer);
                buffer = new Int32[15]; // Squeeze it
                try {
                    var1.GetVar(buffer);
                    // If it gets to here the program will crash hard anyway
                    throw new AssertFailedException("BufferOverflow exception not raised");
                } catch (NcBufferOverflow) {
                    // yay it worked
                }
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 9
0
        public bool TestGetGroups()
        {
            NcGroup group;
            NcFile  file = null;

            NcGroup child1_1;
            NcGroup child1_2;

            try {
                file  = newFile(filePath);
                group = file;
                /* -- Check differentiability for GetGroup -- */
                child1_1 = file.AddGroup("group1");
                file.AddGroup("group2");

                group = file.GetGroup("group1");
                Assert.Equals(group.GetName(), "group1");
                /* -- Check that sets work for GetGroups -- */
                child1_2 = child1_1.AddGroup("group1"); // Second one named group1
                HashSet <NcGroup> groups = file.GetGroups("group1");
                foreach (NcGroup g in groups)
                {
                    if (g.GetId() != child1_1.GetId() && g.GetId() != child1_2.GetId())
                    {
                        throw new AssertFailedException("Incorrect group in set");
                    }
                }
            } finally {
                file.Close();
            }

            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 10
0
        public bool TestUInt64Var()
        {
            NcFile file = null;
            NcDim  dim1 = null;
            NcVar  var1 = null;

            UInt64[] buffer     = new UInt64[20];
            UInt64[] readBuffer = new UInt64[20];
            for (int i = 0; i < 20; i++)
            {
                buffer[i] = (UInt64)i;
            }
            try {
                FileSetup(ref file, ref dim1, ref var1, NcUint64.Instance);
                // Test the basic get/put
                var1.PutVar(buffer);
                var1.GetVar(readBuffer);
                for (int i = 0; i < 20; i++)
                {
                    Assert.Equals(readBuffer[i], buffer[i]);
                }
                // test get and put scalars
                var1.PutVar(new Int32[] { 5 }, new UInt64[] { 30 });
                var1.GetVar(new Int32[] { 5 }, readBuffer);
                Assert.Equals(readBuffer[0], (UInt64)30);
                // test get and put 1d arrays
                var1.PutVar(new Int32[] { 2 }, new Int32[] { 4 }, new UInt64[] { 20, 20, 20, 20 });
                var1.GetVar(new Int32[] { 2 }, new Int32[] { 4 }, readBuffer);
                Assert.Equals(readBuffer[0], (UInt64)20);
                Assert.Equals(readBuffer[3], (UInt64)20);
                var1.GetVar(readBuffer);
                Assert.Equals(readBuffer[0], (UInt64)0);
                Assert.Equals(readBuffer[2], (UInt64)20);
                Assert.Equals(readBuffer[5], (UInt64)20);
                Assert.Equals(readBuffer[6], (UInt64)6);

                // test striding
                var1.PutVar(new Int32[] { 10 }, new Int32[] { 5 }, new Int32[] { 2 }, new UInt64[] { 40, 40, 40 });
                var1.GetVar(new Int32[] { 10 }, new Int32[] { 5 }, new Int32[] { 2 }, readBuffer);
                Assert.Equals(readBuffer[0], (UInt64)40);
                Assert.Equals(readBuffer[2], (UInt64)40);
                var1.GetVar(readBuffer);
                Assert.Equals(readBuffer[10], (UInt64)40);
                Assert.Equals(readBuffer[12], (UInt64)40);
                Assert.Equals(readBuffer[14], (UInt64)40);
                Assert.Equals(readBuffer[15], (UInt64)15);
                // Test ranges
                var1.PutVar(new Int32[] { 0 }, new ulong[] { 18446744073709551615L });
                try {
                    var1.PutVar(new Int32[] { 0 }, new long[] { -1 });
                    throw new AssertFailedException("Failed to raise NcRange exception.");
                } catch (NcRange) {
                }
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 11
0
        public static NcFile NewFile(string filePath)
        {
            NcFile file;

            CheckDelete(filePath);
            file = new NcFile(filePath, NcFileMode.replace, NcFileFormat.nc4);
            return(file);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 取得 nc 檔的資訊內容
        /// </summary>
        /// <param name="ncFilePath"></param>
        /// <returns></returns>
        public string GetNcFileinfo(string ncFilePath)
        {
            StringBuilder sb = new StringBuilder();

            NcFile ncFile = new NcFile(ncFilePath);

            sb.AppendLine($"開始讀取 nc 檔 - {ncFilePath}\n");
            sb.AppendLine(String.Format("Global attributes ({0})", ncFile.AttributeCount));
            //foreach (NcComponent curAtt in ncFile.Attributes)
            //    sb.AppendLine(curAtt.ToString());
            sb.AppendLine(string.Join(Environment.NewLine, ncFile.Attributes.ToList()));


            sb.AppendLine("\n----------------------------");
            sb.AppendLine(String.Format("Dimensions ({0})\n", ncFile.DimensionCount));
            foreach (NcDim curDim in ncFile.Dimensions)
            {
                if (curDim.IsUnlimited)
                {
                    sb.AppendLine(String.Format("{0}[{1}] (unlimited)", curDim.ComponentName, curDim.Size));
                }
                else
                {
                    sb.AppendLine(String.Format("{0}[{1}]", curDim.ComponentName, curDim.Size));
                }
            }

            sb.AppendLine("\n----------------------------");
            sb.AppendLine(String.Format("Variables ({0})", ncFile.VariableCount));
            foreach (NcVar curVar in ncFile.Variables)
            {
                sb.AppendLine("\n........................................");
                sb.AppendLine(String.Format("  NcType(Name)  >>  {0}({1})", curVar.NcType.ToString(), curVar.ComponentName));
                sb.AppendLine("........................................\n");


                sb.AppendLine(String.Format("  Elements: {0:###,###,###,###,###}", curVar.ElementCount));
                sb.AppendLine(String.Format("  Size: {0:###,###,###,###,###} (bytes)", curVar.Size));

                sb.AppendLine("\n  ........................................");
                sb.AppendLine(String.Format("  Attributes ({0})", curVar.Attributes.Count));
                for (int i = 0; i < curVar.Attributes.Count; i++)
                {
                    sb.AppendLine(String.Format("    Attributes[{0}][Name](ToString)  >>  [{1}]({2})", i, curVar.Attributes[i].ComponentName, curVar.Attributes[i].ToString()));
                }

                sb.AppendLine("\n  ........................................");
                sb.AppendLine(String.Format("\n  Dimensions ({0})", curVar.Dimensions.Count));
                for (int i = 0; i < curVar.Dimensions.Count; i++)
                {
                    sb.AppendLine(String.Format("    Dimensions[i][Name](Size)  >>  [{0}][{1}]({2})", i, curVar.Dimensions[i].ComponentName, curVar.Dimensions[i].Size));
                }
            }
            sb.AppendLine("----------------------------");

            return(sb.ToString());
        }
Exemplo n.º 13
0
 private void initializeData(NcFile ncFile, NcFileDetails ncFileDetails)
 {
     DescriptionTxt.Text  = ncFileDetails.description;
     caseTitleLabel.Text  = ncFile.case_title;
     userFullNameTxt.Text = ncFile.nc_user_full_Name;
     structureTxt.Text    = ncFile.structure_name;
     n_planTxt.Text       = ncFileDetails.n_plan;
     partial_setTxt.Text  = ncFileDetails.partial_set;
     sourceTxt.Text       = ncFile.source ? "Externe" : "Interne";
     creationDateTxt.Text = ncFile.creation_date.ToString();
 }
Exemplo n.º 14
0
        public bool TestDoubleVar()
        {
            NcFile file = null;
            NcDim  dim1 = null;
            NcVar  var1 = null;

            double[] buffer     = new double[20];
            double[] readBuffer = new double[20];
            for (int i = 0; i < 20; i++)
            {
                buffer[i] = (double)i;
            }
            try {
                FileSetup(ref file, ref dim1, ref var1, NcDouble.Instance);
                // Test the basic get/put
                var1.PutVar(buffer);
                var1.GetVar(readBuffer);
                for (int i = 0; i < 20; i++)
                {
                    Assert.Equals(readBuffer[i], buffer[i]);
                }
                // test get and put scalars
                var1.PutVar(new Int32[] { 5 }, new double[] { 30.0 });
                var1.GetVar(new Int32[] { 5 }, readBuffer);
                Assert.Equals(readBuffer[0], 30.0);
                // test get and put 1d arrays
                var1.PutVar(new Int32[] { 2 }, new Int32[] { 4 }, new double[] { 20.0, 20.0, 20.0, 20.0 });
                var1.GetVar(new Int32[] { 2 }, new Int32[] { 4 }, readBuffer);
                Assert.Equals(readBuffer[0], (double)20.0);
                Assert.Equals(readBuffer[3], (double)20.0);
                var1.GetVar(readBuffer);
                Assert.Equals(readBuffer[0], (double)0.0);
                Assert.Equals(readBuffer[2], (double)20.0);
                Assert.Equals(readBuffer[5], (double)20.0);
                Assert.Equals(readBuffer[6], (double)6.0);
                // test striding
                var1.PutVar(new Int32[] { 10 }, new Int32[] { 5 }, new Int32[] { 2 }, new double[] { 40, 40, 40 });
                var1.GetVar(new Int32[] { 10 }, new Int32[] { 5 }, new Int32[] { 2 }, readBuffer);
                Assert.Equals(readBuffer[0], (double)40);
                Assert.Equals(readBuffer[2], (double)40);
                var1.GetVar(readBuffer);
                Assert.Equals(readBuffer[10], (double)40);
                Assert.Equals(readBuffer[12], (double)40);
                Assert.Equals(readBuffer[14], (double)40);
                Assert.Equals(readBuffer[15], (double)15);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 15
0
        public bool TestSByteVar()
        {
            NcFile file = null;
            NcDim  dim1 = null;
            NcVar  var1 = null;

            sbyte[] buffer     = new sbyte[4];
            sbyte[] readBuffer = new sbyte[4];
            for (int i = 0; i < 4; i++)
            {
                buffer[i] = (sbyte)(i - 1);
            }
            try {
                FileSetup(ref file, ref dim1, ref var1, NcByte.Instance, 4);
                // Test the array get/put
                var1.PutVar(buffer);
                var1.GetVar(readBuffer);
                for (int i = 0; i < 4; i++)
                {
                    Assert.Equals(readBuffer[i], buffer[i]);
                }

                // Test get and put for scalars
                var1.PutVar(new Int32[] { 1 }, new sbyte[] { -2 });
                var1.GetVar(new Int32[] { 1 }, readBuffer);
                Assert.Equals(readBuffer[0], (sbyte)-2);

                // Test get and put subsets
                var1.PutVar(new Int32[] { 2 }, new Int32[] { 2 }, new sbyte[] { -2, -2 });
                var1.GetVar(new Int32[] { 2 }, new Int32[] { 2 }, readBuffer);
                Assert.Equals(readBuffer[0], (sbyte)-2);
                Assert.Equals(readBuffer[1], (sbyte)-2);
                // Test ranges
                var1.PutVar(new Int32[] { 0 }, new int[] { 127 });
                try {
                    var1.PutVar(new Int32[] { 0 }, new int[] { 128 });
                    throw new AssertFailedException("Failed to raise NcRange exception.");
                } catch (NcRange) {
                }
                var1.PutVar(new Int32[] { 0 }, new int[] { -128 });
                try {
                    var1.PutVar(new Int32[] { 0 }, new int[] { -129 });
                    throw new AssertFailedException("Failed to raise NcRange exception.");
                } catch (NcRange) {
                }
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
        public NcFullDetailPage(NcManagementPage ncManagementPage, NcFile ncFile, NcFileDetails ncFileDetails, NcFileFix ncFileFix)
        {
            this.ncManagementPage = ncManagementPage;
            this.ncFile           = ncFile;
            this.ncFileDetails    = ncFileDetails;
            this.ncFileFix        = ncFileFix;
            InitializeComponent();



            // hide non allowed buttons
            if (!ncManagementPage.mainWindow.loginUser.Value.user_type) // the current user is not an admin
            {
                ValidateFlipper.Visibility = Visibility.Collapsed;
                FinaliseFlipper.Visibility = Visibility.Collapsed;
            }

            if (!ncFile.is_valid || ncFile.state == 2)
            {
                FinaliseFlipper.Visibility = Visibility.Collapsed;
            }

            if (!ncManagementPage.mainWindow.loginUser.Value.user_type &&             // the current user is not an admin
                ncManagementPage.mainWindow.loginUser.Value.id != ncFile.fix_user_id) // the current user is not the fixer
            {
                ResetFlipper.Visibility = Visibility.Collapsed;
            }



            initializeData(ncFile, ncFileDetails, ncFileFix);// populate text fields

            // populate Image List
            for (int i = 0; i < ncManagementPage.ncCaseBitmapImageList.Count; i++)
            {
                Frame newFrame = new Frame
                {
                    Margin  = new Thickness(4),
                    Content = new ZoomPicPage(ncManagementPage, i)
                };

                PicContainer.Children.Add(newFrame);
            }

            if (ncFile.is_valid)
            {
                ValidateFlipperFrontBtn.Content = "Anuler validation";
            }
        }
Exemplo n.º 17
0
        public bool TestOpenCreate()
        {
            string filePath = "nc_clobber.nc";

            CheckDelete(filePath);
            NcFile file = null;

            try {
                file = new NcFile(filePath, NcFileMode.replace, NcFileFormat.nc4);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 18
0
        public bool TestAddDim()
        {
            NcFile file = null;

            try {
                file = TestHelper.NewFile(filePath);
                NcDim dim1 = file.AddDim("time", 20);
                Assert.Equals(dim1.GetName(), "time");
                Assert.Equals(dim1.GetSize(), 20);
                Assert.Equals(file.GetDimCount(), 1);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
        public void ShowNcDetailForm(NonConformityListPage nonConformityListPage)//, int index)
        {
            // Get focussed NcCase (NOT OPTIMAL)

            /*int currentId = 0;
             * int ix = 0;
             * while (ix < focussedNcListPage.NcCaseList.Count) // && focussedNcListPage.NcCaseList[ix].id != ((NcFile)focussedNcListPage.NcCaseDataGrid.Items[focussedNcListPage.NcCaseDataGrid.SelectedIndex]).id)
             * //for(int i=0;i< focussedNcListPage.NcCaseList.Count;i++)
             * {
             *  if(focussedNcListPage.NcCaseList[ix].id == ((NcFile)focussedNcListPage.NcCaseDataGrid.Items[focussedNcListPage.NcCaseDataGrid.SelectedIndex]).id)
             *  {
             *      currentId = ix;
             *      ix = focussedNcListPage.NcCaseList.Count; // to exit the loop
             *  }
             *  ix++;
             * }*/
            // ---------------------------------



            NcFile ncCase = (NcFile)focussedNcListPage.NcCaseDataGrid.Items[focussedNcListPage.NcCaseDataGrid.SelectedIndex];//focussedNcListPage.NcCaseList[currentId];// focussedNcListPage.NcCaseDataGrid.SelectedIndex];

            Nullable <NcFileDetails> ncFileDetail = mainWindow.sqlTools.GetNcFileDetailSQL(ncCase.id, mainWindow);

            if (ncFileDetail.HasValue)
            {
                // get Bitmap images from server
                ncCaseBitmapImageList.Clear();
                ncCaseBitmapImageList.AddRange(mainWindow.sqlTools.GetImageListSQL(ncCase.id, mainWindow));


                if (ncCase.estimated_start_date != "")
                {
                    Nullable <NcFileFix> ncFileFix = mainWindow.sqlTools.GetNcFileFixSQL(ncCase.id, mainWindow);
                    ncFullDetailPage        = new NcFullDetailPage(this, ncCase, ncFileDetail.Value, ncFileFix.Value);
                    NcFileFormFrame.Content = ncFullDetailPage;
                }
                else
                {
                    ncDetailPage            = new NcDetailPage(this, ncCase, ncFileDetail.Value);
                    NcFileFormFrame.Content = ncDetailPage;
                }
                NewFormDialog.IsOpen = true;
            }
        }
Exemplo n.º 20
0
        public NcDetailPage(NcManagementPage ncManagementPage, NcFile ncFile, NcFileDetails ncFileDetails)
        {
            this.ncManagementPage = ncManagementPage;
            this.ncFile           = ncFile;
            InitializeComponent();
            initializeData(ncFile, ncFileDetails);


            for (int i = 0; i < ncManagementPage.ncCaseBitmapImageList.Count; i++)
            {
                Frame newFrame = new Frame
                {
                    Margin  = new Thickness(4),
                    Content = new ZoomPicPage(ncManagementPage, i)
                };

                PicContainer.Children.Add(newFrame);
            }
        }
Exemplo n.º 21
0
        public bool TestDimGeneric()
        {
            NcFile file1 = null;
            NcFile file2 = null;

            try {
                file1 = TestHelper.NewFile(filePath);
                file2 = TestHelper.NewFile("other" + filePath);
                NcDim dim1 = file1.AddDim("time"); //Unlimited
                NcDim dim2 = file2.AddDim(dim1);
                Assert.True(dim2.IsUnlimited());
                Assert.Equals(dim1.GetName(), dim2.GetName());
            } finally {
                file1.Close();
                file2.Close();
            }
            CheckDelete(filePath);
            CheckDelete("other" + filePath);
            return(true);
        }
Exemplo n.º 22
0
        public bool TestVarPutGet()
        {
            NcFile file = null;
            NcDim  dim1 = null;
            NcVar  var1 = null;

            Int32[] vals = new Int32[20];
            for (int i = 0; i < 20; i++)
            {
                vals[i] = i;
            }
            try {
                FileSetup(ref file, ref dim1, ref var1);
                var1.PutVar(vals);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 23
0
        public bool TestScalar()
        {
            NcFile file = null;

            float[] buffer = new float[] { 1.0f };
            try {
                file = TestHelper.NewFile(filePath);
                NcVar var = file.AddVar("scalar", NcFloat.Instance);

                var.PutAtt("long_name", "A scalar variable");
                var.PutVar(new float[] { 1.0f });
                buffer[0] = 90.0f;
                Assert.Equals(buffer[0], 90.0f);
                var.GetVar(buffer);
                Assert.Equals(buffer[0], 1.0f);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 24
0
        public bool TestStringVar()
        {
            NcFile        file    = null;
            NcDim         dim1    = null;
            NcVar         var1    = null;
            ASCIIEncoding encoder = new ASCIIEncoding();

            string buffer = String.Format("{0,20}", "hi there"); // need exactly 20 chars

            byte[] readBuffer = new byte[20];
            try {
                FileSetup(ref file, ref dim1, ref var1, NcChar.Instance);
                var1.PutVar(encoder.GetBytes(buffer));
                var1.GetVar(readBuffer);
                Assert.Equals(encoder.GetString(readBuffer), buffer);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 25
0
        public bool TestGet()
        {
            NcFile file = null;

            try {
                file = TestHelper.NewFile(filePath);
                NcDim time = file.AddDim("time", 10);
                NcDim x    = file.AddDim("x", 20);
                NcDim y    = file.AddDim("y", 20);
                NcVar u    = file.AddVar("u", NcFloat.Instance, new List <NcDim>()
                {
                    time, x, y
                });
                NcVar v = file.AddVar("v", NcFloat.Instance, new List <NcDim>()
                {
                    time, x, y
                });

                float[] uBuf = new float[10 * 20 * 20];
                for (int i = 0; i < uBuf.Length; i++)
                {
                    uBuf[i] = (float)i;
                }
                float[] vBuf = new float[10 * 20 * 20];
                for (int i = 0; i < vBuf.Length; i++)
                {
                    vBuf[i] = (float)i;
                }

                u.PutVar(uBuf);
                v.PutVar(vBuf);

                NcArray uArray = u.GetVar();
                Assert.Equals(uArray.Array, uBuf);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 26
0
        public bool TestPut()
        {
            NcFile file = null;

            try {
                file = TestHelper.NewFile(filePath);
                NcDim time = file.AddDim("time", 2);
                NcDim x    = file.AddDim("x", 2);
                NcDim y    = file.AddDim("y", 2);
                NcDim z    = file.AddDim("z", 4);
                NcVar u    = file.AddVar("u", NcFloat.Instance, new List <NcDim>()
                {
                    time, x, y, z
                });
                NcVar v = file.AddVar("v", NcFloat.Instance, new List <NcDim>()
                {
                    time, x, y, z
                });

                NcArray uArray = new NcArray(NcFloat.Instance, u.Shape);
                uArray.Fill(1);
                uArray.FillSlice(20, new int[] { 0, 0, 0, 3 }, new int[] { 2, 2, 2, 4 });
                NcArray vArray = new NcArray(NcFloat.Instance, v.Shape);
                vArray.Fill(100);

                u.PutVar(uArray);

                v.PutVar(vArray);

                NcArray outArray = u.GetVar();
                Assert.True(uArray.Equals(outArray));

                outArray = v.GetVar();
                Assert.True(vArray.Equals(outArray));
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 27
0
        public bool TestOpaque()
        {
            NcFile       file       = null;
            NcVar        var        = null;
            NcDim        dim        = null;
            NcType       type       = null;
            NcOpaqueType opaqueType = null;

            byte[] opaqueBuffer = new byte[32];
            byte[] readBuffer   = new byte[32];
            for (int i = 0; i < 32; i++)
            {
                opaqueBuffer[i] = (byte)i;
            }

            try {
                file       = TestHelper.NewFile(filePath);
                type       = file.AddOpaqueType("opaque", 32);
                opaqueType = new NcOpaqueType(type);

                Assert.Equals(type.GetTypeClass(), NcTypeEnum.NC_OPAQUE);
                Assert.Equals(opaqueType.GetTypeSize(), 32);

                dim = file.AddDim("time", 1);
                var = file.AddVar("opaqueVar", opaqueType, dim);
                int iLen = 0;
                var.PutVar(new Int32[] { 0 }, opaqueBuffer);
                iLen = var.GetVar(new Int32[] { 0 }, readBuffer);
                Assert.Equals(iLen, 32);
                for (int i = 0; i < 32; i++)
                {
                    Assert.Equals(readBuffer[i], opaqueBuffer[i]);
                }
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
        private void initializeData(NcFile ncFile, NcFileDetails ncFileDetails, NcFileFix ncFileFix)
        {
            // NcFile case
            caseTitleLabel.Text   = ncFile.case_title;
            userFullNameTxt.Text  = ncFile.nc_user_full_Name;
            structureTxt.Text     = ncFile.structure_name;
            NcDescriptionTxt.Text = ncFileDetails.description;
            n_planTxt.Text        = ncFileDetails.n_plan;
            partial_setTxt.Text   = ncFileDetails.partial_set;
            sourceTxt.Text        = ncFile.source ? "Externe" : "Interne";
            creationDateTxt.Text  = ncFile.creation_date;

            //NcFile fix
            CauseTxt.Text             = ncFileFix.cause;
            ActionDescriptionTxt.Text = ncFileFix.action_description;
            ActionTypeTxt.Text        = ncFileFix.action_type == 2 ? "Réalisée" : ncFileFix.action_type == 1 ? "En cours" : "Non entamée";
            FixerNameTxt.Text         = ncFileFix.fixer_full_name;
            FixerFunctionTxt.Text     = ncFileFix.fixer_function;
            FixerStructureTxt.Text    = ncFileFix.fixer_structure_name;
            StartDate.Text            = ncFileFix.estimated_start_date;
            EndDate.Text = ncFileFix.estimated_end_date;
        }
Exemplo n.º 29
0
        public bool TestShape()
        {
            NcFile file = null;

            try {
                file = TestHelper.NewFile(filePath);
                NcDim dim  = file.AddDim("time", 4);
                NcDim node = file.AddDim("node", 5);
                NcDim egg  = file.AddDim("egg", 6);

                NcVar var = file.AddVar("var", NcFloat.Instance, new List <NcDim>()
                {
                    dim, node, egg
                });
                List <int> shape = var.GetShape();
                Assert.Equals(shape.ToArray(), new int[] { 4, 5, 6 });
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }
Exemplo n.º 30
0
        public bool TestDefine()
        {
            NcFile file = null;

            try {
                file = new NcFile(filePath, NcFileMode.replace, NcFileFormat.classic);
                NcDim timeDim = file.AddDim("time", 20);
                NcVar timeVar = file.AddVar("time", NcDouble.Instance, timeDim);
                timeVar.PutAtt("units", "minutes since 2000-01-01 00:00:00");
                timeVar.PutAtt("long_name", "Time");
                timeVar.CheckData();
                NcArray vals = NcArray.Arange(NcDouble.Instance, 20);
                timeVar.PutVar(vals);
                Assert.Equals(timeVar.GetAtt("long_name"), "Time");

                NcVar data = file.AddVar("data", NcDouble.Instance, timeDim);
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }