Example #1
0
        public Bh1750(string i2CControllerName,
                      PinConnection pinConnection     = PinConnection.PIN_LOW,
                      MeasurementMode measurementMode = MeasurementMode.ContinuouslyHighResolutionMode2)
        {
            _pinConnection     = pinConnection;
            _i2CControllerName = i2CControllerName;
            try
            {
                var settings = new I2cConnectionSettings((byte)_pinConnection);
                settings.BusSpeed    = I2cBusSpeed.StandardMode;
                settings.SharingMode = I2cSharingMode.Shared;
                string aqs = I2cDevice.GetDeviceSelector(_i2CControllerName);
                _device = I2cDevice.FromId(_i2CControllerName, settings);
                if (_device == null)
                {
                    Logger.Log("Device not found", Logger.LogLevel.Warning);
                }

                SetMode(measurementMode);
            }
            catch (Exception e)
            {
                Logger.Log("Exception: " + e.Message + "\n" + e.StackTrace, Logger.LogLevel.Error);
                throw;
            }
        }
        void tmi_MouseEnter(object sender, EventArgs e)
        {
            DaggerUIGraph uigraph = (Tag as DaggerBasePin).ParentNode.ParentGraph.ParentUIGraph as DaggerUIGraph;
            PinConnection con     = con = (PinConnection)(sender as ToolStripMenuItem).Tag;

            uigraph._trackingConnectPin = new DraggingNoodle(con.InputPin, con.OutputPin);
            uigraph.Invalidate(false);
        }
        void tmi_Click(object sender, EventArgs e)
        {
            PinConnection con = (PinConnection)(sender as ToolStripMenuItem).Tag;

            con.OutputPin.ConnectToInput(con.InputPin);
        }
        private void SaveConnections()
        {
            // TODO : OPTIMIZATION
            List <PinConnection> pinConnections = new List <PinConnection>();

            foreach (WireNode node in equalityNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in greaterNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in inequalityNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in lesserNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in constantNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in sayReplyNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in branchNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in setAnimVarNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in getAnimVarNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in reunionNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in getVarNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in chooseReplyNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            connections = pinConnections;
        }