Beispiel #1
0
        public static Configuration.Message AddMessage(string messageName, string canId, Configuration.Node node, Configuration.Bus parentBus)
        {
            if (messageName == null)
            {
                throw new ArgumentNullException(nameof(messageName));
            }
            if (canId == null)
            {
                throw new ArgumentNullException(nameof(canId));
            }
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            if (parentBus == null)
            {
                throw new ArgumentNullException(nameof(parentBus));
            }

            Configuration.Message message = new Configuration.Message
            {
                name = messageName,
                id   = "0x" + CanUtilities.Trim0x(canId)
            };

            NodeRef nodeRef = new NodeRef
            {
                id = node.id
            };

            message.Producer.Add(nodeRef);
            parentBus.Message.Add(message);

            return(message);
        }
Beispiel #2
0
        public NetworkMessageForm(Configuration.Message message)
        {
            InitializeComponent();

            this.message            = message;
            MessageNameTextBox.Text = message.name;
            CanIdTextBox.Text       = message.id;
        }
Beispiel #3
0
        public void DeleteMessage(Configuration.Message messageToDelete)
        {
            List <Configuration.Message> messages = new List <Configuration.Message>();

            foreach (Bus bus in Configuration.Bus)
            {
                bus.Message.Remove(messageToDelete);
            }
        }
Beispiel #4
0
 public NetworkMessageForm(Configuration.Message nwmessage)
 {
     InitializeComponent();
     if (nwmessage == null)
     {
         throw new ArgumentNullException(nameof(nwmessage));
     }
     MessageNameTextBox.Text = message.name;
     CanIdTextBox.Text       = message.id;
 }
Beispiel #5
0
        public static void DeleteSignal(Signal signal, Configuration.Message parentMessage)
        {
            if (signal == null)
            {
                throw new ArgumentNullException(nameof(signal));
            }
            if (parentMessage == null)
            {
                throw new ArgumentNullException(nameof(parentMessage));
            }

            parentMessage.Signal.Remove(signal);
        }
Beispiel #6
0
        public static Signal AddSignal(Signal signal, Configuration.Message parentMessage)
        {
            if (signal == null)
            {
                throw new ArgumentNullException(nameof(signal));
            }
            if (parentMessage == null)
            {
                throw new ArgumentNullException(nameof(parentMessage));
            }

            parentMessage.Signal.Add(signal);
            return(signal);
        }
Beispiel #7
0
        public void DeleteMessage(Configuration.Message messageToDelete)
        {
            if (messageToDelete == null)
            {
                throw new ArgumentNullException(nameof(messageToDelete));
            }

            List <Configuration.Message> messages = new List <Configuration.Message>();

            foreach (Bus bus in Configuration.Bus)
            {
                bus.Message.Remove(messageToDelete);
            }
        }
        private void NewMessageMenuItem_Click(object sender,EventArgs e)
        {
            using NetworkMessageForm networkMessageForm = new NetworkMessageForm();
            networkMessageForm.ShowDialog();

            if (networkMessageForm.IsOk)
            {
                CanTreeTag            canTreeTag = (CanTreeTag)NetworkDefinitionView.SelectedNode.Tag;
                Configuration.Message message    = ConfigService.AddMessage(networkMessageForm.Message.name,networkMessageForm.Message.id,canTreeTag.Node,canTreeTag.Bus);
                TreeNode nodeTreeNode            = AddNode(NetworkDefinitionView.SelectedNode.Nodes,message.name,CanTreeTag.MESSAGE,canTreeTag.Node,canTreeTag.Bus,message,null);
                NetworkDefinitionView.SelectedNode = nodeTreeNode;
                UpdateUnknownCan(true);
            }
        }
 private void MessageCommand(IPlayer player, string command, string[] args)
 {
     if (args.Length < 1)
     {
         SendMessage(player, GetLang("MessageSyntax", player.Id));
         return;
     }
     Configuration.Message messageConfig = GetFeatureConfig <Configuration.Message>(FeatureType.MESSAGE);
     if (OnCooldown(player, CooldownType.MessageCooldown))
     {
         SendMessage(player, GetLang("Cooldown", player.Id, (data.Players[player.Id].MessageCooldown.Value.AddSeconds(messageConfig.Cooldown) - DateTime.UtcNow).Seconds));
         return;
     }
     string       _message = string.Join(" ", args.ToArray());
     EmbedBuilder builder  = new EmbedBuilder()
                             .WithTitle(GetLang("Embed_MessageTitle"))
                             .AddInlineField(GetLang("Embed_MessagePlayer"), $"[{ player.Name }](https://steamcommunity.com/profiles/{player.Id})")
                             .AddField(GetLang("Embed_MessageMessage"), _message)
                             .SetColor(messageConfig.Color);
     FancyMessage payload = new FancyMessage()
                            .WithContent(messageConfig.Alert)
                            .SetEmbed(builder);
     Request request = new Request(messageConfig.WebhookUrl, payload, response =>
     {
         if (response.IsOk)
         {
             SendMessage(player, GetLang("MessageSent", player.Id));
             if (data.Players.ContainsKey(player.Id))
             {
                 data.Players[player.Id].MessageCooldown = DateTime.UtcNow;
             }
             else
             {
                 data.Players.Add(player.Id, new PlayerData());
                 data.Players[player.Id].MessageCooldown = DateTime.UtcNow;
             }
             if (messageConfig.LogToConsole)
             {
                 Puts($"MESSAGE ({player.Name}/{player.Id}) : {_message}");
             }
         }
         else if (response.IsBad)
         {
             SendMessage(player, GetLang("MessageNotSent", player.Id));
         }
     }, this);
 }
 private void RegisterCommands()
 {
     if (GetFeatureConfig <Configuration.Report>(FeatureType.REPORT).Enabled)
     {
         AddCovalenceCommand("report", "ReportCommand", ReportPermission);
         AddCovalenceCommand(new string[] { "reportadmin", "ra" }, "ReportAdminCommand", AdminPermission);
     }
     if (GetFeatureConfig <Configuration.Ban>(FeatureType.BAN).Enabled)
     {
         AddCovalenceCommand("ban", "BanCommand", BanPermission);
     }
     Configuration.Message messageConfig = GetFeatureConfig <Configuration.Message>(FeatureType.MESSAGE);
     if (messageConfig.Enabled)
     {
         AddCovalenceCommand(messageConfig.SuggestAlias ? new string[] { "message", "suggest" } : new string[] { "message" }, "MessageCommand", MessagePermission);
     }
 }
Beispiel #11
0
        public Configuration.Message AddMessage(string messageName, string canId, Configuration.Node node, Configuration.Bus parentBus)
        {
            Configuration.Message message = new Configuration.Message
            {
                name = messageName,
                id   = "0x" + MyExtensions.Trim0x(canId)
            };

            NodeRef nodeRef = new NodeRef
            {
                id = node.id
            };

            message.Producer.Add(nodeRef);
            parentBus.Message.Add(message);

            return(message);
        }
Beispiel #12
0
        private TreeNode AddNode(TreeNodeCollection nodes, string nodeName, int nodeType, Configuration.Node node, Configuration.Bus bus, Configuration.Message message, Configuration.Signal signal)
        {
            TreeNode   newTreeNode = nodes.Add(nodeName);
            CanTreeTag newTreeTag  = new CanTreeTag
            {
                NodeType = nodeType,
                Bus      = bus,
                Node     = node,
                Message  = message,
                Signal   = signal
            };

            newTreeNode.Tag = newTreeTag;

            int imageIndex = 0;

            switch (nodeType)
            {
            case CanTreeTag.BUS: imageIndex = 0; break;

            case CanTreeTag.NODE: imageIndex = 1; break;

            case CanTreeTag.MESSAGE: imageIndex = 2; newTreeNode.ToolTipText = "(" + message.id + ")"; break;

            case CanTreeTag.SIGNAL: imageIndex = 3; newTreeNode.ToolTipText = "(" + message.id + "): Offset:" + signal.offset + " Length: " + signal.length; break;
            }

            newTreeNode.ImageIndex         = imageIndex;
            newTreeNode.SelectedImageIndex = imageIndex;

            return(newTreeNode);
        }
Beispiel #13
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            string aqs = SerialDevice.GetDeviceSelector();
            var    dis = await DeviceInformation.FindAllAsync(aqs);

            Configuration.Port cfg_prt = new Configuration.Port()
            {
                PortID          = 1,
                StopBit         = Configuration.Port.StopBitType.OneStop,
                Parity          = Configuration.Port.ParityType.NoParity,
                CharacterLength = Configuration.Port.CharacterLengthType.Bit8,
                BaudRate        = 115200,
                InputProtocol   = Configuration.Port.Protocol.UBX,
                OutputProtocol  = Configuration.Port.Protocol.UBX
            };

            gps = new UBXSerialGPS(dis[0], cfg_prt);
            gps.MessageReceived += Gps_MessageReceived;


            statusTextBox.Text = "GPS Started";

            await gps.Start();

            statusTextBox.Text = "GPS init completed";

            Configuration.Message cfg_msg = Configuration.Message.GetConfigurationForType <Navigation.GeodeticPosition>();

            bool res = await gps.WriteConfigAsync(cfg_msg);

            if (res)
            {
                statusTextBox.Text = "Success configuring message";
                await Task.Delay(5000);
            }
            else
            {
                statusTextBox.Text = "Failed configuring message";
                await Task.Delay(5000);
            }

            statusTextBox.Text = "Polling message Monitor Receiver Status";
            Navigation.Clock resp = await gps.PollMessageAsync <Navigation.Clock>();

            if (resp != null)
            {
                statusTextBox.Text = "Poll message success: " + resp.TimeMillisOfWeek;
            }
            else
            {
                statusTextBox.Text = "Poll message failed";
            }

            var status = await gps.PollMessageAsync <Navigation.Status>();

            if (resp != null)
            {
                statusTextBox.Text = "Poll status success- Time to first fix: " + status.TimeToFirstFix;
            }
            else
            {
                statusTextBox.Text = "Poll status failed";
            }
        }
Beispiel #14
0
 public void DeleteSignal(Signal signal, Configuration.Message parentMessage)
 {
     parentMessage.Signal.Remove(signal);
 }
Beispiel #15
0
 public Signal AddSignal(Signal signal, Configuration.Message parentMessage)
 {
     parentMessage.Signal.Add(signal);
     return(signal);
 }