hlp:桂林国际齿轮泵代码
This commit is contained in:
@@ -0,0 +1,224 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QJSONARRAY_H
|
||||
#define QJSONARRAY_H
|
||||
|
||||
#include "qjsonvalue.h"
|
||||
#include <QtCore/qiterator.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDebug;
|
||||
class QStringList;
|
||||
template <typename T> class QList;
|
||||
typedef QList<QVariant> QVariantList;
|
||||
|
||||
class Q_JSONRPC_EXPORT QJsonArray
|
||||
{
|
||||
public:
|
||||
QJsonArray();
|
||||
~QJsonArray();
|
||||
|
||||
QJsonArray(const QJsonArray &other);
|
||||
QJsonArray &operator =(const QJsonArray &other);
|
||||
|
||||
static QJsonArray fromStringList(const QStringList &list);
|
||||
static QJsonArray fromVariantList(const QVariantList &list);
|
||||
QVariantList toVariantList() const;
|
||||
|
||||
int size() const;
|
||||
inline int count() const { return size(); }
|
||||
|
||||
bool isEmpty() const;
|
||||
QJsonValue at(int i) const;
|
||||
QJsonValue first() const;
|
||||
QJsonValue last() const;
|
||||
|
||||
void prepend(const QJsonValue &value);
|
||||
void append(const QJsonValue &value);
|
||||
void removeAt(int i);
|
||||
QJsonValue takeAt(int i);
|
||||
inline void removeFirst() { removeAt(0); }
|
||||
inline void removeLast() { removeAt(size() - 1); }
|
||||
|
||||
void insert(int i, const QJsonValue &value);
|
||||
void replace(int i, const QJsonValue &value);
|
||||
|
||||
bool contains(const QJsonValue &element) const;
|
||||
QJsonValueRef operator[](int i);
|
||||
QJsonValue operator[](int i) const;
|
||||
|
||||
bool operator==(const QJsonArray &other) const;
|
||||
bool operator!=(const QJsonArray &other) const;
|
||||
|
||||
class const_iterator;
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
QJsonArray *a;
|
||||
int i;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef int difference_type;
|
||||
typedef QJsonValue value_type;
|
||||
//typedef T *pointer;
|
||||
typedef QJsonValueRef reference;
|
||||
|
||||
inline iterator() : a(0), i(0) { }
|
||||
explicit inline iterator(QJsonArray *array, int index) : a(array), i(index) { }
|
||||
|
||||
inline QJsonValueRef operator*() const { return QJsonValueRef(a, i); }
|
||||
//inline T *operator->() const { return &concrete(i)->value; }
|
||||
inline QJsonValueRef operator[](int j) const { return QJsonValueRef(a, i + j); }
|
||||
|
||||
inline bool operator==(const iterator &o) const { return i == o.i; }
|
||||
inline bool operator!=(const iterator &o) const { return i != o.i; }
|
||||
inline bool operator<(const iterator& other) const { return i < other.i; }
|
||||
inline bool operator<=(const iterator& other) const { return i <= other.i; }
|
||||
inline bool operator>(const iterator& other) const { return i > other.i; }
|
||||
inline bool operator>=(const iterator& other) const { return i >= other.i; }
|
||||
inline bool operator==(const const_iterator &o) const { return i == o.i; }
|
||||
inline bool operator!=(const const_iterator &o) const { return i != o.i; }
|
||||
inline bool operator<(const const_iterator& other) const { return i < other.i; }
|
||||
inline bool operator<=(const const_iterator& other) const { return i <= other.i; }
|
||||
inline bool operator>(const const_iterator& other) const { return i > other.i; }
|
||||
inline bool operator>=(const const_iterator& other) const { return i >= other.i; }
|
||||
inline iterator &operator++() { ++i; return *this; }
|
||||
inline iterator operator++(int) { iterator n = *this; ++i; return n; }
|
||||
inline iterator &operator--() { i--; return *this; }
|
||||
inline iterator operator--(int) { iterator n = *this; i--; return n; }
|
||||
inline iterator &operator+=(int j) { i+=j; return *this; }
|
||||
inline iterator &operator-=(int j) { i-=j; return *this; }
|
||||
inline iterator operator+(int j) const { return iterator(a, i+j); }
|
||||
inline iterator operator-(int j) const { return iterator(a, i-j); }
|
||||
inline int operator-(iterator j) const { return i - j.i; }
|
||||
};
|
||||
friend class iterator;
|
||||
|
||||
class const_iterator {
|
||||
public:
|
||||
const QJsonArray *a;
|
||||
int i;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef qptrdiff difference_type;
|
||||
typedef QJsonValue value_type;
|
||||
//typedef const T *pointer;
|
||||
typedef QJsonValue reference;
|
||||
|
||||
inline const_iterator() : a(0), i(0) { }
|
||||
explicit inline const_iterator(const QJsonArray *array, int index) : a(array), i(index) { }
|
||||
inline const_iterator(const const_iterator &o) : a(o.a), i(o.i) {}
|
||||
inline const_iterator(const iterator &o) : a(o.a), i(o.i) {}
|
||||
|
||||
inline QJsonValue operator*() const { return a->at(i); }
|
||||
//inline T *operator->() const { return &concrete(i)->value; }
|
||||
inline QJsonValue operator[](int j) const { return a->at(i+j); }
|
||||
inline bool operator==(const const_iterator &o) const { return i == o.i; }
|
||||
inline bool operator!=(const const_iterator &o) const { return i != o.i; }
|
||||
inline bool operator<(const const_iterator& other) const { return i < other.i; }
|
||||
inline bool operator<=(const const_iterator& other) const { return i <= other.i; }
|
||||
inline bool operator>(const const_iterator& other) const { return i > other.i; }
|
||||
inline bool operator>=(const const_iterator& other) const { return i >= other.i; }
|
||||
inline const_iterator &operator++() { ++i; return *this; }
|
||||
inline const_iterator operator++(int) { const_iterator n = *this; ++i; return n; }
|
||||
inline const_iterator &operator--() { i--; return *this; }
|
||||
inline const_iterator operator--(int) { const_iterator n = *this; i--; return n; }
|
||||
inline const_iterator &operator+=(int j) { i+=j; return *this; }
|
||||
inline const_iterator &operator-=(int j) { i-=j; return *this; }
|
||||
inline const_iterator operator+(int j) const { return const_iterator(a, i+j); }
|
||||
inline const_iterator operator-(int j) const { return const_iterator(a, i-j); }
|
||||
inline int operator-(const_iterator j) const { return i - j.i; }
|
||||
};
|
||||
friend class const_iterator;
|
||||
|
||||
// stl style
|
||||
inline iterator begin() { detach(); return iterator(this, 0); }
|
||||
inline const_iterator begin() const { return const_iterator(this, 0); }
|
||||
inline const_iterator constBegin() const { return const_iterator(this, 0); }
|
||||
inline iterator end() { detach(); return iterator(this, size()); }
|
||||
inline const_iterator end() const { return const_iterator(this, size()); }
|
||||
inline const_iterator constEnd() const { return const_iterator(this, size()); }
|
||||
iterator insert(iterator before, const QJsonValue &value) { insert(before.i, value); return before; }
|
||||
iterator erase(iterator pos) { removeAt(pos.i); return pos; }
|
||||
|
||||
// more Qt
|
||||
typedef iterator Iterator;
|
||||
typedef const_iterator ConstIterator;
|
||||
|
||||
// stl compatibility
|
||||
inline void push_back(const QJsonValue &t) { append(t); }
|
||||
inline void push_front(const QJsonValue &t) { prepend(t); }
|
||||
inline void pop_front() { removeFirst(); }
|
||||
inline void pop_back() { removeLast(); }
|
||||
inline bool empty() const { return isEmpty(); }
|
||||
typedef int size_type;
|
||||
typedef QJsonValue value_type;
|
||||
typedef value_type *pointer;
|
||||
typedef const value_type *const_pointer;
|
||||
typedef QJsonValueRef reference;
|
||||
typedef QJsonValue const_reference;
|
||||
typedef int difference_type;
|
||||
|
||||
private:
|
||||
friend class QJsonPrivate::Data;
|
||||
friend class QJsonValue;
|
||||
friend class QJsonDocument;
|
||||
friend Q_JSONRPC_EXPORT QDebug operator<<(QDebug, const QJsonArray &);
|
||||
|
||||
QJsonArray(QJsonPrivate::Data *data, QJsonPrivate::Array *array);
|
||||
void compact();
|
||||
void detach(uint reserve = 0);
|
||||
|
||||
QJsonPrivate::Data *d;
|
||||
QJsonPrivate::Array *a;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
Q_JSONRPC_EXPORT QDebug operator<<(QDebug, const QJsonArray &);
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QJSONARRAY_H
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 434 B |
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
|
||||
* Copyright (c) 2006 Christian Walter <wolti@sil.at>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* File: $Id: mbcrc.c,v 1.7 2007/02/18 23:50:27 wolti Exp $
|
||||
*/
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "port.h"
|
||||
|
||||
static const UCHAR aucCRCHi[] = {
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40
|
||||
};
|
||||
|
||||
static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 0x7B, 0x7A, 0xBA,
|
||||
0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
|
||||
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0,
|
||||
0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97,
|
||||
0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E,
|
||||
0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89,
|
||||
0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
|
||||
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83,
|
||||
0x41, 0x81, 0x80, 0x40
|
||||
};
|
||||
|
||||
USHORT
|
||||
usMBCRC16( UCHAR * pucFrame, USHORT usLen )
|
||||
{
|
||||
UCHAR ucCRCHi = 0xFF;
|
||||
UCHAR ucCRCLo = 0xFF;
|
||||
int iIndex;
|
||||
|
||||
while( usLen-- )
|
||||
{
|
||||
iIndex = ucCRCLo ^ *( pucFrame++ );
|
||||
ucCRCLo = ( UCHAR )( ucCRCHi ^ aucCRCHi[iIndex] );
|
||||
ucCRCHi = aucCRCLo[iIndex];
|
||||
}
|
||||
return ( USHORT )( ucCRCHi << 8 | ucCRCLo );
|
||||
}
|
||||
Reference in New Issue
Block a user