aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h
blob: c3499454d866ac70914d0aa6a9a87dbef5ec5027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef MODULES_IDS_IDS_H_
#define MODULES_IDS_IDS_H_
#include "PMR/common/MessageContainer.pb-c.h"
#include "PMR/Hardware/HardwareDispenser.pb-c.h"
#include "drivers/motors/motor.h"
#include "ids_ex.h"

extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS];
extern float DispenserPressure[MAX_SYSTEM_DISPENSERS];
uint32_t DispenserConfigMessage(HardwareDispenser * request);

extern HardwareDispenser DispensersCfg[ MAX_SYSTEM_DISPENSERS];

extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS];



#endif  //MODULES_IDS_IDS_H_
-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

/// <summary>
/// Contains <see cref="ObservableCollection{T}"/> extension methods.
/// </summary>
public static class ObservableCollectionExtensions
{
    private static object _syncLock = new object();

    /// <summary>
    /// Replaces the specified old element with the specified new element.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="collection">The observable collection.</param>
    /// <param name="oldElement">The old element.</param>
    /// <param name="newElement">The new element.</param>
    public static void Replace<T>(this ObservableCollection<T> collection, T oldElement, T newElement)
    {
        int index = collection.IndexOf(oldElement);
        collection.Remove(oldElement);
        collection.Insert(index, newElement);
    }

    /// <summary>
    /// Swaps the specified elements.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="collection">The observable collection.</param>
    /// <param name="element1">Element1.</param>
    /// <param name="element2">Element2.</param>
    public static void Swap<T>(this ObservableCollection<T> collection, T element1, T element2)
    {
        int index1 = collection.IndexOf(element1);
        int index2 = collection.IndexOf(element2);

        T tmp = collection[index1];
        collection[index1] = collection[index2];
        collection[index2] = tmp;
    }

    /// <summary>
    /// Removes the dragged element and inserts it after the dropped element position.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="collection">The collection.</param>
    /// <param name="dragged">The dragged element.</param>
    /// <param name="dropped">The dropped element.</param>
    public static void DragAndDrop<T>(this ObservableCollection<T> collection, T dragged, T dropped)
    {
        collection.Remove(dragged);
        collection.Insert(collection.IndexOf(dropped), dragged);
    }

    /// <summary>
    /// Enables cross thread operations on this collection.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="collection">The collection.</param>
    public static void EnableCrossThreadOperations<T>(this ObservableCollection<T> collection)
    {
        BindingOperations.EnableCollectionSynchronization(collection, _syncLock);
    }

    /// <summary>
    /// Creates a collection view from the observable collection.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="collection">The collection.</param>
    /// <returns></returns>
    public static ICollectionView ToCollectionView<T>(this ObservableCollection<T> collection)
    {
        return CollectionViewSource.GetDefaultView(collection);
    }
}