Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Controller()
        {
            this.errorLogger = new LedErrorLogger(LED_ERROR_PIN);

#if !EMULATOR
            // check for SD presence
            this.CheckSD();
#endif

            // create sensors instances
            this.dataLogger = new SDDataLogger(SD_DATA_LOGGING);
            this.anemometer = new Anemometer(ANEMOMETER_PIN);
            this.sht1x      = new SHT1X(SHT1X_DATA_PIN, SHT1X_CLK_PIN, SHT1X.Voltage.Vdd_3_5V);
            this.ldr        = new Ldr(LDR_ANALOG_CHANNEL, LDR_ADC_RESOLUTION, LDR_LOAD_RESISTOR);

            // RTC
            this.rtc = Rtc.Instance;

            // configure and create Web Server
            MicroWebServerConfig uWebServerConfig =
                new MicroWebServerConfig {
                Backlog         = WS_BACKLOG,
                HttpPort        = WS_HTTP_PORT,
                MaxWorkerThread = WS_MAX_WORKER_THREAD,
                WebRoot         = SD_WEBROOT
            };

            this.uWebServer = new MicroWebServer(uWebServerConfig);
        }
Esempio n. 2
0
        addRiserSummaryCallout(Point3d pnt3dV0, double angle0, double lenLand, string topTxt, string botTxt = "RISERS")
        {
            Point3d pnt3dV1 = pnt3dV0.traverse(angle0 + pi, lenLand + 2);
            Point3d pnt3dV2 = pnt3dV1.traverse(angle0 + pi, 10);

            Point3dCollection pnts3dLdr = new Point3dCollection {
                pnt3dV0,
                pnt3dV1,
                pnt3dV2
            };

            ObjectId idLayer   = Layer.manageLayers("ARROW");
            double   scaleAnno = Misc.getCurrAnnoScale();
            double   angleView = double.Parse(Application.GetSystemVariable("VIEWTWIST").ToString());

            ObjectId idLDR = Ldr.addLdr(pnts3dLdr, idLayer, 0.09, 0.0, clr.byl, ObjectId.Null);

            ObjectId idWO = ObjectId.Null;

            Txt.addLdrText("cmdRDR", apps.lnkCO, idLDR, null, topTxt, botTxt, useBackgroundFill: true);

            Point3d pnt3dIns = idLDR.getEndPnt();

            pnt3dIns = pnt3dIns.traverse(angle0 + pi, Pub.radius * scaleAnno);

            ObjectId idSym = Draw.addSymbolAndWipeout(pnt3dIns, angleView, out idWO, Pub.radius, 1024, true);
            Color    color = new Color();

            color = Color.FromColorIndex(ColorMethod.ByLayer, 256);
            ObjectId idMTxt = Txt.addMText("XX", pnt3dIns, angleView, 0.0, 0.09, AttachmentPoint.MiddleCenter, "Annotative", "BUBBLE", color, Pub.JUSTIFYCENTER);

            idSym.putOnTop(idMTxt, idWO);
        }
Esempio n. 3
0
        modLDRlnkBubsEndPnts(DBObject dbObj, TypedValue[] tvsLDR)
        {
            Leader   ldr     = (Leader)dbObj;
            Point3d  pnt3dVX = ldr.LastVertex;
            Handle   hSM     = tvsLDR[3].Value.ToString().stringToHandle();
            ObjectId idSM    = hSM.getObjectId();

            ObjectId[] ids = pnt3dVX.getEntitysAtPoint("TEXT");
            if (ids == null)
            {
                Application.ShowAlertDialog("Attention Walmart Shoppers: Last Vertex of Leader is no longer connected to the Symbol.  Exiting...");
                return;
            }

            switch (ids.Length)
            {
            case 0:
                Application.ShowAlertDialog("Attention Walmart Shoppers: Last Vertex of Leader is no longer connected to the Symbol.  Exiting...");
                return;

            case 1:

                Ldr.setLdrXData(pnt3dVX, ldr.ObjectId, idSM);

                break;

            default:
                Application.ShowAlertDialog("Attention Walmart Shoppers: More than one Target Entity at picked location. Exiting...");
                break;
            }
        }
Esempio n. 4
0
        addRiserCallout(ObjectId idCgPnt, double angle0, int side)
        {
            List <ObjectId> idsCgPnts = new List <ObjectId> {
                idCgPnt
            };

            Point3d pnt3dV0 = idCgPnt.getCogoPntCoordinates();
            Point3d pnt3dV1 = pnt3dV0.traverse(angle0 + pi / 4 * side, 4);
            Point3d pnt3dV2 = pnt3dV1.traverse(angle0 + pi / 2 * side, 10);

            Point3dCollection pnts3dLdr = new Point3dCollection {
                pnt3dV0,
                pnt3dV1,
                pnt3dV2
            };
            ObjectId idLayer   = Layer.manageLayers("ARROW");
            double   scaleAnno = Misc.getCurrAnnoScale();

            ObjectId idLDR = Ldr.addLdr(pnts3dLdr, idLayer, 0.09, 0.0, clr.byl, ObjectId.Null);

            string resBot = "FS";
            string resTop = string.Format(pnt3dV0.Z.ToString("F2"));

            Txt.addLdrText("cmdFL", apps.lnkCO, idLDR, idsCgPnts, resTop, resBot, useBackgroundFill: true);
        }
Esempio n. 5
0
        protected override void UpdateGfxCore()
        {
            // Create lines that fit the chart
            var w = (float)Chart.XAxis.Span;

            GfxBid = new View3d.Object(Ldr.Line("BidPrice", Model.Settings.UI.BidColour, v4.Origin, new v4(-w, 0, 0, 1)), file: false);
            GfxAsk = new View3d.Object(Ldr.Line("AskPrice", Model.Settings.UI.AskColour, v4.Origin, new v4(-w, 0, 0, 1)), file: false);
            base.UpdateGfxCore();
        }
Esempio n. 6
0
        addLdr()
        {
            Point3d                  pnt3d  = Pub.pnt3dO;
            bool                     canLdr = false;
            Handle                   hTarget;
            ObjectId                 idSM        = ObjectId.Null;
            string                   layerTarget = "";
            FullSubentityPath        path        = new FullSubentityPath();
            List <FullSubentityPath> paths       = new List <FullSubentityPath>();

            Entity ent = Ldr.getFirstLdrPoint(out pnt3d, out canLdr, out hTarget, out layerTarget, out path);

            if (canLdr)
            {
                return;
            }
            ent.PushHighlight(path, Autodesk.AutoCAD.GraphicsInterface.HighlightStyle.Glow);
            Color    color = Misc.getColorByLayer();
            ObjectId idLDR = JigSplineLeader_BB.jigSplineLeader(pnt3d, 0.09, "BUBBLE", color);

            if (idLDR == ObjectId.Null)
            {
                return;
            }

            Point3d     pnt3dEnd = idLDR.getLastVertex();
            List <Type> types    = new List <Type> {
                typeof(Polyline),
                typeof(Circle)
            };

            ObjectId[] ids = Select.getEntityatPoint(pnt3dEnd, types, "BUBBLE");

            if (ids == null)
            {
                return;
            }

            foreach (ObjectId id in ids)
            {
                ResultBuffer rb = id.getXData(apps.lnkBubs);
                if (rb != null)
                {
                    idSM = id;
                    Ldr.setLdrXData(pnt3dEnd, idLDR, idSM);
                    if (!updateSMxData(idSM, idLDR))
                    {
                        Application.ShowAlertDialog("Leader linkage to Symbol failed.");
                    }
                    break;
                }
            }
            paths.Add(path);
            xRef.unHighlightNestedEntity(paths);
        }
Esempio n. 7
0
        moveLdrEndPoint(TypedValue[] tvsSM, Point3d pnt3dCEN, Point3d pnt3dIns, ObjectId idSM)
        {
            for (int i = 6; i < tvsSM.Length; i++)
            {
                ObjectId idLDR     = tvsSM.getObjectId(i);
                Point3d  pnt3dBase = idLDR.getLastVertex();
                Point3d  pnt3dEnd  = idLDR.moveLdrEndPoint(pnt3dCEN, pnt3dIns, pnt3dBase);

                Ldr.setLdrXData(pnt3dEnd, idLDR, idSM);
            }
        }
Esempio n. 8
0
        scaleLDRs(Point3d pnt3dCEN, double scaleFactor, ObjectId idSM)
        {
            TypedValue[] tvsSM = idSM.getTVsAsArray(apps.lnkBubs);
            for (int i = 6; i < tvsSM.Length; i++)
            {
                ObjectId     idLDR  = tvsSM.getObjectId(i);
                ResultBuffer rbLDR  = idLDR.getXData(apps.lnkBubsLdrEndPnt);
                TypedValue[] tvsLDR = rbLDR.AsArray();

                Point3d pnt3dOrg = new Point3d((double)tvsLDR[1].Value, (double)tvsLDR[2].Value, 0.0);
                Point3d pnt3dEnd = idLDR.adjLdrEndPnt(pnt3dCEN, Pub.pnt3dO, scaleFactor);

                Ldr.setLdrXData(pnt3dEnd, idLDR, idSM);
            }
        }
Esempio n. 9
0
 public static void Mesh(this LdrBuilder ldr, string name, Colour32 colour, View3d.EGeom geom, IList <View3d.Vertex> verts, IList <ushort>?faces = null, IList <ushort>?lines = null, IList <ushort>?tetra = null, bool generate_normals = false, v4?position = null)
 {
     ldr.Append("*Mesh ", name, " ", colour, " {\n");
     if ((geom & View3d.EGeom.Vert) != 0)
     {
         ldr.Append("*Verts {").Append(verts.Select(x => Ldr.Vec3(x.m_pos))).Append("}\n");
     }
     if ((geom & View3d.EGeom.Norm) != 0)
     {
         ldr.Append("*Normals {").Append(verts.Select(x => Ldr.Vec3(x.m_norm))).Append("}\n");
     }
     if ((geom & View3d.EGeom.Colr) != 0)
     {
         ldr.Append("*Colours {").Append(verts.Select(x => Ldr.Colour(x.m_col))).Append("}\n");
     }
     if ((geom & View3d.EGeom.Tex0) != 0)
     {
         ldr.Append("*TexCoords {").Append(verts.Select(x => Ldr.Vec2(x.m_uv))).Append("}\n");
     }
     if (faces != null)
     {
         Debug.Assert(faces.All(i => i >= 0 && i < verts.Count)); ldr.Append("*Faces {").Append(faces).Append("}\n");
     }
     if (lines != null)
     {
         Debug.Assert(lines.All(i => i >= 0 && i < verts.Count)); ldr.Append("*Lines {").Append(lines).Append("}\n");
     }
     if (tetra != null)
     {
         Debug.Assert(tetra.All(i => i >= 0 && i < verts.Count)); ldr.Append("*Tetra {").Append(tetra).Append("}\n");
     }
     if (generate_normals)
     {
         ldr.Append("*GenerateNormals\n");
     }
     if (position != null)
     {
         ldr.Append(Ldr.Position(position.Value));
     }
     ldr.Append("}\n");
 }
Esempio n. 10
0
        labelElevDiff(double dblElevPnt, double dblElevSurface, List <Point3d> pnts3dLdr, Point3d pnt3dInsTxt, double dblDir)
        {
            string   nameLayer   = "GRADES";
            ObjectId idLayer     = Layer.manageLayers(nameLayer);
            double   dblElevDiff = dblElevSurface - dblElevPnt;

            string strText  = "";
            string strText1 = "";
            string strText2 = "";
            string strText3 = "";

            strText1 = string.Format("{0:#0.00}-DESIGN", dblElevSurface);
            strText2 = string.Format("\\P{0:#0.00}-EXIST", dblElevPnt);
            if (dblElevDiff < 0)
            {
                strText3 = string.Format("\\P{0:##.00} C", dblElevDiff);
            }
            else if (dblElevDiff >= 0)
            {
                strText3 = string.Format("\\P{0:##.00} F", dblElevDiff);
            }

            strText = strText1 + strText2 + strText3;

            int    intDrawUnits  = Misc.getCurrAnnoScale();
            double dblCurrHeight = 0.09 * intDrawUnits;

            ObjectId idMTxt = Txt.addMText(strText, pnt3dInsTxt, dblDir, 0, attachPnt: AttachmentPoint.MiddleLeft, nameLayer: nameLayer);

            Point3dCollection pnts3dLdrCol = new Point3dCollection();

            foreach (Point3d pnt3d in pnts3dLdr)
            {
                pnts3dLdrCol.Add(pnt3d);
            }

            ObjectId idLdr = Ldr.addLdr(pnts3dLdrCol, idLayer, sizeArrow: 0.1, sizeGap: 0.1, color: clr.wht, idMTxt: idMTxt);

            //List<Point3d> pnts3d = idLdr.getCoordinates3dList();
        }
Esempio n. 11
0
        convertBubble()
        {
            ObjectId idWO  = ObjectId.Null; //wipeout
            ObjectId idSM  = ObjectId.Null; //symbol
            ObjectId idTX  = ObjectId.Null; //text
            ObjectId idLDR = ObjectId.Null; //leader

            Point3d pnt3d  = Pub.pnt3dO;
            Object  osMode = SnapMode.getOSnap();

            int scale = Misc.getCurrAnnoScale();

            TypedValue[] tvs = new TypedValue[2];
            tvs.SetValue(new TypedValue((int)DxfCode.Start, "INSERT"), 0);
            tvs.SetValue(new TypedValue((int)DxfCode.LayerName, "BUBBLE"), 1);

            SelectionSet ss = Select.buildSSet(tvs);

            ObjectId[] idsBR = ss.GetObjectIds();

            ObjectId idLayer   = Layer.manageLayers("BUBBLE");
            double   angleView = -(double)Application.GetSystemVariable("VIEWTWIST");

            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                DBDictionary     groups = (DBDictionary)db.GroupDictionaryId.GetObject(OpenMode.ForRead);
                BlockTableRecord ms     = Blocks.getBlockTableRecordMS();

                foreach (ObjectId idBR in idsBR)
                {
                    BlockReference br = (BlockReference)tr.GetObject(idBR, OpenMode.ForWrite);

                    if (br.Name == "CWP")
                    {
                        br.ObjectId.delete();
                        continue;
                    }

                    Scale3d  scaleFactor = br.ScaleFactors;
                    Matrix3d m3d         = scaleFactor.GetMatrix();
                    double   scaleBR     = m3d.GetScale();

                    double              rotation = br.Rotation;
                    Point3d             pnt3dPos = br.Position;
                    string              name     = br.Name;
                    string              value    = string.Empty;
                    Entity              ent      = null;
                    AttributeCollection atts     = br.AttributeCollection;
                    foreach (ObjectId id in atts)
                    {
                        ent = id.getEnt();
                        AttributeReference attDef = (AttributeReference)ent;
                        value = attDef.TextString;
                    }

                    Vector3d v3d = new Vector3d(scaleBR * 1.35, scaleBR * 1.35, 0);
                    v3d = v3d * 1.1;
                    Point3d pnt3dLL = pnt3dPos - v3d;
                    Point3d pnt3dUR = pnt3dPos + v3d;
                    Point3d pnt3dLR = new Point3d(pnt3dUR.X, pnt3dLL.Y, 0.0);
                    Point3d pnt3dUL = new Point3d(pnt3dLL.X, pnt3dUR.Y, 0.0);

                    Point3dCollection pnts3d = new Point3dCollection {
                        pnt3dLL,
                        pnt3dLR,
                        pnt3dUR,
                        pnt3dUL,
                        pnt3dLL
                    };

                    tvs = new TypedValue[2];
                    tvs.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 0);
                    tvs.SetValue(new TypedValue((int)DxfCode.LayerName, "BUBBLE"), 1);

                    Point3d pnt3dBeg = Pub.pnt3dO;
                    Point3d pnt3dEnd = Pub.pnt3dO;
                    Point3d pnt3dMid = Pub.pnt3dO;

                    double             bulge = 0.0, delta0 = 0.0;
                    double             dirChord, dirTarget, disChord, disTarget;
                    Polyline           poly;
                    ObjectIdCollection idsLdr = new ObjectIdCollection();
                    ss = Select.buildSSet(tvs, pnts3d);
                    if (ss != null && ss.Count > 0)
                    {
                        ObjectId[] ids = ss.GetObjectIds();
                        foreach (ObjectId id in ids)
                        {
                            poly = (Polyline)id.getEnt();
                            if (poly != null)
                            {
                                pnt3dBeg = poly.StartPoint;
                                pnt3dMid = poly.GetPoint3dAt(1);
                                pnt3dEnd = poly.EndPoint;

                                bulge     = poly.GetBulgeAt(1);
                                delta0    = Geom.getDelta(bulge);
                                disChord  = pnt3dMid.getDistance(pnt3dEnd);
                                disTarget = (0.5 * disChord) / System.Math.Cos(delta0 / 4);
                                dirChord  = pnt3dMid.getDirection(pnt3dEnd);
                                dirTarget = dirChord - delta0 / 4;
                                pnt3dMid  = pnt3dMid.traverse(dirTarget, disTarget);

                                //dirTarget = pnt3dEnd.getDirection(pnt3dPos);    //direction towards center of circle
                                //disTarget = pnt3dEnd.getDistance(pnt3dPos);     //distance from original end point to center
                                //disTarget = disTarget - Pub.radius * scale * 0.85;    //0.85 per addSymbolAndWipeout  - factors to adjust symbols for best fit.
                                //pnt3dEnd = pnt3dEnd.traverse(dirTarget, disTarget);

                                pnt3dEnd = pnt3dPos;

                                pnts3d = new Point3dCollection {
                                    pnt3dBeg,
                                    pnt3dMid,
                                    pnt3dEnd
                                };
                                ObjectId idLdr = Ldr.addLdr(pnts3d, idLayer, 0.09 * scale, 0, clr.byl, ObjectId.Null, spline: true);
                                idsLdr.Add(idLdr);
                                poly.ObjectId.delete();
                            }
                        }
                    }

                    idSM = Base_Tools45.Draw.addSymbolAndWipeout(pnt3dPos, angleView, out idWO, Pub.radius, 1024, true);
                    idSM.moveToTop();
                    idSM.moveBelow(new ObjectIdCollection {
                        idWO
                    });
                    if (idsLdr.Count > 0)
                    {
                        idWO.moveBelow(idsLdr);
                    }
                    Color color = new Color();
                    color = Color.FromColorIndex(ColorMethod.ByLayer, 256);
                    idTX  = Txt.addMText(value, pnt3dPos, angleView, 0.8, 0.09, AttachmentPoint.MiddleCenter, "Annotative", "BUBBLE", color, Pub.JUSTIFYCENTER);
                    br.ObjectId.delete();

                    Draw.addXData(idSM, scale, idTX, idsLdr, idWO, 1024, "0".stringToHandle(), "");
                    //DBObjectCollection dbObjs = new DBObjectCollection();
                    //ent = (Entity)br;
                    //ent.Explode(dbObjs);
                    //foreach(Autodesk.AutoCAD.DatabaseServices.DBObject dbObj in dbObjs){
                    //    Autodesk.AutoCAD.DatabaseServices.Entity e = (Autodesk.AutoCAD.DatabaseServices.Entity)dbObj;
                    //    ms.AppendEntity(e);
                    //    tr.AddNewlyCreatedDBObject(e, true);
                    //    if(e.GetType() == typeof(Circle)){
                    //        foreach (DBDictionaryEntry entry in groups)
                    //        {
                    //            ObjectId idGrp = entry.Value;
                    //            Group group = (Group)tr.GetObject(idGrp, (OpenMode.ForRead));
                    //            ObjectId[] ids = group.GetAllEntityIds();
                    //            List<ObjectId> lstIDs = new List<ObjectId>();
                    //            foreach (ObjectId id in ids)
                    //                lstIDs.Add(id);
                    //            if (lstIDs.Contains(idBR))
                    //            {
                    //                group.UpgradeOpen();
                    //                foreach (ObjectId idEnt in lstIDs)
                    //                {
                    //                    group.Remove(idEnt);
                    //                    idEnt.delete();
                    //                }
                    //                group.Erase();
                    //                break;
                    //            }
                    //        }
                    //    }
                    //    e.ObjectId.delete();
                    //}
                }
                tr.Commit();
            }

            SnapMode.setOSnap((int)osMode);
        }
Esempio n. 12
0
        addLeader(Point3d varPntIns, string varPntNum, string strLayer, string strProfile, int shtScale, double dblScaleProfileView, object varDesc = null)
        {
            Point3dCollection pnts3dLdr = new Point3dCollection();
            Point3d           pnt3d     = Pub.pnt3dO;

            pnts3dLdr.Add(varPntIns);
            pnt3d = new Point3d(varPntIns.X + 4, varPntIns.Y - 4, 0);
            pnts3dLdr.Add(pnt3d);

            string strDesc = varPntNum;

            int      intStrLen  = strDesc.Length;
            ObjectId idTxtStyle = ObjectId.Null;

            try
            {
                idTxtStyle = Txt.getTextStyleId("Annotative");
            }
            catch (Exception)
            {
                idTxtStyle = Txt.getTextStyleId("Standard");
            }

            ObjectId idDimStyle = ObjectId.Null;

            try
            {
                idDimStyle = Dim.getDimStyleTableRecord("Annotative");
            }
            catch (Exception)
            {
                idDimStyle = Dim.getDimStyleTableRecord("Standard");
            }

            short intColor = 256;

            if (strProfile == "EXIST")
            {
                intColor = 1;
            }
            else
            {
                intColor = 4;
            }
            Wall_Form.frmWall2 fWall2 = Wall_Forms.wForms.fWall2;
            MText    mTxt             = null;
            ObjectId idMtext          = ObjectId.Null;

            try
            {
                idMtext = Txt.addMText(strDesc, pnt3d, 0, 0);

                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    mTxt             = (MText)tr.GetObject(idMtext, OpenMode.ForWrite);
                    mTxt.Attachment  = AttachmentPoint.BottomLeft;
                    mTxt.Layer       = strLayer;
                    mTxt.Color       = Color.FromColorIndex(ColorMethod.ByBlock, (short)intColor);
                    mTxt.TextStyleId = idTxtStyle;

                    MText          objLabel   = fWall2.LABEL;
                    List <Point3d> varPntsInt = mTxt.intersectWith(objLabel, false, extend.none);

                    if (varPntsInt.Count > 0)
                    {
                        Point3d pnt3dX = new Point3d(pnt3d.X - 0.35 * dblScaleProfileView, pnt3d.Y, 0);
                        mTxt.Location = pnt3dX;
                    }
                    fWall2.LABEL = mTxt;

                    tr.Commit();
                }
            }
            catch (Exception)
            {
            }

            ObjectId idLayer  = Layer.manageLayers(strLayer);
            ObjectId idLeader = Ldr.addLdr(pnts3dLdr, idLayer, 0.09, 0, clr.byl, idMtext);
            Leader   ldr      = null;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                ldr                = (Leader)tr.GetObject(idLeader, OpenMode.ForWrite);
                ldr.Dimasz         = 0.09;
                ldr.HasArrowHead   = true;
                ldr.Dimgap         = 0.01;
                ldr.DimensionStyle = idDimStyle;

                tr.Commit();
            }

            TypedValue[] tvs = new TypedValue[] { new TypedValue(1001, "LEADER"), new TypedValue(1005, ldr.Handle) };
            idMtext.setXData(tvs, "LEADER");
            return(true);
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();


            // How to use the ADS1015 and MCP3002 ADC/Converters

            AdcProviderManager adcManager = new AdcProviderManager();

            adcManager.Providers.Add(new ADS1015(ADS1015.Gain.Volt33));                            // Load up ADS1015 4 Channel ADC Converter
            adcManager.Providers.Add(new MCP3002());                                               // Load up MCP3002 2 Channel ADC Converter

            IReadOnlyList <AdcController> adcControllers = await adcManager.GetControllersAsync(); // load ADCs


            //use the ADCs create above
            Ldr      light = new Ldr(adcControllers[0].OpenChannel(0));      // create new light sensor using the ADS1015 ADC provider
            MCP9700A temp  = new MCP9700A(adcControllers[1].OpenChannel(0)); // create temperature sensor using MCP3002 ADC Provider

            var lightLevel = light.ReadValue;                                // read light level from the first ADC ADS1015
            var lightRatio = light.ReadRatio;

            var celsius    = temp.Temperature.DegreesCelsius;    // read temp in celsius
            var fahrenheit = temp.Temperature.DegreesFahrenheit; // read temp in celsius


            BMP280 tempAndPressure = new BMP280();

            var degreesCelsius    = tempAndPressure.Temperature.DegreesCelsius; // read temp in celsius - plenty of other units
            var degreesFahrenheit = tempAndPressure.Temperature.DegreesFahrenheit;

            var bars         = tempAndPressure.Pressure.Bars;         // read air pressure in bars - plenty of other units
            var hectopascals = tempAndPressure.Pressure.Hectopascals; // read air pressure in Hectopascals
            var Atmospheres  = tempAndPressure.Pressure.Atmospheres;


            // LED demo

            Led led = new Led(4);   // open led on pin 4

            led.On();               // turn on
            await Task.Delay(1000); // wait for 1 second

            led.Off();              // turn off

            // relay Demo
            Relay relay = new Relay(6);

            relay.On();             // turn relay on
            await Task.Delay(1000); // wait for 1 second

            led.Off();              // turn relay off


            // motor demo
            Motor leftMotor  = new Motor(22, 24);
            Motor rightMotor = new Motor(12, 25);

            //now do a tight circle
            leftMotor.Forward();
            rightMotor.Backward();
            await Task.Delay(5000);  // wait for 5 second

            leftMotor.Stop();
            rightMotor.Stop();
        }
Esempio n. 14
0
        ProcessCmds(string nameCmd)
        {
            ObjectId idCgPnt1 = ObjectId.Null;
            ObjectId idCgPnt2 = ObjectId.Null;
            ObjectId idLDR    = ObjectId.Null;

            List <ObjectId> idsCgPnts = new List <ObjectId>();

            Point3d      pnt3d, pnt3d1, pnt3d2, pnt3dIns, pnt3dLdr1, pnt3dLdr2;
            string       prompt;
            const string prompt1 = "Pick the Arrow Starting Point: ";

            string resElev = string.Empty, resElev1, resElev2, resTop = string.Empty, resBot = string.Empty, resBot2 = string.Empty,
                   resSlab, resCurb, resPrefix, resSuffix, resDesc, resElevSuf = string.Empty;

            double       deltaZ = 0.0;
            double       pi     = System.Math.PI;
            bool         escape = true;
            PromptStatus ps     = PromptStatus.Cancel;

            switch (nameCmd)
            {
            case "cmdCF0":
                resElev1 = UserInput.getCogoPoint(prompt1, out idCgPnt1, Pub.pnt3dO, osMode: 8);
                resTop   = string.Format("{0} TC", resElev1);
                resBot   = "0\" CF";
                pnt3d    = idCgPnt1.getCogoPntCoordinates();
                //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d, 0.09, "ARROW", 7);
                idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                idsCgPnts.Add(idCgPnt1);
                Txt.addLdrText(nameCmd, apps.lnkCO, idLDR, idsCgPnts, resTop, resBot);
                break;

            case "cmdDEP":
            case "cmdGQ":
            case "cmdWQ":
                idCgPnt1 = CgPnt.selectCogoPointByNode("\nSelect Low Point : ", osMode: 8);
                if (idCgPnt1 == null)
                {
                    return;
                }
                pnt3d1 = idCgPnt1.getCogoPntCoordinates();

                idCgPnt2 = CgPnt.selectCogoPointByNode("\nSelect High Point : ", osMode: 8);
                if (idCgPnt2 == null)
                {
                    return;
                }
                pnt3d2 = idCgPnt2.getCogoPntCoordinates();
                if (pnt3d2 == Pub.pnt3dO)
                {
                    return;
                }
                deltaZ = System.Math.Abs(pnt3d1.Z - pnt3d2.Z);
                switch (nameCmd)
                {
                case "cmdDEP":
                    resTop = "DEEPEN";
                    resBot = string.Format("PANEL= {0:F2}'", deltaZ);
                    break;

                case "cmdGQ":
                    resTop = "CONSTRUCT GRAVITY WALL";
                    string resDelta = "0.50";
                    escape = UserInput.getUserInputDoubleAsString("\nEnter Additional Height in feet: ", out resDelta, resDelta);
                    if (escape)
                    {
                        return;
                    }
                    resBot = string.Format("H= {0:F2}'", deltaZ + double.Parse(resDelta));
                    break;

                case "cmdWQ":
                    resTop = "CONSTRUCT RETAINING WALL";
                    resBot = string.Format("H= {0:F2}'", deltaZ + 1.5);
                    break;
                }
                //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d2, 0.09, "ARROW", 7);
                idLDR = Ldr.drawLdr(pnt3d2, 0.09, "ARROW", 7);

                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                idsCgPnts = new List <ObjectId> {
                    idCgPnt1,
                    idCgPnt2
                };

                Txt.addLdrText(nameCmd, apps.lnkDP, idLDR, idsCgPnts, resTop, resBot);
                break;

            case "cmdFF":
            case "cmdFFD":
                resElev1 = UserInput.getCogoPoint(prompt1, out idCgPnt1, Pub.pnt3dO, osMode: 8);
                pnt3d    = idCgPnt1.getCogoPntCoordinates();
                resTop   = string.Format("{0} FF", resElev1);
                if (nameCmd == "cmdFFD")
                {
                    idLDR = ObjectId.Null;
                }
                else if (nameCmd == "cmdFF")
                {
                    //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d, 0.09, "ARROW", 7);
                    idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                    if (idLDR == ObjectId.Null)
                    {
                        return;
                    }
                }
                idsCgPnts.Add(idCgPnt1);
                //resSlab = Dict.getCmdDefault(nameCmd, "resSlab");
                resSlab = "0.50";                                                                                               //per M. Roberts 6/21/2015
                escape  = UserInput.getUserInputDoubleAsString("\nEnter Slab Thickness:", out resSlab, resSlab);
                if (escape)
                {
                    if (idLDR != ObjectId.Null)
                    {
                        idLDR.delete();
                    }
                    return;
                }
                deltaZ = double.Parse(resSlab);
                resBot = string.Format("{0} PAD", (double.Parse(resElev1) - deltaZ).ToString("F2"));
                Txt.addLdrText(nameCmd, apps.lnkCO, idLDR, idsCgPnts, resTop, resBot, "", deltaZ);
                break;

            case "cmdFL":
            case "cmdFLX":
                resElev1 = UserInput.getCogoPoint(prompt1, out idCgPnt1, Pub.pnt3dO, osMode: 8);
                if (resElev1 == string.Empty)
                {
                    return;
                }
                pnt3d = idCgPnt1.getCogoPntCoordinates();
                //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d, 0.09, "ARROW", 7);
                idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                idsCgPnts.Add(idCgPnt1);

                resBot = Dict.getCmdDefault(nameCmd, "resBot");
                if (resBot == string.Empty)
                {
                    resBot = "FL";
                }

                prompt = string.Format("\nEnter Bottom Text: FL/FS/Other <{0}> [FL/FS]:", resBot);
                escape = UserInput.getUserInputKeyword(resBot, out resBot, prompt, "FL FS");
                if (escape)
                {
                    idLDR.delete();
                    return;
                }

                if (nameCmd == "cmdFLX")
                {
                    resTop = string.Format("({0})", resElev1);
                }
                else
                {
                    resTop = resElev1;
                }

                Txt.addLdrText(nameCmd, apps.lnkCO, idLDR, idsCgPnts, resTop, resBot);
                Dict.setCmdDefault(nameCmd, "resBot", resBot);

                break;

            case "cmdG":
            case "cmdGX":
                resElev1 = UserInput.getCogoPoint(prompt1, out idCgPnt1, Pub.pnt3dO, osMode: 8);
                if (resElev1 == string.Empty)
                {
                    return;
                }
                pnt3d = idCgPnt1.getCogoPntCoordinates();
                //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d, 0.09, "ARROW", 7);
                idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                idsCgPnts.Add(idCgPnt1);

                resBot = Dict.getCmdDefault(nameCmd, "resBot");
                if (resBot == string.Empty)
                {
                    resBot = "FL";
                }

                prompt = string.Format("\nBottom Label is: FL/FS/Other <{0}>: [FL/FS]: ", resBot);
                escape = UserInput.getUserInputKeyword(resBot, out resBot, prompt, "FL FS");
                if (escape)
                {
                    idLDR.delete();
                    return;
                }

                resTop = Dict.getCmdDefault(nameCmd, "resTop");
                if (resTop == "")
                {
                    resTop = "TC";
                }
                prompt = string.Format("\nTop Label is: TC/Other <{0}>: [TC]: ", resTop);
                escape = UserInput.getUserInputKeyword(resTop, out resTop, prompt, "TC");
                if (escape)
                {
                    idLDR.delete();
                    return;
                }

                resCurb = Dict.getCmdDefault(nameCmd, "resCurb");
                if (resCurb == "")
                {
                    resCurb = "0.50";
                }
                escape = UserInput.getUserInputDoubleAsString(string.Format("\nEnter Offset for {0}", resTop), out resCurb, resCurb);
                if (escape)
                {
                    idLDR.delete();
                    return;
                }

                resElev2 = string.Format("{0:F2}", double.Parse(resElev1) + double.Parse(resCurb));
                string resBotMod = string.Format("{0}{1}", resElev1, resBot);
                string resTopMod = string.Format("{0}{1}", resElev2, resTop);
                if (nameCmd == "cmdGX")
                {
                    resBotMod = string.Format("({0})", resBotMod);
                    resTopMod = string.Format("({0})", resTopMod);
                }

                Txt.addLdrText(nameCmd, apps.lnkCO, idLDR, idsCgPnts, resTopMod, resBotMod, deltaZ: double.Parse(resCurb));
                Dict.setCmdDefault(nameCmd, "resTop", resTop);
                Dict.setCmdDefault(nameCmd, "resBot", resBot);
                Dict.setCmdDefault(nameCmd, "resCurb", resCurb);
                break;

            case "cmdGS":
            case "cmdGS0":
            case "cmdGS2":
            case "cmdGS3":
            case "cmdGSE":
            case "cmdGSS":
            case "cmdGSX":
            case "cmdSL":
            case "cmdSS":
                try
                {
                    if (nameCmd == "cmdGSE")
                    {
                        pnt3d1 = UserInput.getPoint("\nSelect First Endpoint: ", out ps, osMode: 1);
                        if (pnt3d1 == Pub.pnt3dO)
                        {
                            return;
                        }
                        pnt3d2 = UserInput.getPoint("\nSelect Second Endpoint: ", out ps, osMode: 1);
                        if (pnt3d2 == Pub.pnt3dO)
                        {
                            return;
                        }
                    }
                    else if (nameCmd == "cmdGSX")
                    {
                        resElev1 = UserInput.getPoint("\nSelect First Point: ", out idCgPnt1, out pnt3d, Pub.pnt3dO, osMode: 8);
                        if (resElev1 == string.Empty)
                        {
                            return;
                        }
                        if (idCgPnt1 == ObjectId.Null)
                        {
                            pnt3d1 = pnt3d;
                        }
                        else
                        {
                            pnt3d1 = idCgPnt1.getCogoPntCoordinates();
                        }

                        resElev2 = UserInput.getPoint("\nSelect Second Point: ", out idCgPnt2, out pnt3d, pnt3d1, osMode: 8);
                        if (resElev2 == string.Empty)
                        {
                            return;
                        }
                        if (idCgPnt2 == ObjectId.Null)
                        {
                            pnt3d2 = pnt3d;
                        }
                        else
                        {
                            pnt3d2 = idCgPnt2.getCogoPntCoordinates();
                        }
                    }
                    else
                    {                                                          //cmd GS, GS0, GS2, GS3, GSE, GSS, GSX, SS, SL
                        resElev1 = UserInput.getCogoPoint("\nSelect First Point: ", out idCgPnt1, Pub.pnt3dO, osMode: 8);
                        if (resElev1 == string.Empty)
                        {
                            return;
                        }
                        pnt3d1 = idCgPnt1.getCogoPntCoordinates();

                        resElev2 = UserInput.getCogoPoint("\nSelect Second Point: ", out idCgPnt2, pnt3d1, osMode: 8);
                        if (resElev2 == string.Empty)
                        {
                            return;
                        }
                        pnt3d2 = idCgPnt2.getCogoPntCoordinates();
                    }

                    double scale = Misc.getCurrAnnoScale();
                    double angle = pnt3d1.getDirection(pnt3d2);
                    double dxy   = pnt3d1.getDistance(pnt3d2);
                    double dz    = pnt3d2.Z - pnt3d1.Z;
                    double slope = dz / dxy;

                    Pub.Slope = slope;
                    Pub.dZ    = dz;

                    if (pnt3d2.Z > pnt3d1.Z)                                        //nominal case is sloping downhill - arrow points to lower grade
                    {
                        angle = angle + System.Math.PI;
                    }

                    string message = string.Format("\nHorz = {0:F4} : Vert = {1:F4} : R = {2:F2}%\r", dxy, dz, slope * 100);
                    BaseObjs._editor.WriteMessage(message);

                    ps       = PromptStatus.Cancel;
                    pnt3dIns = UserInput.getPoint("\nPick Insertion Point for Slope: ", out ps, osMode: 0);
                    if (ps == PromptStatus.Cancel)
                    {
                        return;
                    }
                    if (ps == PromptStatus.None)
                    {
                        pnt3dIns = pnt3d1.getMidPoint2d(pnt3d2);
                    }

                    double factor = 0.0;
                    slope = System.Math.Abs(slope);
                    switch (nameCmd)
                    {
                    case "cmdGS":
                        resElev = string.Format("R={0:F2}%", slope * 100);
                        factor  = 3.8;
                        break;

                    case "cmdGSE":
                        resElev = string.Format("R={0:F4}%", slope * 100);
                        factor  = 3.8;
                        break;

                    case "cmdGS0":
                        resElev = string.Format("{0:F0}%", Base_Tools45.Math.roundUP3(slope) * 100);
                        factor  = 1.5;
                        break;

                    case "cmdGS2":
                        resElev = string.Format("R={0:F2}%", slope * 100);
                        factor  = 3.0;
                        break;

                    case "cmdGS3":
                        resElev = string.Format("{0:F0}%", Base_Tools45.Math.roundUP3(slope) * 100);
                        factor  = 1.2;
                        break;

                    case "cmdGSS":
                        resElev = string.Format("{0:F1}%", slope * 100);
                        factor  = 2.0;
                        break;

                    case "cmdGSX":
                        resElev = string.Format("(R={0:F2}%)", slope * 100);
                        factor  = 3.8;
                        break;

                    case "cmdSL":
                        resElev = string.Format("S={0:F4}", slope);
                        factor  = 3.0;
                        break;
                    }
                    pnt3dLdr1 = pnt3dIns.traverse(angle, 0.09 * scale * factor);
                    pnt3dLdr2 = pnt3dIns.traverse(angle + pi, 0.09 * scale * factor);

                    Point3dCollection pnts3dLdr = new Point3dCollection {
                        pnt3dLdr1,
                        pnt3dLdr2
                    };
                    ObjectId idLayer = Layer.manageLayers("ARROW");
                    idLDR = Ldr.addLdr(pnts3dLdr, idLayer, 0.09, 0.0, clr.byl, ObjectId.Null);

                    idsCgPnts = new List <ObjectId> {
                        idCgPnt1,
                        idCgPnt2
                    };

                    List <Point3d> pnts3d = new List <Point3d> {
                        pnt3d1, pnt3d2
                    };

                    if (nameCmd == "cmdGS3")
                    {
                        Txt.addLdrText(nameCmd, apps.lnkGS, idLDR, idsCgPnts, resElev, "", "", 0.0, 0.7, pnts3dX: pnts3d);
                    }
                    else
                    {
                        Txt.addLdrText(nameCmd, apps.lnkGS, idLDR, idsCgPnts, resElev, "", "", 0.0, pnts3dX: pnts3d);                                          //pnts3d added to allow using something other than a CogoPoint
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " LdrText_ProcessCmds.cs: line: 313");
                }
                break;

            case "cmdLD":
                //resElev1 = UserInput.getCogoPoint(prompt1, out idCgPnt1, Pub.pnt3dOrg, osMode: 8);
                //pnt3d = idCgPnt1.getCogoPntCoordinates();
                //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d, 0.09, "ARROW", 7);
                pnt3d = UserInput.getPoint(prompt1, out ps, 521);

                idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                resTop = Dict.getCmdDefault(nameCmd, "resTop");
                bool cancel = true;
                cancel = UserInput.getUserInput(resTop, "\nEnter Top Text: ", out resTop, true);
                if (cancel || resTop == string.Empty)
                {
                    idLDR.delete();
                    return;
                }
                resBot = Dict.getCmdDefault(nameCmd, "resBot");
                cancel = true;
                cancel = UserInput.getUserInput(resBot, "\nEnter Bottom Text: ", out resBot, true);

                Txt.addLdrText(nameCmd, apps.lnkLD, idLDR, null, resTop, resBot);

                Dict.setCmdDefault(nameCmd, "resTop", resTop);                          //OK
                Dict.setCmdDefault(nameCmd, "resBot", resBot);                          //OK

                break;

            case "cmdLLA":
                bool              canLdr;
                Handle            hEntX     = "0000".stringToHandle();
                string            nameLayer = "";
                FullSubentityPath path      = new FullSubentityPath();
                Entity            ent       = Ldr.getFirstLdrPoint(out pnt3d, out canLdr, out hEntX, out nameLayer, out path);
                if (ent == null)
                {
                    return;
                }
                idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                resTop = nameLayer;
                resBot = "";
                Txt.addLdrText(nameCmd, apps.lnkLD, idLDR, null, resTop, resBot);

                break;

            case "cmdLLG":
                string zone = "405";
                prompt = string.Format("\nEnter the California SPCS Zone: <{0}>: [401/402/403/404/405/406]: ", zone);
                escape = UserInput.getUserInputKeyword(zone, out zone, prompt, "401 402 403 404 405 406");
                if (escape)
                {
                    return;
                }
                pnt3d = UserInput.getPoint("\nSelect a GRID point: ", out ps, osMode: 8);
                if (pnt3d == Pub.pnt3dO)
                {
                    return;
                }
                //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d, 0.09, "ARROW", 7);
                idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                LdrText_cmdLLG.cmdLLG(zone, pnt3d.Y, pnt3d.X, out resTop, out resBot);
                Txt.addLdrText(nameCmd, apps.lnkLD, idLDR, null, resTop, resBot);
                break;

            case "cmdRQ":
            case "cmdRiser":
                resElev1 = UserInput.getPoint("\nSelect Low Point : ", out idCgPnt1, out pnt3d, Pub.pnt3dO, osMode: 8);
                if (resElev1 == string.Empty)
                {
                    return;
                }
                if (idCgPnt1 == ObjectId.Null)
                {
                    pnt3d1 = pnt3d;
                }
                else
                {
                    pnt3d1 = idCgPnt1.getCogoPntCoordinates();
                }

                resElev2 = UserInput.getPoint("\nSelect High Point: ", out idCgPnt2, out pnt3d, pnt3d1, osMode: 8);
                if (resElev2 == string.Empty)
                {
                    return;
                }
                if (idCgPnt2 == ObjectId.Null)
                {
                    pnt3d2 = pnt3d;
                }
                else
                {
                    pnt3d2 = idCgPnt2.getCogoPntCoordinates();
                }

                idLDR = Ldr.drawLdr(pnt3d2, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }

                if (pnt3d1.Z > pnt3d2.Z)
                {
                    resElev  = resElev1;
                    resElev1 = resElev2;
                    resElev2 = resElev;
                    pnt3d    = pnt3d1;
                    pnt3d1   = pnt3d2;
                    pnt3d2   = pnt3d;
                }

                double nomRiser = 0.583;
                double aveRiser = 0;
                int    numRiser = 1;

                deltaZ = pnt3d2.Z - pnt3d1.Z;

                if (deltaZ < 0.333)                         //4"
                {
                    Application.ShowAlertDialog("\nElevation difference is less than 4 in. - revise landing elevation");
                }
                else if (deltaZ <= nomRiser)
                {                           //7"
                    aveRiser = deltaZ;
                }
                else if (deltaZ <= 0.667)                         //8"
                {
                    Application.ShowAlertDialog("\nElevation difference is greater than 7 in.  and less than 8 in. - therefore landing elevation needs to be adjusted");
                }
                else
                {                         // > 8"
                    if (deltaZ.mod(nomRiser) == 0)
                    {
                        numRiser = (int)System.Math.Truncate(deltaZ / nomRiser);
                    }
                    else
                    {
                        numRiser = (int)System.Math.Truncate(deltaZ / nomRiser);
                        numRiser++;
                    }
                    aveRiser = deltaZ / numRiser;

                    if (aveRiser < 0.333)
                    {
                        numRiser--;
                        aveRiser = deltaZ / numRiser;
                    }
                }

                string minRiser = (aveRiser * 12.0).decimalToFraction();
                if (nameCmd == "cmdRiser")
                {
                    resTop = string.Format("({0}) {1} ", numRiser, minRiser);
                    resBot = "RISERS";
                }
                else if (nameCmd == "cmdRQ")
                {
                    double lenRamp = deltaZ / 0.0833;
                    resTop = string.Format("CONSTRUCT {0:F2} FT HC RAMP", lenRamp);
                    resBot = string.Format("({0}) RISERS {1}", numRiser, minRiser);
                }
                Txt.addLdrText(nameCmd, apps.lnkLD, idLDR, null, resTop, resBot);

                break;

            case "cmdSDE":
            case "cmdSDS":
            case "cmdSED":
                Point3d  pnt3dPicked = Pub.pnt3dO;
                string   nameAlign   = string.Empty;
                ObjectId idAlign     = Align.selectAlign("Select Alignment:\n", "Alignment not found! Retry\n", out pnt3dPicked, out nameAlign);
                if (idAlign == ObjectId.Null)
                {
                    return;
                }
                bool go = true;
                do
                {
                    BaseObjs.write(string.Format("Active Alignment is: {0}\n", nameAlign));
                    pnt3d = UserInput.getPoint("Pick Arrow Start Point:\n", out ps, osMode: 8);
                    if (pnt3d == Pub.pnt3dO)
                    {
                        return;
                    }
                    pnt3d1 = pnt3d;                             //store elevation from start point

                    idCgPnt1 = Select.selectCogoPntAtPoint3d(pnt3d1);
                    idsCgPnts.Add(idCgPnt1);

                    //idLDR = LdrText_JigLeader0.jigLeader0(pnt3dTar, 0.09, "ARROW", 7);
                    idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                    if (idLDR == ObjectId.Null)
                    {
                        return;
                    }
                    escape    = false;
                    resPrefix = Dict.getCmdDefault(nameCmd, "resPrefix");
                    if (resPrefix == "")
                    {
                        resPrefix = "STA";
                    }
                    prompt = string.Format("\nEnter Station Prefix: STA/Other/. for None <{0}>: [STA/.]: ", resPrefix);
                    escape = UserInput.getUserInputKeyword(resPrefix, out resPrefix, prompt, "STA .");
                    if (escape)
                    {
                        idLDR.delete();
                        return;
                    }

                    escape    = false;
                    resSuffix = Dict.getCmdDefault(nameCmd, "resSuffix");
                    if (resSuffix == "")
                    {
                        resSuffix = ".";
                    }
                    prompt = string.Format("\nEnter Station Suffix: BC/EC/Other/. for None <{0}>: [BC/EC/.]: ", resSuffix);
                    escape = UserInput.getUserInputKeyword(resSuffix, out resSuffix, prompt, "BC EC .");
                    if (escape)
                    {
                        idLDR.delete();
                        return;
                    }

                    escape  = false;
                    resDesc = Dict.getCmdDefault(nameCmd, "resDesc");
                    if (resDesc == "")
                    {
                        resDesc = nameAlign;
                    }
                    prompt = string.Format("\nEnter Station Desc/. for None <{0}>: [.]: ", resDesc);
                    escape = UserInput.getUserInputKeyword(resDesc, out resDesc, prompt, ".");
                    if (escape)
                    {
                        idLDR.delete();
                        return;
                    }

                    if (nameCmd == "cmdSDE" || nameCmd == "cmdSED")
                    {
                        escape     = false;
                        resElevSuf = Dict.getCmdDefault(nameCmd, "resElevSuf");
                        if (resElevSuf == "")
                        {
                            resElevSuf = ".";
                        }
                        prompt = string.Format("\nEnter Elevation Suffix: INV/TC/FS/Other/. for None <{0}>: [.]: ", resElevSuf);
                        escape = UserInput.getUserInputKeyword(resElevSuf, out resElevSuf, prompt, ".");
                        if (escape)
                        {
                            idLDR.delete();
                            return;
                        }
                    }

                    double station = 0.0, offset = 0.0;
                    pnt3d = idLDR.getBegPnt();
                    Align.getAlignStaOffset(idAlign, pnt3d, ref station, ref offset);
                    if (resPrefix == ".")
                    {
                        resPrefix = "";
                    }
                    if (resSuffix == ".")
                    {
                        resSuffix = "";
                    }

                    resTop = string.Format("{0} {1} {2}", resPrefix, station.ToString("#####0+00.00"), resSuffix);
                    if (resDesc == ".")
                    {
                        resDesc = "";
                    }
                    resBot = resDesc;

                    if (nameCmd == "cmdSDE" || nameCmd == "cmdSED")
                    {
                        resBot2 = string.Format("{0:F2} {1}", pnt3d1.Z, resElevSuf);
                    }

                    Txt.addLdrText(nameCmd, apps.lnkCO, idLDR, idsCgPnts, resTop, resBot, resBot2);
                } while (go);

                Dict.setCmdDefault(nameCmd, "resPrefix", resPrefix);
                Dict.setCmdDefault(nameCmd, "resSuffix", resSuffix);
                Dict.setCmdDefault(nameCmd, "resDesc", resDesc);
                Dict.setCmdDefault(nameCmd, "resElevSuf", resElevSuf);
                break;

            //case "cmdSF1":
            //    break;

            //case "cmdSF2":
            //    break;

            //case "cmdSLG":
            //    break;

            //case "cmdSS1":
            //    break;

            //case "cmdSS2":
            //    break;
            case "cmdPFA":
                break;

            case "cmdPFBEG":
                break;

            case "cmdPFDIM":
                break;

            case "cmdPFDIML":
                break;

            case "cmdPFDIMS":
                break;

            case "cmdPFDM":
                break;

            case "cmdPFDP":
                break;

            case "cmdPFED":
                break;

            case "cmdPFEND":
                break;

            case "cmdPFES":
                break;

            case "cmdPFI":
                break;

            case "cmdPFIS":
                break;

            case "cmdPFS":
                break;

            case "cmdPFSDE":
                break;

            case "cmdPFSIE":
                break;

            case "cmdPFXI":
                break;

            case "cmdPLA":
                break;

            case "cmdPLBD":
                break;

            case "cmdPLBDS":
                break;

            case "cmdPLCD":
                break;

            case "cmdPLEND":
                break;

            case "cmdPLBEG":
                break;
            //case "cmdPLMH":
            //    osMode = SnapMode.getOSnap();
            //    SnapMode.setOSnap(0);
            //    Point3d pnt3dPicked = Pub.pnt3dOrg;
            //    Algn align = (Algn)Base_Tools45.Select.selectEntity(typeof(Algn), "Select Algn", "Algn Selection Failed", out pnt3dPicked);

            //    SnapMode.setOSnap((int)osMode);
            //    break;
            case "cmdPLX":
                break;

            case "cmdVB":
                break;

            case "cmdVG":
                break;

            case "cmdPFSDM":
                break;

            case "cmdPFSDP":
                break;

            case "cmdPFSI":
                break;

            case "cmdPLSCO":
                break;

            case "cmdPLSMH":
                break;

            case "cmdSBD":
                break;

            case "cmdSE":
                break;

            case "cmdSSZ":
                pnt3d = UserInput.getPoint("\nSelect Node to label: ", out ps, osMode: 8);
                if (ps != PromptStatus.OK)
                {
                    return;
                }
                //idLDR = LdrText_JigLeader0.jigLeader0(pnt3d, 0.09, "ARROW", 7);
                idLDR = Ldr.drawLdr(pnt3d, 0.09, "ARROW", 7);
                if (idLDR == ObjectId.Null)
                {
                    return;
                }
                if (resBot == string.Empty)
                {
                    resBot = "TOP";
                }

                prompt = string.Format("\nEnter Bottom Text: TOP/TOE/Other <{0}> [TOP/TOE]:", resBot);
                escape = UserInput.getUserInputKeyword(resBot, out resBot, prompt, "TOP TOE");
                if (escape)
                {
                    idLDR.delete();
                    return;
                }

                resTop    = string.Format("{0:F2}", pnt3d.Z);
                idsCgPnts = null;

                Txt.addLdrText(nameCmd, apps.lnkCO, idLDR, idsCgPnts, resTop, resBot);
                Dict.setCmdDefault(nameCmd, "resBot", resBot);

                break;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Controller()
        {
            this.errorLogger = new LedErrorLogger(LED_ERROR_PIN);

            #if !EMULATOR
            // check for SD presence
            this.CheckSD();
            #endif

            // create sensors instances
            this.dataLogger = new SDDataLogger(SD_DATA_LOGGING);
            this.anemometer = new Anemometer(ANEMOMETER_PIN);
            this.sht1x = new SHT1X(SHT1X_DATA_PIN, SHT1X_CLK_PIN, SHT1X.Voltage.Vdd_3_5V);
            this.ldr = new Ldr(LDR_ANALOG_CHANNEL, LDR_ADC_RESOLUTION, LDR_LOAD_RESISTOR);

            // RTC
            this.rtc = Rtc.Instance;

            // configure and create Web Server
            MicroWebServerConfig uWebServerConfig =
                new MicroWebServerConfig {
                    Backlog = WS_BACKLOG,
                    HttpPort = WS_HTTP_PORT,
                    MaxWorkerThread = WS_MAX_WORKER_THREAD,
                    WebRoot = SD_WEBROOT
                };

            this.uWebServer = new MicroWebServer(uWebServerConfig);
        }
Esempio n. 16
0
        private void cmdLeaderLayout_Click(object sender, RoutedEventArgs e)
        {
            ObjectId idLdr = Ldr.drawLdr(Point3d.Origin, 0.09, "ARROW", 7);

            PntsLeader = idLdr.getCoordinates3dList();
        }