hlp:桂林国际齿轮泵代码
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#ifndef IPEDIT_H
|
||||
#define IPEDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
#include <QBoxLayout>
|
||||
#include <QPaintEvent>
|
||||
|
||||
class IPEdit : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IPEdit(QWidget *parent = 0);
|
||||
~IPEdit();
|
||||
|
||||
QString text();
|
||||
void setText(const QString& text);
|
||||
|
||||
protected:
|
||||
void init();
|
||||
void initForEdit(QLineEdit* edit);
|
||||
QLineEdit* nextEdit(QLineEdit* curEdit);
|
||||
bool isEdit(QObject* object);
|
||||
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
virtual bool eventFilter(QObject* object, QEvent* event);
|
||||
|
||||
protected slots:
|
||||
void editTextChanged(const QString& text);
|
||||
|
||||
private:
|
||||
QBoxLayout* m_layout;
|
||||
QLineEdit* m_edit1;
|
||||
QLineEdit* m_edit2;
|
||||
QLineEdit* m_edit3;
|
||||
QLineEdit* m_edit4;
|
||||
QLabel* m_dot1;
|
||||
QLabel* m_dot2;
|
||||
QLabel* m_dot3;
|
||||
};
|
||||
|
||||
#endif // IPEDIT_H
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* i25.c -- "interleaved 2 of 5"
|
||||
*
|
||||
* Copyright (c) 1999,2000 Alessandro Rubini (rubini@gnu.org)
|
||||
* Copyright (c) 1999 Prosa Srl. (prosa@prosa.it)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "barcode.h"
|
||||
|
||||
static char *codes[] = {
|
||||
"11331", "31113", "13113", "33111", "11313",
|
||||
"31311", "13311", "11133", "31131", "13131"
|
||||
};
|
||||
|
||||
static char *guard[] = {"a1a1", "c1a"}; /* begin end */
|
||||
|
||||
int Barcode_i25_verify(unsigned char *text)
|
||||
{
|
||||
if (!text[0])
|
||||
return -1;
|
||||
while (*text && isdigit(*text))
|
||||
text++;
|
||||
if (*text)
|
||||
return -1; /* a non-digit char */
|
||||
return 0; /* ok */
|
||||
}
|
||||
|
||||
int Barcode_i25_encode(struct Barcode_Item *bc)
|
||||
{
|
||||
unsigned char *text;
|
||||
unsigned char *partial; /* dynamic */
|
||||
unsigned char *textinfo; /* dynamic */
|
||||
unsigned char *textptr, *p1, *p2, *pd;
|
||||
int i, len, sum[2], textpos, usesum = 0;
|
||||
|
||||
if (bc->partial)
|
||||
free(bc->partial);
|
||||
if (bc->textinfo)
|
||||
free(bc->textinfo);
|
||||
bc->partial = bc->textinfo = NULL; /* safe */
|
||||
|
||||
if (!bc->encoding)
|
||||
bc->encoding = strdup("interleaved 2 of 5");
|
||||
|
||||
text = bc->ascii;
|
||||
if (!bc->ascii) {
|
||||
bc->error = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((bc->flags & BARCODE_NO_CHECKSUM)) usesum = 0; else usesum = 1;
|
||||
|
||||
/* create the real text string, padded to an even number of digits */
|
||||
text = malloc(strlen(bc->ascii) + 3); /* leading 0, checksum, term. */
|
||||
if (!text) {
|
||||
bc->error = errno;
|
||||
return -1;
|
||||
}
|
||||
/* add the leading 0 if needed */
|
||||
i = strlen(bc->ascii) + usesum;
|
||||
if (i % 2) {
|
||||
/* add a leading 0 */
|
||||
text[0] = '0';
|
||||
strcpy(text+1, bc->ascii);
|
||||
} else {
|
||||
strcpy(text, bc->ascii);
|
||||
}
|
||||
/* add the trailing checksum if needed, the leading 0 is ignored */
|
||||
if (usesum) {
|
||||
sum[0] = sum[1] = 0;
|
||||
for (i=0; text[i]; i++)
|
||||
sum[i%2] += text[i]-'0';
|
||||
/*
|
||||
* The "even" sum must be multiplied by three, and the *
|
||||
* rightmost digit is defined as "even". The digits' position
|
||||
* is already correct, whether or not we added a leading zero.
|
||||
* (e.g., they are in pos. 0..4 or 1..4 of the string)
|
||||
*/
|
||||
i = sum[0] * 3 + sum[1];
|
||||
strcat(text, "0");
|
||||
text[strlen(text)-1] += (10 - (i%10)) % 10;
|
||||
}
|
||||
|
||||
/* the partial code is 5 * (text + check) + 4(head) + 3(tail) + term. */
|
||||
partial = malloc( (strlen(text) + 3) * 5 +2); /* be large... */
|
||||
if (!partial) {
|
||||
bc->error = errno;
|
||||
free(text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* the text information is at most "nnn:fff:c " * (strlen+1) +term */
|
||||
textinfo = malloc(10*(strlen(text)+1) + 2);
|
||||
if (!textinfo) {
|
||||
bc->error = errno;
|
||||
free(partial);
|
||||
free(text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
strcpy(partial, "0"); /* the first space */
|
||||
strcat(partial, guard[0]); /* start */
|
||||
textpos = 4; /* width of initial guard */
|
||||
textptr = textinfo;
|
||||
|
||||
len = strlen(text);
|
||||
for (i=0; i<len; i+=2) {
|
||||
if (!isdigit(text[i]) || !isdigit(text[i+1])) {
|
||||
bc->error = EINVAL; /* impossible if text is verified */
|
||||
free(partial);
|
||||
free(textinfo);
|
||||
free(text);
|
||||
return -1;
|
||||
}
|
||||
/* interleave two digits */
|
||||
p1 = codes[text[i]-'0'];
|
||||
p2 = codes[text[i+1]-'0'];
|
||||
pd = partial + strlen(partial); /* destination */
|
||||
while (*p1) {
|
||||
*(pd++) = *(p1++);
|
||||
*(pd++) = *(p2++);
|
||||
}
|
||||
*pd = '\0';
|
||||
/* and print the ascii text (but don't print the checksum, if any */
|
||||
if (usesum && strlen(text+i)==2) {
|
||||
/* print only one digit, discard the checksum */
|
||||
sprintf(textptr, "%i:12:%c ", textpos, text[i]);
|
||||
} else {
|
||||
sprintf(textptr, "%i:12:%c %i:12:%c ", textpos, text[i],
|
||||
textpos+9, text[i+1]);
|
||||
}
|
||||
textpos += 18; /* width of two codes */
|
||||
textptr += strlen(textptr);
|
||||
}
|
||||
strcat(partial, guard[1]);
|
||||
|
||||
bc->partial = partial;
|
||||
bc->textinfo = textinfo;
|
||||
free(text);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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: mbproto.h,v 1.14 2006/12/07 22:10:34 wolti Exp $
|
||||
*/
|
||||
|
||||
#ifndef _MB_PROTO_H
|
||||
#define _MB_PROTO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
PR_BEGIN_EXTERN_C
|
||||
#endif
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
#define MB_ADDRESS_BROADCAST ( 0 ) /*! Modbus broadcast address. */
|
||||
#define MB_ADDRESS_MIN ( 1 ) /*! Smallest possible slave address. */
|
||||
#define MB_ADDRESS_MAX ( 247 ) /*! Biggest possible slave address. */
|
||||
#define MB_FUNC_NONE ( 0 )
|
||||
#define MB_FUNC_READ_COILS ( 1 )
|
||||
#define MB_FUNC_READ_DISCRETE_INPUTS ( 2 )
|
||||
#define MB_FUNC_WRITE_SINGLE_COIL ( 5 )
|
||||
#define MB_FUNC_WRITE_MULTIPLE_COILS ( 15 )
|
||||
#define MB_FUNC_READ_HOLDING_REGISTER ( 3 )
|
||||
#define MB_FUNC_READ_INPUT_REGISTER ( 4 )
|
||||
#define MB_FUNC_WRITE_REGISTER ( 6 )
|
||||
#define MB_FUNC_WRITE_MULTIPLE_REGISTERS ( 16 )
|
||||
#define MB_FUNC_READWRITE_MULTIPLE_REGISTERS ( 23 )
|
||||
#define MB_FUNC_DIAG_READ_EXCEPTION ( 7 )
|
||||
#define MB_FUNC_DIAG_DIAGNOSTIC ( 8 )
|
||||
#define MB_FUNC_DIAG_GET_COM_EVENT_CNT ( 11 )
|
||||
#define MB_FUNC_DIAG_GET_COM_EVENT_LOG ( 12 )
|
||||
#define MB_FUNC_OTHER_REPORT_SLAVEID ( 17 )
|
||||
#define MB_FUNC_ERROR ( 128 )
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
MB_EX_NONE = 0x00,
|
||||
MB_EX_ILLEGAL_FUNCTION = 0x01,
|
||||
MB_EX_ILLEGAL_DATA_ADDRESS = 0x02,
|
||||
MB_EX_ILLEGAL_DATA_VALUE = 0x03,
|
||||
MB_EX_SLAVE_DEVICE_FAILURE = 0x04,
|
||||
MB_EX_ACKNOWLEDGE = 0x05,
|
||||
MB_EX_SLAVE_BUSY = 0x06,
|
||||
MB_EX_MEMORY_PARITY_ERROR = 0x08,
|
||||
MB_EX_GATEWAY_PATH_FAILED = 0x0A,
|
||||
MB_EX_GATEWAY_TGT_FAILED = 0x0B
|
||||
} eMBException;
|
||||
|
||||
typedef eMBException( *pxMBFunctionHandler ) ( UCHAR * pucFrame, USHORT * pusLength );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UCHAR ucFunctionCode;
|
||||
pxMBFunctionHandler pxHandler;
|
||||
} xMBFunctionHandler;
|
||||
|
||||
#ifdef __cplusplus
|
||||
PR_END_EXTERN_C
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* MyFileDialog.h
|
||||
*
|
||||
* Created on: Jul 14, 2013
|
||||
* Author: yiyu
|
||||
* QQ:1036184468
|
||||
* Descriptoin:
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MYFILEDIALOG_H_
|
||||
#define MYFILEDIALOG_H_
|
||||
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
class MyFileDialog:public QFileDialog{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MyFileDialog(QWidget *parent = 0);
|
||||
~MyFileDialog();
|
||||
|
||||
void showFileDialog(QString title,QString filter,QString dir);
|
||||
};
|
||||
|
||||
#endif /* MYFILEDIALOG_H_ */
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user