예제 #1
0
def point():
    tid = int(request.form['tid'])
    point_name = request.form['point_name']
    num = PI(c_int(0))
    err = lib.MyDataSearchPointsNumByID(handle, tid,
                                        c_char_p(point_name.encode('utf-8')),
                                        num)
    if err:
        current_app.logger.error("获取标签点数量失败,%d", err)
        abort(404)
    pointinfo = (Mydata.PointInfo * num.contents.value)()
    err = lib.MyDataSearchPointsByID(handle, tid,
                                     c_char_p(point_name.encode('utf-8')),
                                     pointinfo, num)
    return jsonify({'point_infos': [info.to_json() for info in pointinfo]})
예제 #2
0
def add_file():
    name = request.form['name']
    err = lib.MyDataAddFile(handle, c_char_p(name.encode()))
    if err:
        current_app.logger.error("添加文件失败,%d", err)
        lib.MyDataGetErrDesc.restype = c_char_p
        return jsonify({
            "ret": -1,
            'errmsg': lib.MyDataGetErrDesc(err).decode('gbk')
        })
    return jsonify({"ret": 0})
예제 #3
0
def addtype_result():
    type_name = request.form['type_name']
    typeenums = request.form['typeenums']
    names = request.form['names']
    typeenums = typeenums.split('H')
    num = len(typeenums)
    typeenums_array = (c_int * num)()
    for i in range(len(typeenums)):
        typeenums_array[i] = int(typeenums[i])

    err = lib.MyDataAddType(handle, typeenums_array, num,
                            c_char_p(type_name.encode()),
                            c_char_p(names.encode()))
    if err:
        current_app.logger.error("添加类型失败,%d", err)
        lib.MyDataGetErrDesc.restype = c_char_p
        return jsonify({
            "ret": -1,
            'errmsg': lib.MyDataGetErrDesc(err).decode('gbk')
        })
    return jsonify({"ret": 0})
예제 #4
0
def add_table():
    try:
        type_id = int(request.form['table_type_id'])
    except:
        type_id = -1
    name = request.form['name']
    err = lib.MyDataAddTable(handle, type_id, c_char_p(name.encode()))
    if err:
        current_app.logger.error("添加表失败,%d", err)
        lib.MyDataGetErrDesc.restype = c_char_p
        return jsonify({
            "ret": -1,
            'errmsg': lib.MyDataGetErrDesc(err).decode('gbk')
        })
    return jsonify({"ret": 0})
예제 #5
0
def rebuild_index():
    try:
        start_time = int(request.form['start_time'])
    except:
        start_time = 0
    name = request.form['name']
    err = lib.MyDataRebuildIndex(handle, c_char_p(name.encode()),
                                 c_longlong(start_time))
    if err:
        current_app.logger.error("重建索引失败,%d", err)
        lib.MyDataGetErrDesc.restype = c_char_p
        return jsonify({
            "ret": -1,
            'errmsg': lib.MyDataGetErrDesc(err).decode('gbk')
        })
    return jsonify({"ret": 0})
예제 #6
0
def create_file():
    try:
        size = int(request.form['size'])
    except:
        size = -1
    name = request.form['name']
    start_time = int(request.form['start_time'])
    end_time = int(request.form['end_time'])
    llstart = c_longlong(start_time)
    llend = c_longlong(end_time)
    llsize = c_longlong(size)
    err = lib.MyDataCreateFile(handle, c_char_p(name.encode()), llstart, llend,
                               llsize)
    if err:
        current_app.logger.error("创建文件失败,%d", err)
        lib.MyDataGetErrDesc.restype = c_char_p
        return jsonify({
            "ret": -1,
            'errmsg': lib.MyDataGetErrDesc(err).decode('gbk')
        })
    return jsonify({"ret": 0})