Ejemplo n.º 1
0
    def put(self):
        args = variable_put_parser.parse_args()

        # 检查站点已存在变量数量,防止超过规定上限
        if args['group_id'] is not None:
            plc_id = YjGroupInfo.query.filter_by(
                id=args['group_id']).first().yjplcinfo.id
            station_variable_count = YjVariableInfo.query.join(
                YjGroupInfo).filter(YjGroupInfo.plc_id == plc_id).count()
            if station_variable_count >= current_app.config['VARIABLE_COUNT']:
                return variable_overfulfil()

        variable = YjVariableInfo(
            variable_name=args['variable_name'],
            group_id=args['group_id'],
            db_num=args['db_num'],
            address=args['address'],
            area=args['area'],
            data_type=args['data_type'],
            rw_type=args['rw_type'],
            upload=args['upload'],
            acquisition_cycle=args['acquisition_cycle'],
            server_record_cycle=args['server_record_cycle'],
            note=args['note'],
            ten_id=args['ten_id'],
            item_id=args['item_id'],
            write_value=args['write_value'])

        db.session.add(variable)
        db.session.commit()

        return rp_create()
Ejemplo n.º 2
0
    def put(self):

        model = Parameter(
            variable_id=self.variable_id,
            param_name=self.param_name,
            unit=self.unit
        )
        db.session.add(model)
        db.session.commit()
        return rp_create()
Ejemplo n.º 3
0
    def put(self):
        args = alarm_now_put_parser.parse_args()

        model = VarAlarm(
            alarm_id=args['alarm_id'],
            time=args['time'],
        )
        db.session.add(model)
        db.session.commit()

        return rp_create()
Ejemplo n.º 4
0
    def put(self):
        args = alarm_info_put_parser.parse_args()

        model = VarAlarmInfo(variable_id=args['variable_id'],
                             alarm_type=args['alarm_type'],
                             note=args['note'],
                             is_send_message=args['is_send_message'])
        db.session.add(model)
        db.session.commit()

        return rp_create()
Ejemplo n.º 5
0
    def put(self):
        args = status_put_parser.parse_args()

        model = TransferLog(
            station_id=args['station_id'],
            level=args['level'],
            time=args['time'],
            note=args['note'],
        )
        db.session.add(model)
        db.session.commit()
        return rp_create()
Ejemplo n.º 6
0
    def put(self):
        args = value_put_parser.parse_args()

        model = Value(
            variable_id=args['variable_id'],
            value=args['value'],
            time=args['time']
        )

        db.session.add(model)
        db.session.commit()

        return rp_create()
Ejemplo n.º 7
0
    def put(self):
        args = station_alarm_parser.parse_args()

        # 添加
        model = StationAlarm(id_num=args['id_num'],
                             code=args['code'],
                             note=args['note'],
                             time=args['time'])

        db.session.add(model)
        db.session.commit()

        return rp_create()
Ejemplo n.º 8
0
    def put(self):
        args = plc_alarm_parser.parse_args()

        # 添加
        model = PLCAlarm(id_num=args['id_num'],
                         plc_id=args['plc_id'],
                         level=args['level'],
                         note=args['note'],
                         time=args['time'])

        db.session.add(model)
        db.session.commit()

        return rp_create()
Ejemplo n.º 9
0
    def put(self):
        args = query_put_parser.parse_args()

        if args['variable_id']:
            var_models = YjVariableInfo.query.filter(
                YjVariableInfo.id.in_(args['variable_id'])).all()
        else:
            var_models = []

        model = QueryGroup(name=args['name'], vars=var_models)

        db.session.add(model)
        db.session.commit()
        return rp_create()
Ejemplo n.º 10
0
    def put(self):
        args = group_put_parser.parse_args()

        model = YjGroupInfo(group_name=args['group_name'],
                            plc_id=args['plc_id'],
                            note=args['note'],
                            upload_cycle=args['upload_cycle'],
                            ten_id=args['ten_id'],
                            item_id=args['item_id'],
                            upload=args['upload'])

        db.session.add(model)
        db.session.commit()

        return rp_create()
Ejemplo n.º 11
0
    def put(self):
        args = station_put_parser.parse_args()

        model = YjStationInfo(station_name=args['station_name'],
                              mac=args['mac'],
                              ip=args['ip'],
                              note=args['note'],
                              id_num=args['id_num'],
                              plc_count=args['plc_count'],
                              ten_id=args['ten_id'],
                              item_id=args['item_id'],
                              modification=args['modification'],
                              phone=args['phone'],
                              version=args['version'])
        db.session.add(model)
        db.session.commit()

        return rp_create()
Ejemplo n.º 12
0
    def put(self):
        args = plc_put_parser.parse_args()

        self.query = []
        plc = YjPLCInfo(
            plc_name=args['plc_name'],
            station_id=args['station_id'],
            note=args['note'],
            ip=args['ip'],
            mpi=args['mpi'],
            type=args['type'],
            plc_type=args['plc_type'],
            ten_id=args['ten_id'],
            item_id=args['item_id'],
            rack=args['rack'],
            slot=args['slot'],
            tcp_port=args['tcp_port']
        )

        db.session.add(plc)
        db.session.commit()
        self.new_id = plc.id
        return rp_create()