hexsha stringlengths 40 40 | size int64 5 2.72M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 976 | max_stars_repo_name stringlengths 5 113 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:01:43 2022-03-31 23:59:48 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 00:06:24 2022-03-31 23:59:53 ⌀ | max_issues_repo_path stringlengths 3 976 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 976 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:19 2022-03-31 23:59:49 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 12:00:57 2022-03-31 23:59:49 ⌀ | content stringlengths 5 2.72M | avg_line_length float64 1.38 573k | max_line_length int64 2 1.01M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8329513bbaea12ee4e2d48e27f4f6f91a35024da | 4,383 | h | C | vital/logger/location_info.h | dstoup/kwiver | a3a36317b446baf0feb6274235ab1ac6b4329ead | [
"BSD-3-Clause"
] | 1 | 2017-07-31T07:07:32.000Z | 2017-07-31T07:07:32.000Z | vital/logger/location_info.h | dstoup/kwiver | a3a36317b446baf0feb6274235ab1ac6b4329ead | [
"BSD-3-Clause"
] | 4 | 2021-03-19T00:52:41.000Z | 2022-03-11T23:48:06.000Z | vital/logger/location_info.h | acidburn0zzz/kwiver | 6e4205f1c46df04759c57c040f01cc804b27e00d | [
"BSD-3-Clause"
] | null | null | null | /*ckwg +29
* Copyright 2015 by Kitware, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither name of Kitware, Inc. nor the names of any contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``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 AUTHORS OR CONTRIBUTORS 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.
*/
#ifndef KWIVER_LOGGER_LOCATION_INFO_H_
#define KWIVER_LOGGER_LOCATION_INFO_H_
#include <vital/logger/vital_logger_export.h>
#include <string>
namespace kwiver {
namespace vital {
namespace logger_ns {
// ----------------------------------------------------------------
/** Location of logging call.
*
* This class represents the location of the logging call.
*
*/
class VITAL_LOGGER_EXPORT location_info
{
public:
/** Constructor. Create a default of unknown location */
location_info();
/** Constructor. Create a location object for the current site */
location_info( char const* filename, char const* method, int line );
//@{
/** Default values for unknown locations */
static const char * const NA;
static const char * const NA_METHOD;
//@}
/**
* @brief Get file name.
*
* The file name for the current location is returned without
* leading path components and with file extension.
*
* @return file name, may be null.
*/
std::string get_file_name() const;
char const * get_file_name_ptr() const { return m_fileName; }
/**
* @brief Get path part of file spec.
*
* The path or base name portion of the file path is returned
* without the file name.
*
* @return file name base. May be null.
*/
std::string get_file_path() const;
/**
* @brief Get full function/method signature.
*
* The whole signature, as captured by the macro, is returned.
*
* @return function/method signature
*/
std::string get_signature() const;
/**
* @brief Get method name.
*
* The method name for the current location is returned.
*
* @return method name, may be null.
*/
std::string get_method_name() const;
char const * get_method_name_ptr() const { return m_methodName; }
/**
* @brief Get class name.
*
* This method returns the method name for the current location.
*
* @return class name.
*/
std::string get_class_name() const;
/**
* @brief Get line number.
*
* The line number for the current location is returned.
*
* @return line number, -1 indicates unknown line.
*/
int get_line_number() const;
private:
const char * const m_fileName;
const char * const m_methodName;
int m_lineNumber;
}; // end class location_info
} } } // end namespace
#if defined(_MSC_VER)
#if _MSC_VER >= 1300
#define __KWIVER_LOGGER_FUNC__ __FUNCSIG__
#endif
#else
#if defined(__GNUC__)
#define __KWIVER_LOGGER_FUNC__ __PRETTY_FUNCTION__
#endif
#endif
#if !defined(__KWIVER_LOGGER_FUNC__)
#define __KWIVER_LOGGER_FUNC__ ""
#endif
#define KWIVER_LOGGER_SITE ::kwiver::vital::logger_ns::location_info(__FILE__, \
__KWIVER_LOGGER_FUNC__, \
__LINE__)
#endif /* KWIVER_LOGGER_LOCATION_INFO_H_ */
| 29.22 | 81 | 0.696555 |
832998d5a8999b11aa2dcf36ae55444d42ac6847 | 2,362 | h | C | src/analyzer/smartpieseries.h | loganek/workertracker | b4e66f02e6a7cdf91e5f0a418cabbd23ac636f2e | [
"Beerware"
] | null | null | null | src/analyzer/smartpieseries.h | loganek/workertracker | b4e66f02e6a7cdf91e5f0a418cabbd23ac636f2e | [
"Beerware"
] | 1 | 2017-01-10T10:13:37.000Z | 2017-01-10T10:13:37.000Z | src/analyzer/smartpieseries.h | loganek/workertracker | b4e66f02e6a7cdf91e5f0a418cabbd23ac636f2e | [
"Beerware"
] | null | null | null | #ifndef SMARTPIESERIES_H
#define SMARTPIESERIES_H
#include <QPieSeries>
#include <memory>
QT_CHARTS_USE_NAMESPACE
class PieSeriesPolicy
{
public:
virtual bool check_pie_slice(QPieSlice *slice) = 0;
virtual std::shared_ptr<PieSeriesPolicy> make_new(QVariant variant = QVariant()) = 0;
virtual bool need_update(const std::shared_ptr<PieSeriesPolicy> &other) = 0;
virtual ~PieSeriesPolicy() {}
};
class AllPieSeriesPolicy : public PieSeriesPolicy
{
public:
bool check_pie_slice(QPieSlice *) { return true; }
std::shared_ptr<PieSeriesPolicy> make_new(QVariant) override { return std::make_shared<AllPieSeriesPolicy>(); }
virtual bool need_update(const std::shared_ptr<PieSeriesPolicy> &other) override { return !std::dynamic_pointer_cast<AllPieSeriesPolicy>(other); }
};
class MaxCountPieSeriesPolicy : public PieSeriesPolicy
{
const int max_count;
int current_count = 0;
public:
MaxCountPieSeriesPolicy(int max_count) : max_count(max_count) {}
bool check_pie_slice(QPieSlice *) override;
std::shared_ptr<PieSeriesPolicy> make_new(QVariant) override { return std::make_shared<MaxCountPieSeriesPolicy>(max_count); }
bool need_update(const std::shared_ptr<PieSeriesPolicy> &other) override;
};
class MinPercentagePieSeriesPolicy : public PieSeriesPolicy
{
const double min_percentage;
const int total_count;
public:
MinPercentagePieSeriesPolicy(double min_percentage, int total_count)
: min_percentage(min_percentage), total_count(total_count) {}
bool check_pie_slice(QPieSlice *slice) override;
std::shared_ptr<PieSeriesPolicy> make_new(QVariant variant) override { return std::make_shared<MinPercentagePieSeriesPolicy>(min_percentage, variant.toLongLong()); }
bool need_update(const std::shared_ptr<PieSeriesPolicy> &other) override;
};
class QSmartPieSeries : public QPieSeries
{
std::shared_ptr<PieSeriesPolicy> policy;
QPieSlice* others_slice = nullptr;
public:
virtual ~QSmartPieSeries() {}
explicit QSmartPieSeries(std::shared_ptr<PieSeriesPolicy> policy, QObject *parent = Q_NULLPTR);
void smart_add(QPieSlice *slice);
void finalize();
std::shared_ptr<PieSeriesPolicy> get_policy() const { return policy; }
void set_policy(const std::shared_ptr<PieSeriesPolicy>& policy) { this->policy = policy; }
};
#endif // SMARTPIESERIES_H
| 33.267606 | 169 | 0.762066 |
832b10ded82f599c27569801bf00ee8f95beff14 | 2,729 | c | C | linsched-linsched-alpha/fs/efs/namei.c | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 47 | 2015-03-10T23:21:52.000Z | 2022-02-17T01:04:14.000Z | linsched-linsched-alpha/fs/efs/namei.c | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 1 | 2020-05-28T13:06:06.000Z | 2020-05-28T13:13:15.000Z | linsched-linsched-alpha/fs/efs/namei.c | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 19 | 2015-02-25T19:50:05.000Z | 2021-10-05T14:35:54.000Z | /*
* namei.c
*
* Copyright (c) 1999 Al Smith
*
* Portions derived from work (c) 1995,1996 Christian Vogelgsang.
*/
#include <linux/buffer_head.h>
#include <linux/string.h>
#include <linux/exportfs.h>
#include "efs.h"
static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len) {
struct buffer_head *bh;
int slot, namelen;
char *nameptr;
struct efs_dir *dirblock;
struct efs_dentry *dirslot;
efs_ino_t inodenum;
efs_block_t block;
if (inode->i_size & (EFS_DIRBSIZE-1))
printk(KERN_WARNING "EFS: WARNING: find_entry(): directory size not a multiple of EFS_DIRBSIZE\n");
for(block = 0; block < inode->i_blocks; block++) {
bh = sb_bread(inode->i_sb, efs_bmap(inode, block));
if (!bh) {
printk(KERN_ERR "EFS: find_entry(): failed to read dir block %d\n", block);
return 0;
}
dirblock = (struct efs_dir *) bh->b_data;
if (be16_to_cpu(dirblock->magic) != EFS_DIRBLK_MAGIC) {
printk(KERN_ERR "EFS: find_entry(): invalid directory block\n");
brelse(bh);
return(0);
}
for(slot = 0; slot < dirblock->slots; slot++) {
dirslot = (struct efs_dentry *) (((char *) bh->b_data) + EFS_SLOTAT(dirblock, slot));
namelen = dirslot->namelen;
nameptr = dirslot->name;
if ((namelen == len) && (!memcmp(name, nameptr, len))) {
inodenum = be32_to_cpu(dirslot->inode);
brelse(bh);
return(inodenum);
}
}
brelse(bh);
}
return(0);
}
struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) {
efs_ino_t inodenum;
struct inode *inode = NULL;
inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
if (inodenum)
inode = efs_iget(dir->i_sb, inodenum);
return d_splice_alias(inode, dentry);
}
static struct inode *efs_nfs_get_inode(struct super_block *sb, u64 ino,
u32 generation)
{
struct inode *inode;
if (ino == 0)
return ERR_PTR(-ESTALE);
inode = efs_iget(sb, ino);
if (IS_ERR(inode))
return ERR_CAST(inode);
if (generation && inode->i_generation != generation) {
iput(inode);
return ERR_PTR(-ESTALE);
}
return inode;
}
struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid,
int fh_len, int fh_type)
{
return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
efs_nfs_get_inode);
}
struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid,
int fh_len, int fh_type)
{
return generic_fh_to_parent(sb, fid, fh_len, fh_type,
efs_nfs_get_inode);
}
struct dentry *efs_get_parent(struct dentry *child)
{
struct dentry *parent = ERR_PTR(-ENOENT);
efs_ino_t ino;
ino = efs_find_entry(child->d_inode, "..", 2);
if (ino)
parent = d_obtain_alias(efs_iget(child->d_inode->i_sb, ino));
return parent;
}
| 23.525862 | 101 | 0.6845 |
832bbd95574c7e958d30a8a8b968a35f7af1071c | 4,225 | c | C | compute/pzlauum.c | zhuangsc/Plasma-ompss1 | bcc99c164a256bc7df7c936b9c43afd38c12aea2 | [
"BSD-3-Clause"
] | null | null | null | compute/pzlauum.c | zhuangsc/Plasma-ompss1 | bcc99c164a256bc7df7c936b9c43afd38c12aea2 | [
"BSD-3-Clause"
] | null | null | null | compute/pzlauum.c | zhuangsc/Plasma-ompss1 | bcc99c164a256bc7df7c936b9c43afd38c12aea2 | [
"BSD-3-Clause"
] | null | null | null | /**
*
* @file pzlauum.c
*
* PLASMA auxiliary routines
* PLASMA is a software package provided by Univ. of Tennessee,
* Univ. of California Berkeley and Univ. of Colorado Denver
*
* @version 2.6.0
* @author Julien Langou
* @author Henricus Bouwmeester
* @author Mathieu Faverge
* @date 2010-11-15
* @precisions normal z -> s d c
*
**/
#include "common.h"
#define A(m,n) BLKADDR(A, PLASMA_Complex64_t, m, n)
/***************************************************************************//**
* Parallel UU' or L'L operation - dynamic scheduling
**/
void plasma_pzlauum_quark(PLASMA_enum uplo, PLASMA_desc A,
PLASMA_sequence *sequence, PLASMA_request *request)
{
plasma_context_t *plasma;
Quark_Task_Flags task_flags = Quark_Task_Flags_Initializer;
int k, m, n;
int ldam;
int tempkm, tempmm, tempnn;
PLASMA_Complex64_t zone = (PLASMA_Complex64_t)1.0;
plasma = plasma_context_self();
if (sequence->status != PLASMA_SUCCESS)
return;
QUARK_Task_Flag_Set(&task_flags, TASK_SEQUENCE, (intptr_t)sequence->quark_sequence);
/*
* PlasmaLower
*/
if (uplo == PlasmaLower) {
for (m = 0; m < A.mt; m++) {
tempmm = m == A.mt-1 ? A.m-m*A.mb : A.mb;
ldam = BLKLDD(A, m);
for(n = 0; n < m; n++) {
tempnn = n == A.nt-1 ? A.n-n*A.nb : A.nb;
QUARK_CORE_zherk(
plasma->quark, &task_flags,
uplo, PlasmaConjTrans,
tempnn, tempmm, A.mb,
1.0, A(m, n), ldam,
1.0, A(n, n), A.mb);
for(k = n+1; k < m; k++) {
tempkm = k == A.mt-1 ? A.m-k*A.mb : A.mb;
QUARK_CORE_zgemm(
plasma->quark, &task_flags,
PlasmaConjTrans, PlasmaNoTrans,
tempkm, tempnn, tempmm, A.mb,
zone, A(m, k), ldam,
A(m, n), ldam,
zone, A(k, n), A.mb);
}
}
for (n = 0; n < m; n++) {
tempnn = n == A.nt-1 ? A.n-n*A.nb : A.nb;
QUARK_CORE_ztrmm(
plasma->quark, &task_flags,
PlasmaLeft, uplo, PlasmaConjTrans, PlasmaNonUnit,
tempmm, tempnn, A.mb,
zone, A(m, m), ldam,
A(m, n), ldam);
}
QUARK_CORE_zlauum(
plasma->quark, &task_flags,
uplo,
tempmm,
A.mb, A(m, m), ldam);
}
}
/*
* PlasmaUpper
*/
else {
for (m = 0; m < A.mt; m++) {
tempmm = m == A.mt-1 ? A.m-m*A.mb : A.mb;
ldam = BLKLDD(A, m);
for (n = 0; n < m; n++) {
tempnn = n == A.nt-1 ? A.n-n*A.nb : A.nb;
QUARK_CORE_zherk(
plasma->quark, &task_flags,
uplo, PlasmaNoTrans,
tempnn, tempmm, A.mb,
1.0, A(n, m), A.mb,
1.0, A(n, n), A.mb);
for (k = n+1; k < m; k++){
tempkm = k == A.mt-1 ? A.m-k*A.mb : A.mb;
QUARK_CORE_zgemm(
plasma->quark, &task_flags,
PlasmaNoTrans, PlasmaConjTrans,
tempnn, tempkm, tempmm, A.mb,
zone, A(n, m), A.mb,
A(k, m), A.mb,
zone, A(n, k), A.mb);
}
}
for (n = 0; n < m; n++) {
tempnn = n == A.nt-1 ? A.n-n*A.nb : A.nb;
QUARK_CORE_ztrmm(
plasma->quark, &task_flags,
PlasmaRight, uplo, PlasmaConjTrans, PlasmaNonUnit,
tempnn, tempmm, A.mb,
zone, A(m, m), ldam,
A(n, m), A.mb);
}
QUARK_CORE_zlauum(
plasma->quark, &task_flags,
uplo,
tempmm,
A.mb, A(m, m), ldam);
}
}
}
| 33.531746 | 88 | 0.412544 |
83315727841602be19108e1d062145f5bfda6fb6 | 1,601 | h | C | MachSuite/bfs/bulk/bfs.h | Sacusa/ALADDIN | 45ff9ab7edf84dfa964bc870f0c3634d1a4c55fb | [
"BSD-3-Clause"
] | 82 | 2015-04-12T17:29:48.000Z | 2020-06-19T00:33:51.000Z | MachSuite/bfs/bulk/bfs.h | Sacusa/ALADDIN | 45ff9ab7edf84dfa964bc870f0c3634d1a4c55fb | [
"BSD-3-Clause"
] | 31 | 2015-05-13T09:43:00.000Z | 2020-06-20T16:26:06.000Z | MachSuite/bfs/bulk/bfs.h | Sacusa/ALADDIN | 45ff9ab7edf84dfa964bc870f0c3634d1a4c55fb | [
"BSD-3-Clause"
] | 47 | 2015-02-10T02:37:11.000Z | 2020-06-04T01:24:01.000Z | /*
Implementations based on:
Harish and Narayanan. "Accelerating large graph algorithms on the GPU using CUDA." HiPC, 2007.
Hong, Oguntebi, Olukotun. "Efficient Parallel Graph Exploration on Multi-Core CPU and GPU." PACT, 2011.
*/
#include <stdlib.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "support.h"
// Terminology (but not values) from graph500 spec
// graph density = 2^-(2*SCALE - EDGE_FACTOR)
#define SCALE 8
#define EDGE_FACTOR 16
#define N_NODES (1LL<<SCALE)
#define N_EDGES (N_NODES*EDGE_FACTOR)
// upper limit
#define N_LEVELS 10
// Larger than necessary for small graphs, but appropriate for large ones
typedef uint64_t edge_index_t;
typedef uint64_t node_index_t;
typedef struct edge_t_struct {
// These fields are common in practice, but we elect not to use them.
//weight_t weight;
//node_index_t src;
node_index_t dst;
} edge_t;
typedef struct node_t_struct {
edge_index_t edge_begin;
edge_index_t edge_end;
} node_t;
typedef int8_t level_t;
#define MAX_LEVEL INT8_MAX
////////////////////////////////////////////////////////////////////////////////
// Test harness interface code.
struct bench_args_t {
node_t nodes[N_NODES];
edge_t edges[N_EDGES];
node_index_t starting_node;
level_t level[N_NODES];
edge_index_t level_counts[N_LEVELS];
};
void bfs(node_t* host_nodes,
edge_t* host_edges,
level_t* host_level,
edge_index_t* host_level_counts,
node_t* nodes,
edge_t* edges,
level_t* level,
edge_index_t* level_counts,
node_index_t starting_node);
| 25.412698 | 103 | 0.692067 |
833313d597f8c06ed80c10a020b7f6a1db84d3e7 | 3,383 | h | C | head/sys/mips/atheros/ar933xreg.h | dplbsd/soc2013 | c134f5e2a5725af122c94005c5b1af3720706ce3 | [
"BSD-2-Clause"
] | null | null | null | head/sys/mips/atheros/ar933xreg.h | dplbsd/soc2013 | c134f5e2a5725af122c94005c5b1af3720706ce3 | [
"BSD-2-Clause"
] | null | null | null | head/sys/mips/atheros/ar933xreg.h | dplbsd/soc2013 | c134f5e2a5725af122c94005c5b1af3720706ce3 | [
"BSD-2-Clause"
] | null | null | null | /*-
* Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
*
* $FreeBSD: soc2013/dpl/head/sys/mips/atheros/ar933xreg.h 250324 2013-04-05 01:35:59Z adrian $
*/
#ifndef __AR93XX_REG_H__
#define __AR93XX_REG_H__
#define REV_ID_MAJOR_AR9330 0x0110
#define REV_ID_MAJOR_AR9331 0x1110
#define AR933X_REV_ID_REVISION_MASK 0x3
#define AR933X_GPIO_COUNT 30
#define AR933X_UART_BASE (AR71XX_APB_BASE + 0x00020000)
#define AR933X_UART_SIZE 0x14
#define AR933X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
#define AR933X_WMAC_SIZE 0x20000
#define AR933X_EHCI_BASE 0x1b000000
#define AR933X_EHCI_SIZE 0x1000
#define AR933X_DDR_REG_FLUSH_GE0 (AR71XX_APB_BASE + 0x7c)
#define AR933X_DDR_REG_FLUSH_GE1 (AR71XX_APB_BASE + 0x80)
#define AR933X_DDR_REG_FLUSH_USB (AR71XX_APB_BASE + 0x84)
#define AR933X_DDR_REG_FLUSH_WMAC (AR71XX_APB_BASE + 0x88)
#define AR933X_PLL_CPU_CONFIG_REG (AR71XX_PLL_CPU_BASE + 0x00)
#define AR933X_PLL_CLOCK_CTRL_REG (AR71XX_PLL_CPU_BASE + 0x08)
#define AR933X_PLL_CPU_CONFIG_NINT_SHIFT 10
#define AR933X_PLL_CPU_CONFIG_NINT_MASK 0x3f
#define AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT 16
#define AR933X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
#define AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT 23
#define AR933X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
#define AR933X_PLL_CLOCK_CTRL_BYPASS (1 << 2)
#define AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT 5
#define AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK 0x3
#define AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT 10
#define AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK 0x3
#define AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT 15
#define AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK 0x7
#define AR933X_RESET_REG_RESET_MODULE (AR71XX_RST_BLOCK_BASE + 0x1c)
#define AR933X_RESET_REG_BOOTSTRAP (AR71XX_RST_BLOCK_BASE + 0xac)
#define AR933X_RESET_WMAC (1 << 11)
#define AR933X_RESET_USB_HOST (1 << 5)
#define AR933X_RESET_USB_PHY (1 << 4)
#define AR933X_RESET_USBSUS_OVERRIDE (1 << 3)
#define AR933X_BOOTSTRAP_REF_CLK_40 (1 << 0)
#define AR933X_PLL_VAL_1000 0x00110000
#define AR933X_PLL_VAL_100 0x00001099
#define AR933X_PLL_VAL_10 0x00991099
#endif /* __AR93XX_REG_H__ */
| 40.759036 | 95 | 0.810228 |
8333b4fae0b9c17c3ed17288dc05926b3ee4f6a2 | 415 | h | C | Chapter_08_Processes/00_Start/programs/user_threads/uthread.h | filipklepo/osur-labs-fer | 98e27503927114b9fb012bd8cdef14112395db03 | [
"MIT"
] | 3 | 2021-11-18T06:44:04.000Z | 2022-01-29T08:56:05.000Z | Chapter_08_Processes/00_Start/programs/user_threads/uthread.h | filipklepo/osur-labs-fer | 98e27503927114b9fb012bd8cdef14112395db03 | [
"MIT"
] | null | null | null | Chapter_08_Processes/00_Start/programs/user_threads/uthread.h | filipklepo/osur-labs-fer | 98e27503927114b9fb012bd8cdef14112395db03 | [
"MIT"
] | 3 | 2019-03-31T21:32:38.000Z | 2021-07-02T14:09:19.000Z | /*! Simple user managed threads */
#pragma once
#ifndef USER_THREAD_C
typedef void uthread_t;
#else
#include <lib/list.h>
#include <arch/context.h>
typedef struct _uthread_t_
{
int id;
context_t context;
void *stack;
list_h list;
}
uthread_t;
#endif /* USER_THREAD_C */
void uthreads_init ();
uthread_t *create_uthread ( void (func) (void *), void *param );
void uthread_exit ();
void uthread_yield ();
| 14.310345 | 64 | 0.713253 |
8333e6ba6a51345ed71df37cf628233959aa5a93 | 565 | h | C | iop/hdd/pfs/src/pfs-opt.h | mlaux/ps2sdk | e8e9edb7309478d71be12bc44f2e087f3d1735a2 | [
"AFL-2.0"
] | 4 | 2016-02-08T12:45:36.000Z | 2021-04-08T18:02:32.000Z | iop/hdd/pfs/src/pfs-opt.h | belek666/ps2sdk | f23f376e5a99c4826ce94a2b4b5f1ba5affe4207 | [
"AFL-2.0"
] | 1 | 2016-03-02T11:24:13.000Z | 2016-03-03T13:28:02.000Z | iop/hdd/pfs/src/pfs-opt.h | belek666/ps2sdk | f23f376e5a99c4826ce94a2b4b5f1ba5affe4207 | [
"AFL-2.0"
] | 4 | 2016-02-28T14:33:07.000Z | 2019-11-29T05:34:03.000Z | #ifndef _PFS_OPT_H
#define _PFS_OPT_H
#define PFS_PRINTF(format,...) printf(format, ##__VA_ARGS__)
#define PFS_DRV_NAME "pfs"
#define PFS_MAJOR 2
#define PFS_MINOR 2
/* Define PFS_OSD_VER in your Makefile to build an OSD version, which will:
1. Enable the PIOCINVINODE IOCTL2 function.
2. (Unofficial) Return the LBA of the inode in private_5 and sub number in private_4 fields of the stat structure (returned by getstat and dread). */
#ifdef PFS_OSD_VER
#define PFS_IOCTL2_INC_CHECKSUM 1
#define PFS_STAT_RETURN_INODE_LBA 1
#endif
#endif
| 29.736842 | 151 | 0.759292 |
8334732c4abaed9b0191216645a2ac614213348d | 3,188 | h | C | sys/dev/mk48txx/mk48txxvar.h | TrustedBSD/sebsd | fd5de6f587183087cf930779701d5713e8ca64cc | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 4 | 2017-04-06T21:39:15.000Z | 2019-10-09T17:34:14.000Z | sys/dev/mk48txx/mk48txxvar.h | TrustedBSD/sebsd | fd5de6f587183087cf930779701d5713e8ca64cc | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | sys/dev/mk48txx/mk48txxvar.h | TrustedBSD/sebsd | fd5de6f587183087cf930779701d5713e8ca64cc | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 1 | 2020-01-04T06:36:39.000Z | 2020-01-04T06:36:39.000Z | /*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*
* from: NetBSD: mk48txxvar.h,v 1.1 2003/11/01 22:41:42 tsutsui Exp
*
* $FreeBSD: src/sys/dev/mk48txx/mk48txxvar.h,v 1.2 2005/05/19 21:16:50 marius Exp $
*/
typedef uint8_t (*mk48txx_nvrd_t)(device_t, int);
typedef void (*mk48txx_nvwr_t)(device_t, int, uint8_t);
struct mk48txx_softc {
bus_space_tag_t sc_bst; /* bus space tag */
bus_space_handle_t sc_bsh; /* bus space handle */
struct mtx sc_mtx; /* hardware mutex */
eventhandler_tag sc_wet; /* watchdog event handler tag */
const char *sc_model; /* chip model name */
bus_size_t sc_nvramsz; /* Size of NVRAM on the chip */
bus_size_t sc_clkoffset; /* Offset in NVRAM to clock bits */
u_int sc_year0; /* year counter offset */
u_int sc_flag; /* MD flags */
#define MK48TXX_NO_CENT_ADJUST 0x0001 /* don't manually adjust century */
#define MK48TXX_WDOG_REGISTER 0x0002 /* register watchdog */
#define MK48TXX_WDOG_ENABLE_WDS 0x0004 /* enable watchdog steering bit */
mk48txx_nvrd_t sc_nvrd; /* NVRAM/RTC read function */
mk48txx_nvwr_t sc_nvwr; /* NVRAM/RTC write function */
};
/* Chip attach function */
int mk48txx_attach(device_t);
/* Methods for the clock interface */
int mk48txx_gettime(device_t, struct timespec *);
int mk48txx_settime(device_t, struct timespec *);
| 45.542857 | 84 | 0.750941 |
8334cfc8468e89af7cc3c1daab016a25ec28e716 | 4,219 | h | C | System/Library/PrivateFrameworks/FrontBoard.framework/FBSceneMonitor.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 12 | 2019-06-02T02:42:41.000Z | 2021-04-13T07:22:20.000Z | System/Library/PrivateFrameworks/FrontBoard.framework/FBSceneMonitor.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/FrontBoard.framework/FBSceneMonitor.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 3 | 2019-06-11T02:46:10.000Z | 2019-12-21T14:58:16.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Saturday, June 1, 2019 at 6:47:20 PM Mountain Standard Time
* Operating System: Version 12.1.1 (Build 16C5050a)
* Image Source: /System/Library/PrivateFrameworks/FrontBoard.framework/FrontBoard
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <libobjc.A.dylib/FBSceneManagerInternalObserver.h>
#import <libobjc.A.dylib/FBSceneLayerManagerObserver.h>
#import <libobjc.A.dylib/FBSceneMonitorDelegate.h>
@protocol FBSceneMonitorDelegate;
@class FBScene, NSString, NSMutableSet, NSMutableDictionary, FBSSceneClientSettingsDiffInspector, FBSMutableSceneSettings, FBSceneMonitorBehaviors, FBSSceneSettings;
@interface FBSceneMonitor : NSObject <FBSceneManagerInternalObserver, FBSceneLayerManagerObserver, FBSceneMonitorDelegate> {
FBScene* _scene;
NSString* _sceneID;
NSMutableSet* _externalSceneIDs;
NSMutableSet* _pairedExternalSceneIDs;
NSMutableDictionary* _monitorsBySceneID;
FBSSceneClientSettingsDiffInspector* _diffInspector;
FBSMutableSceneSettings* _sceneSettings;
FBSMutableSceneSettings* _effectiveSettings;
FBSceneMonitorBehaviors* _givenMonitorBehaviors;
FBSceneMonitorBehaviors* _delegateMonitorBehaviors;
FBSceneMonitorBehaviors* _effectiveMonitorBehaviors;
BOOL _invalidated;
BOOL _isSynchronizing;
BOOL _updateSettingsAfterSync;
BOOL _updateExternalScenesAfterSync;
id<FBSceneMonitorDelegate> _delegate;
}
@property (nonatomic,readonly) FBScene * scene; //@synthesize scene=_scene - In the implementation block
@property (nonatomic,copy,readonly) NSString * sceneID; //@synthesize sceneID=_sceneID - In the implementation block
@property (assign,nonatomic,__weak) id<FBSceneMonitorDelegate> delegate; //@synthesize delegate=_delegate - In the implementation block
@property (nonatomic,copy) FBSceneMonitorBehaviors * behaviors; //@synthesize givenMonitorBehaviors=_givenMonitorBehaviors - In the implementation block
@property (nonatomic,readonly) FBSSceneSettings * sceneSettings; //@synthesize sceneSettings=_sceneSettings - In the implementation block
@property (nonatomic,readonly) FBSSceneSettings * effectiveSceneSettings; //@synthesize effectiveSettings=_effectiveSettings - In the implementation block
@property (readonly) unsigned long long hash;
@property (readonly) Class superclass;
@property (copy,readonly) NSString * description;
@property (copy,readonly) NSString * debugDescription;
-(NSString *)sceneID;
-(FBSSceneSettings *)sceneSettings;
-(void)sceneLayerManager:(id)arg1 didRepositionLayer:(id)arg2 fromIndex:(unsigned long long)arg3 toIndex:(unsigned long long)arg4 ;
-(void)_updateScenePairingState:(BOOL)arg1 ;
-(void)_evaluateEffectiveMonitorBehaviors;
-(id)initWithSceneID:(id)arg1 ;
-(id)_initWithSceneManager:(id)arg1 sceneID:(id)arg2 ;
-(void)sceneMonitor:(id)arg1 effectiveSceneSettingsDidChangeWithDiff:(id)arg2 previousSettings:(id)arg3 ;
-(void)_updateAllSceneStateIgnoringDelegate;
-(void)_setEffectiveMonitorBehaviors:(id)arg1 ;
-(void)_updateSceneSettings:(BOOL)arg1 ;
-(void)_updateExternalScenes:(BOOL)arg1 ;
-(void)_updateEffectiveSceneSettings:(BOOL)arg1 ;
-(FBSSceneSettings *)effectiveSceneSettings;
-(void)sceneManager:(id)arg1 didCreateScene:(id)arg2 ;
-(void)sceneManager:(id)arg1 willDestroyScene:(id)arg2 ;
-(void)sceneManager:(id)arg1 didDestroyScene:(id)arg2 ;
-(void)sceneManager:(id)arg1 updateForScene:(id)arg2 appliedWithContext:(id)arg3 ;
-(void)sceneManagerWillBeginSceneUpdateSynchronization:(id)arg1 ;
-(void)sceneManagerDidEndSceneUpdateSynchronization:(id)arg1 ;
-(BOOL)isPairedWithExternalSceneID:(id)arg1 ;
-(id)_effectiveBehaviors;
-(void)sceneManager:(id)arg1 scene:(id)arg2 didUpdateClientSettingsWithDiff:(id)arg3 oldClientSettings:(id)arg4 transitionContext:(id)arg5 ;
-(void)dealloc;
-(NSString *)description;
-(void)setDelegate:(id<FBSceneMonitorDelegate>)arg1 ;
-(id<FBSceneMonitorDelegate>)delegate;
-(void)invalidate;
-(FBScene *)scene;
-(id)initWithScene:(id)arg1 ;
-(FBSceneMonitorBehaviors *)behaviors;
-(void)setBehaviors:(FBSceneMonitorBehaviors *)arg1 ;
@end
| 52.08642 | 175 | 0.792131 |
8334ddfd77fa0465c6f36bcdc0bd59f5639fd1b7 | 181 | h | C | ObjC/Others/PassByValue/ByKVC/ByKVC/LoginedViewController.h | guowilling/iOSDevCollection | ba1569ad09ad06bebe427dc9b3bc3e35605254c3 | [
"MIT"
] | 1 | 2017-10-11T08:33:00.000Z | 2017-10-11T08:33:00.000Z | ObjC/Others/PassByValue/ByKVC/ByKVC/LoginedViewController.h | guowilling/iOSDevCollection | ba1569ad09ad06bebe427dc9b3bc3e35605254c3 | [
"MIT"
] | null | null | null | ObjC/Others/PassByValue/ByKVC/ByKVC/LoginedViewController.h | guowilling/iOSDevCollection | ba1569ad09ad06bebe427dc9b3bc3e35605254c3 | [
"MIT"
] | null | null | null |
#import <UIKit/UIKit.h>
@interface LoginedViewController : UIViewController
@property(nonatomic, strong)NSString *userName;
@property(nonatomic, strong)NSString *passWord;
@end
| 18.1 | 51 | 0.79558 |
83364fedbf0ab57962a7b325663ab910d6173a0a | 8,192 | c | C | drivers/irqchip/irq-brcmstb-l2.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 3 | 2020-11-06T05:17:03.000Z | 2020-11-06T07:32:34.000Z | drivers/irqchip/irq-brcmstb-l2.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | null | null | null | drivers/irqchip/irq-brcmstb-l2.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 1 | 2020-11-06T07:32:55.000Z | 2020-11-06T07:32:55.000Z | /*
* Generic Broadcom Set Top Box Level 2 Interrupt controller driver
*
* Copyright (C) 2014-2017 Broadcom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/irqdomain.h>
#include <linux/irqchip.h>
#include <linux/irqchip/chained_irq.h>
struct brcmstb_intc_init_params {
irq_flow_handler_t handler;
int cpu_status;
int cpu_clear;
int cpu_mask_status;
int cpu_mask_set;
int cpu_mask_clear;
};
/* Register offsets in the L2 latched interrupt controller */
static const struct brcmstb_intc_init_params l2_edge_intc_init = {
.handler = handle_edge_irq,
.cpu_status = 0x00,
.cpu_clear = 0x08,
.cpu_mask_status = 0x0c,
.cpu_mask_set = 0x10,
.cpu_mask_clear = 0x14
};
/* Register offsets in the L2 level interrupt controller */
static const struct brcmstb_intc_init_params l2_lvl_intc_init = {
.handler = handle_level_irq,
.cpu_status = 0x00,
.cpu_clear = -1, /* Register not present */
.cpu_mask_status = 0x04,
.cpu_mask_set = 0x08,
.cpu_mask_clear = 0x0C
};
/* L2 intc private data structure */
struct brcmstb_l2_intc_data {
struct irq_domain *domain;
struct irq_chip_generic *gc;
int status_offset;
int mask_offset;
bool can_wake;
u32 saved_mask; /* for suspend/resume */
};
/**
* brcmstb_l2_mask_and_ack - Mask and ack pending interrupt
* @d: irq_data
*
* Chip has separate enable/disable registers instead of a single mask
* register and pending interrupt is acknowledged by setting a bit.
*
* Note: This function is generic and could easily be added to the
* generic irqchip implementation if there ever becomes a will to do so.
* Perhaps with a name like irq_gc_mask_disable_and_ack_set().
*
* e.g.: https://patchwork.kernel.org/patch/9831047/
*/
static void brcmstb_l2_mask_and_ack(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
u32 mask = d->mask;
irq_gc_lock(gc);
irq_reg_writel(gc, mask, ct->regs.disable);
*ct->mask_cache &= ~mask;
irq_reg_writel(gc, mask, ct->regs.ack);
irq_gc_unlock(gc);
}
static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc)
{
struct brcmstb_l2_intc_data *b = irq_desc_get_handler_data(desc);
struct irq_chip *chip = irq_desc_get_chip(desc);
unsigned int irq;
u32 status;
chained_irq_enter(chip, desc);
status = irq_reg_readl(b->gc, b->status_offset) &
~(irq_reg_readl(b->gc, b->mask_offset));
if (status == 0) {
raw_spin_lock(&desc->lock);
handle_bad_irq(desc);
raw_spin_unlock(&desc->lock);
goto out;
}
do {
irq = ffs(status) - 1;
status &= ~(1 << irq);
generic_handle_irq(irq_linear_revmap(b->domain, irq));
} while (status);
out:
chained_irq_exit(chip, desc);
}
static void brcmstb_l2_intc_suspend(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
struct brcmstb_l2_intc_data *b = gc->private;
unsigned long flags;
irq_gc_lock_irqsave(gc, flags);
/* Save the current mask */
b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
if (b->can_wake) {
/* Program the wakeup mask */
irq_reg_writel(gc, ~gc->wake_active, ct->regs.disable);
irq_reg_writel(gc, gc->wake_active, ct->regs.enable);
}
irq_gc_unlock_irqrestore(gc, flags);
}
static void brcmstb_l2_intc_resume(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct irq_chip_type *ct = irq_data_get_chip_type(d);
struct brcmstb_l2_intc_data *b = gc->private;
unsigned long flags;
irq_gc_lock_irqsave(gc, flags);
if (ct->chip.irq_ack) {
/* Clear unmasked non-wakeup interrupts */
irq_reg_writel(gc, ~b->saved_mask & ~gc->wake_active,
ct->regs.ack);
}
/* Restore the saved mask */
irq_reg_writel(gc, b->saved_mask, ct->regs.disable);
irq_reg_writel(gc, ~b->saved_mask, ct->regs.enable);
irq_gc_unlock_irqrestore(gc, flags);
}
static int __init brcmstb_l2_intc_of_init(struct device_node *np,
struct device_node *parent,
const struct brcmstb_intc_init_params
*init_params)
{
unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
struct brcmstb_l2_intc_data *data;
struct irq_chip_type *ct;
int ret;
unsigned int flags;
int parent_irq;
void __iomem *base;
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
base = of_iomap(np, 0);
if (!base) {
pr_err("failed to remap intc L2 registers\n");
ret = -ENOMEM;
goto out_free;
}
/* Disable all interrupts by default */
writel(0xffffffff, base + init_params->cpu_mask_set);
/* Wakeup interrupts may be retained from S5 (cold boot) */
data->can_wake = of_property_read_bool(np, "brcm,irq-can-wake");
if (!data->can_wake && (init_params->cpu_clear >= 0))
writel(0xffffffff, base + init_params->cpu_clear);
parent_irq = irq_of_parse_and_map(np, 0);
if (!parent_irq) {
pr_err("failed to find parent interrupt\n");
ret = -EINVAL;
goto out_unmap;
}
data->domain = irq_domain_add_linear(np, 32,
&irq_generic_chip_ops, NULL);
if (!data->domain) {
ret = -ENOMEM;
goto out_unmap;
}
/* MIPS chips strapped for BE will automagically configure the
* peripheral registers for CPU-native byte order.
*/
flags = 0;
if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
flags |= IRQ_GC_BE_IO;
/* Allocate a single Generic IRQ chip for this node */
ret = irq_alloc_domain_generic_chips(data->domain, 32, 1,
np->full_name, init_params->handler, clr, 0, flags);
if (ret) {
pr_err("failed to allocate generic irq chip\n");
goto out_free_domain;
}
/* Set the IRQ chaining logic */
irq_set_chained_handler_and_data(parent_irq,
brcmstb_l2_intc_irq_handle, data);
data->gc = irq_get_domain_generic_chip(data->domain, 0);
data->gc->reg_base = base;
data->gc->private = data;
data->status_offset = init_params->cpu_status;
data->mask_offset = init_params->cpu_mask_status;
ct = data->gc->chip_types;
if (init_params->cpu_clear >= 0) {
ct->regs.ack = init_params->cpu_clear;
ct->chip.irq_ack = irq_gc_ack_set_bit;
ct->chip.irq_mask_ack = brcmstb_l2_mask_and_ack;
} else {
/* No Ack - but still slightly more efficient to define this */
ct->chip.irq_mask_ack = irq_gc_mask_disable_reg;
}
ct->chip.irq_mask = irq_gc_mask_disable_reg;
ct->regs.disable = init_params->cpu_mask_set;
ct->regs.mask = init_params->cpu_mask_status;
ct->chip.irq_unmask = irq_gc_unmask_enable_reg;
ct->regs.enable = init_params->cpu_mask_clear;
ct->chip.irq_suspend = brcmstb_l2_intc_suspend;
ct->chip.irq_resume = brcmstb_l2_intc_resume;
ct->chip.irq_pm_shutdown = brcmstb_l2_intc_suspend;
if (data->can_wake) {
/* This IRQ chip can wake the system, set all child interrupts
* in wake_enabled mask
*/
data->gc->wake_enabled = 0xffffffff;
ct->chip.irq_set_wake = irq_gc_set_wake;
}
return 0;
out_free_domain:
irq_domain_remove(data->domain);
out_unmap:
iounmap(base);
out_free:
kfree(data);
return ret;
}
int __init brcmstb_l2_edge_intc_of_init(struct device_node *np,
struct device_node *parent)
{
return brcmstb_l2_intc_of_init(np, parent, &l2_edge_intc_init);
}
IRQCHIP_DECLARE(brcmstb_l2_intc, "brcm,l2-intc", brcmstb_l2_edge_intc_of_init);
int __init brcmstb_l2_lvl_intc_of_init(struct device_node *np,
struct device_node *parent)
{
return brcmstb_l2_intc_of_init(np, parent, &l2_lvl_intc_init);
}
IRQCHIP_DECLARE(bcm7271_l2_intc, "brcm,bcm7271-l2-intc",
brcmstb_l2_lvl_intc_of_init);
| 28.054795 | 79 | 0.738525 |
8338be4534abb6857c9fa5841ef9e6b11f8221d3 | 4,908 | h | C | fuse_constraints/include/fuse_constraints/normal_prior_pose_2d_cost_functor.h | congleetea/fuse | 7a87a59915a213431434166c96d0705ba6aa00b2 | [
"BSD-3-Clause"
] | 383 | 2018-07-02T07:20:32.000Z | 2022-03-31T12:51:06.000Z | fuse_constraints/include/fuse_constraints/normal_prior_pose_2d_cost_functor.h | congleetea/fuse | 7a87a59915a213431434166c96d0705ba6aa00b2 | [
"BSD-3-Clause"
] | 117 | 2018-07-16T10:32:52.000Z | 2022-02-02T20:15:16.000Z | fuse_constraints/include/fuse_constraints/normal_prior_pose_2d_cost_functor.h | congleetea/fuse | 7a87a59915a213431434166c96d0705ba6aa00b2 | [
"BSD-3-Clause"
] | 74 | 2018-10-01T10:10:45.000Z | 2022-03-02T04:48:22.000Z | /*
* Software License Agreement (BSD License)
*
* Copyright (c) 2018, Locus Robotics
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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
* COPYRIGHT HOLDER OR CONTRIBUTORS 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.
*/
#ifndef FUSE_CONSTRAINTS_NORMAL_PRIOR_POSE_2D_COST_FUNCTOR_H
#define FUSE_CONSTRAINTS_NORMAL_PRIOR_POSE_2D_COST_FUNCTOR_H
#include <fuse_core/eigen.h>
#include <fuse_core/macros.h>
#include <fuse_core/util.h>
#include <Eigen/Core>
namespace fuse_constraints
{
/**
* @brief Create a prior cost function on both the position and orientation variables at once.
*
* The Ceres::NormalPrior cost function only supports a single variable. This is a convenience cost function that
* applies a prior constraint on both the position and orientation variables at once.
*
* The cost function is of the form:
*
* || [ x - b(0)] ||^2
* cost(x) = ||A * [ y - b(1)] ||
* || [yaw - b(2)] ||
*
* Here, the matrix A can be of variable size, thereby permitting the computation of errors for partial measurements.
* The vector b is a fixed-size 3x1. In case the user is interested in implementing a cost function of the form:
*
* cost(X) = (X - mu)^T S^{-1} (X - mu)
*
* where, mu is a vector and S is a covariance matrix, then, A = S^{-1/2}, i.e the matrix A is the square root
* information matrix (the inverse of the covariance).
*/
class NormalPriorPose2DCostFunctor
{
public:
/**
* @brief Construct a cost function instance
*
* The residual weighting matrix can vary in size, as this cost functor can be used to compute costs for partial
* vectors. The number of rows of A will be the number of dimensions for which you want to compute the error, and the
* number of columns in A will be fixed at 3. For example, if we just want to use the values of x and yaw, then \p A
* will be of size 2x3.
*
* @param[in] A The residual weighting matrix, most likely the square root information matrix in order (x, y, yaw)
* @param[in] b The pose measurement or prior in order (x, y, yaw)
*/
NormalPriorPose2DCostFunctor(const fuse_core::MatrixXd& A, const fuse_core::Vector3d& b);
/**
* @brief Evaluate the cost function. Used by the Ceres optimization engine.
*/
template <typename T>
bool operator()(const T* const position, const T* const orientation, T* residual) const;
private:
fuse_core::MatrixXd A_; //!< The residual weighting matrix, most likely the square root information matrix
fuse_core::Vector3d b_; //!< The measured 2D pose value
};
NormalPriorPose2DCostFunctor::NormalPriorPose2DCostFunctor(const fuse_core::MatrixXd& A, const fuse_core::Vector3d& b) :
A_(A),
b_(b)
{
}
template <typename T>
bool NormalPriorPose2DCostFunctor::operator()(const T* const position, const T* const orientation, T* residual) const
{
Eigen::Matrix<T, 3, 1> full_residuals_vector;
full_residuals_vector(0) = position[0] - T(b_(0));
full_residuals_vector(1) = position[1] - T(b_(1));
full_residuals_vector(2) = fuse_core::wrapAngle2D(orientation[0] - T(b_(2)));
// Scale the residuals by the square root information matrix to account for
// the measurement uncertainty.
Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>> residuals_vector(residual, A_.rows());
residuals_vector = A_.template cast<T>() * full_residuals_vector;
return true;
}
} // namespace fuse_constraints
#endif // FUSE_CONSTRAINTS_NORMAL_PRIOR_POSE_2D_COST_FUNCTOR_H
| 41.243697 | 120 | 0.726773 |
8339376956aed78874151e94e53848f1c9ce48ab | 313 | h | C | enclosing_ball/src/hello_triangle/pch.h | kingofthebongo2008/enclosing_ball | 2bb71d89e299a808aebb21e41a1edb6d87aed67f | [
"Apache-2.0"
] | 5 | 2019-03-29T16:47:47.000Z | 2019-05-08T18:34:50.000Z | enclosing_ball/src/hello_triangle/pch.h | kingofthebongo2008/enclosing_ball | 2bb71d89e299a808aebb21e41a1edb6d87aed67f | [
"Apache-2.0"
] | 3 | 2019-04-21T08:05:04.000Z | 2019-04-21T08:05:44.000Z | enclosing_ball/src/hello_triangle/pch.h | kingofthebongo2008/enclosing_ball | 2bb71d89e299a808aebb21e41a1edb6d87aed67f | [
"Apache-2.0"
] | null | null | null | //
// pch.h
// Header for standard system include files.
//
#pragma once
#define NOMINMAX // Exclude windows header macro
#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
| 16.473684 | 89 | 0.648562 |
83396690b4b8cd9360fa611d30bdcb799268499d | 2,063 | c | C | tests/src/token.c | mmdmine/brainfuck | 4579c92e73bcf26d8cc85dd86619604e4e9bd5a9 | [
"MIT"
] | 2 | 2020-12-03T15:24:56.000Z | 2021-02-23T19:16:02.000Z | tests/src/token.c | mmdmine/brainfuck | 4579c92e73bcf26d8cc85dd86619604e4e9bd5a9 | [
"MIT"
] | null | null | null | tests/src/token.c | mmdmine/brainfuck | 4579c92e73bcf26d8cc85dd86619604e4e9bd5a9 | [
"MIT"
] | null | null | null | // test madvm/src/token.c
#include <stddef.h>
#include <assert.h>
#include "token.h"
#define VECTOR_INITIAL_SIZE 4
#define APPEND_TEST(I, TOKEN) token_vector_append(tokens, (TOKEN)); \
assert(tokens->count == I+1); \
assert(tokens->tokens[I] == (TOKEN));
int main(int argc, char **argv) {
// test token_vector_new
token_vector_t *tokens = token_vector_new(VECTOR_INITIAL_SIZE);
assert(tokens != NULL);
assert(tokens->tokens != NULL);
assert(tokens->count == 0);
assert(tokens->size == VECTOR_INITIAL_SIZE);
// test token_vector_append and test_vector_grow
APPEND_TEST(0, token_increment)
APPEND_TEST(1, token_decrement)
APPEND_TEST(2, token_pointer_next)
APPEND_TEST(3, token_pointer_prev)
assert(tokens->size == VECTOR_INITIAL_SIZE);
APPEND_TEST(4, token_open_bracket)
assert(tokens->size == VECTOR_INITIAL_SIZE + TOKEN_VECTOR_GROW_SIZE);
token_vector_grow(tokens, 1);
assert(tokens->size == VECTOR_INITIAL_SIZE + TOKEN_VECTOR_GROW_SIZE + 1);
token_vector_free(tokens);
tokens = token_vector_new(8);
token_vector_stokenize(tokens, "+-<>[]:Y");
assert(tokens->count == 8);
token_t expected[] = {
token_increment,
token_decrement,
token_pointer_prev,
token_pointer_next,
token_open_bracket,
token_close_bracket,
token_call,
token_fork
};
for (size_t i = 0; i < tokens->count; i++) {
assert(tokens->tokens[i] == expected[i]);
}
token_vector_free(tokens);
#if _POSIX_C_SOURCE >= 200809L
tokens = token_vector_new(8);
char *source_string = "+-<>[]:Y";
FILE * source_file = fmemopen(source_string, 9, "r");
assert(source_file != NULL);
token_vector_ftokenize(tokens, source_file);
fclose(source_file);
assert(tokens->count == 8);
for (size_t i = 0; i < tokens->count; i++) {
assert(tokens->tokens[i] == expected[i]);
}
token_vector_free(tokens);
#endif
} | 25.469136 | 77 | 0.636452 |
833b41470220e23fb9acc5895cb35622d09f7734 | 244 | h | C | DroiBaaSDemo/DroiBaaSDemo/DroiFeedback/DroiFeedbackSubmitViewController.h | DroiBaaS/DroiBaaS-Demo-iOS | 4e1ba82e8165d5b7f75410406fae98d08cbcb5dd | [
"MIT"
] | null | null | null | DroiBaaSDemo/DroiBaaSDemo/DroiFeedback/DroiFeedbackSubmitViewController.h | DroiBaaS/DroiBaaS-Demo-iOS | 4e1ba82e8165d5b7f75410406fae98d08cbcb5dd | [
"MIT"
] | null | null | null | DroiBaaSDemo/DroiBaaSDemo/DroiFeedback/DroiFeedbackSubmitViewController.h | DroiBaaS/DroiBaaS-Demo-iOS | 4e1ba82e8165d5b7f75410406fae98d08cbcb5dd | [
"MIT"
] | null | null | null | //
// DroiFeedbackSubmitViewController.h
// DroiFeedbackDemo
//
// Created by Jon on 16/6/27.
// Copyright © 2016年 Droi. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface DroiFeedbackSubmitViewController : UIViewController
@end
| 17.428571 | 62 | 0.737705 |
833b9d4a536f9de31527d631e273ef122e3efd27 | 1,365 | h | C | tests/CoreTests/RandomOuts.h | sehiotbe/alloy | 81c1ee5f30f56750a165347da877725439af2cd1 | [
"MIT"
] | 15 | 2018-02-22T11:19:20.000Z | 2021-05-24T22:58:55.000Z | tests/CoreTests/RandomOuts.h | sehiotbe/alloy | 81c1ee5f30f56750a165347da877725439af2cd1 | [
"MIT"
] | 10 | 2018-02-24T15:16:46.000Z | 2021-10-10T12:42:34.000Z | tests/CoreTests/RandomOuts.h | sehiotbe/alloy | 81c1ee5f30f56750a165347da877725439af2cd1 | [
"MIT"
] | 16 | 2018-02-23T10:11:06.000Z | 2021-09-11T16:31:10.000Z | /*
* Copyright (c) 2017-2018, The Alloy Developers.
* Portions Copyright (c) 2012-2017, The CryptoNote Developers, The Bytecoin Developers.
*
* This file is part of Alloy.
*
* This file is subject to the terms and conditions defined in the
* file 'LICENSE', which is part of this source code package.
*/
#pragma once
#include "Chaingen.h"
namespace CryptoNote {
struct COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_response;
}
struct GetRandomOutputs : public test_chain_unit_base
{
GetRandomOutputs();
// bool check_tx_verification_context(CryptoNote::TransactionValidationError tve, bool tx_added, size_t event_idx, const CryptoNote::Transaction& tx);
// bool check_block_verification_context(CryptoNote::BlockValidationError bve, size_t event_idx, const CryptoNote::BlockTemplate& block);
// bool mark_last_valid_block(CryptoNote::Core& c, size_t ev_index, const std::vector<test_event_entry>& events);
bool generate(std::vector<test_event_entry>& events) const;
private:
bool checkHalfUnlocked(CryptoNote::Core& c, size_t ev_index, const std::vector<test_event_entry>& events);
bool checkFullyUnlocked(CryptoNote::Core& c, size_t ev_index, const std::vector<test_event_entry>& events);
bool request(CryptoNote::Core& c, uint64_t amount, size_t mixin, CryptoNote::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_response& resp);
};
| 34.125 | 152 | 0.782418 |
833bba2c44ee36b8b9c67f05b48ece5fb405ba01 | 8,757 | h | C | Plugins/UBIKSolver/Source/UBIKRuntime/Public/AnimNode_UBIKSolver.h | straycatss/NectoXR | c7d00fe5070cfd1d94aa9401bb7ef66238d4cae7 | [
"MIT"
] | null | null | null | Plugins/UBIKSolver/Source/UBIKRuntime/Public/AnimNode_UBIKSolver.h | straycatss/NectoXR | c7d00fe5070cfd1d94aa9401bb7ef66238d4cae7 | [
"MIT"
] | null | null | null | Plugins/UBIKSolver/Source/UBIKRuntime/Public/AnimNode_UBIKSolver.h | straycatss/NectoXR | c7d00fe5070cfd1d94aa9401bb7ef66238d4cae7 | [
"MIT"
] | null | null | null | // 2020 Sticky Snout Studio (Jonas Molgaard)
#pragma once
#include "CoreMinimal.h"
#include "BoneControllers/AnimNode_SkeletalControlBase.h"
#include "UBIK.h"
#include "AnimNode_UBIKSolver.generated.h"
/**
* UBIK Solver
*/
USTRUCT(BlueprintInternalUseOnly)
struct UBIKRUNTIME_API FAnimNode_UBIKSolver : public FAnimNode_SkeletalControlBase
{
GENERATED_BODY()
public:
FAnimNode_UBIKSolver();
/** Feed in the HMD transform in WorldSpace. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UBIK, meta = (PinShownByDefault))
FTransform InHeadTransformWorld;
/** Feed in the Left MotionController in WorldSpace. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UBIK, meta = (PinShownByDefault))
FTransform InLeftHandTransformWorld;
/** Feed in the Right MotionController in WorldSpace. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UBIK, meta = (PinShownByDefault))
FTransform InRightHandTransformWorld;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UBIK, meta = (PinShownByDefault))
bool bApplyHeadTransform;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UBIK, meta = (PinShownByDefault))
bool bApplyRightHandTransform;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UBIK, meta = (PinShownByDefault))
bool bApplyLeftHandTransform;
/** By default Pelvis will be driven from Head location with an offset. Set to true to ignore Location. */
UPROPERTY(EditAnywhere, Category = UBIK)
bool bIgnorePelvisLocation;
UPROPERTY(EditAnywhere, Category = UBIK, meta = (InlineEditConditionToggle))
bool bApplyBoneAxis;
UPROPERTY(EditAnywhere, Category = UBIK, meta = (EditCondition="bApplyBoneAxis"))
TEnumAsByte<EBoneAxis> BoneAxis;
/** These settings will be returned by calling the GetUBIKSettings function. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UBIK, meta = (PinShownByDefault))
FUBIKSettings Settings;
//** Head bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference HeadBoneToModify = FBoneReference("head");
/** Left Clavicle bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference LeftClavicleBoneToModify = FBoneReference("clavicle_l");
/** Right Clavicle Arm bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference RightClavicleBoneToModify = FBoneReference("clavicle_r");
/** Left Upper Arm bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference LeftUpperArmBoneToModify = FBoneReference("upperarm_l");
/** Right Upper Arm bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference RightUpperArmBoneToModify = FBoneReference("upperarm_r");
/** Left Lower Arm bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference LeftLowerArmBoneToModify = FBoneReference("lowerarm_l");;
/** Right Lower Arm bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference RightLowerArmBoneToModify = FBoneReference("lowerarm_r");
/** Left Hand bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference LeftHandBoneToModify = FBoneReference("hand_l");
/** Right Hand bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference RightHandBoneToModify = FBoneReference("hand_r");
//** Spine01 bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference Spine01_BoneToModify = FBoneReference("spine_01");
//** Spine02 bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference Spine02_BoneToModify = FBoneReference("spine_02");
//** Spine03 bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference Spine03_BoneToModify = FBoneReference("spine_03");
//** Pelvis bone to modify */
UPROPERTY(EditAnywhere, Category = Bones)
FBoneReference PelvisBoneToModify = FBoneReference("pelvis");
UPROPERTY(EditAnywhere, Category = Debug)
bool bDrawDebug;
// FAnimNode_Base interface
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
// End of FAnimNode_Base interface
// FAnimNode_SkeletalControlBase interface
virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
virtual void EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms) override;
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) override;
virtual void UpdateInternal(const FAnimationUpdateContext& Context) override;
virtual void InitializeBoneReferences(const FBoneContainer& RequiredBones) override;
//virtual void CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) override;
// End of FAnimNode_SkeletalControlBase interface
private:
TArray<FBoneReference> AllBones;
UPROPERTY(Transient)
USkeletalMeshComponent* SkeletalMeshComponent;
UPROPERTY(Transient)
UWorld* World;
float CachedDeltaTime;
private:
FTransform LeftHandTransformWorld;
FTransform RightHandTransformWorld;
FTransform ComponentSpaceWorld;
FTransform ShoulderTransformWorld;
FTransform LeftUpperArmTransformWorld;
FTransform RightUpperArmTransformWorld;
FTransform LeftLowerArmTransformWorld;
FTransform RightLowerArmTransformWorld;
FTransform HeadTransformComponentSpace;
FTransform LeftHandTransformComponentSpace;
FTransform RightHandTransformComponentSpace;
FTransform ShoulderTransformComponentSpace;
FTransform LeftClavicleComponentSpace; // TODO: May be able to turn into a FRotator instead
FTransform RightClavicleComponentSpace; // TODO: May be able to turn into a FRotator instead
FTransform BaseCharTransformComponentSpace;
FTransform LeftUpperArmTransformComponentSpace;
FTransform LeftLowerArmTransformComponentSpace;
FTransform RightUpperArmTransformComponentSpace;
FTransform RightLowerArmTransformComponentSpace;
/** WorldSpace inverted **/
FTransform ShoulderTransform;
FTransform ComponentSpace;
FTransform HeadTransformS;
FTransform LeftHandTransformS;
FTransform RightHandTransformS;
FTransform LeftUpperArmTransformS;
FTransform RightUpperArmTransformS;
FTransform LeftLowerArmTransformS;
FTransform RightLowerArmTransformS;
float LeftHeadHandAngle;
float RightHeadHandAngle;
float LeftElbowHandAngle;
float RightElbowHandAngle;
FRotator HeadRotation;
FRotator Spine03_Rotation;
FRotator Spine02_Rotation;
FRotator Spine01_Rotation;
FTransform PelvisRotation;
FRotator ClavicleLRotation;
FRotator UpperArmLRotation;
FRotator LowerArmLRotation;
FRotator HandLRotation;
FRotator ClavicleRRotation;
FRotator UpperArmRRotation;
FRotator LowerArmRRotation;
FRotator HandRRotation;
private:
void ConvertTransforms();
void SetShoulder();
FVector GetShoulderLocation();
FRotator GetShoulderRotationFromHead();
FRotator GetShoulderRotationFromHands();
float GetHeadHandAngle(float LastAngle, const FVector& Hand, const FVector& HandHeadDelta);
void SetLeftUpperArm();
void SetRightUpperArm();
FTransform RotateUpperArm(bool IsLeftArm, const FVector& HandTranslation);
void ResetUpperArmsLocation();
void SolveArms();
void SetElbowBasePosition(const FVector& UpperArm, const FVector& Hand, bool bIsLeftArm, FTransform& UpperArmTransform,
FTransform& LowerArmTransform);
float RotateElbowByHandPosition(const FVector& Hand, bool bIsLeftArm);
float RotateElbowByHandRotation(const FTransform& LowerArm, FRotator Hand);
void RotateElbow(float Angle, const FTransform& UpperArm, const FTransform& LowerArm, const FVector& HandLoc, bool bIsLeftArm,
FTransform& NewUpperArm, FTransform& NewLowerArm);
FTransform GetBaseCharTransform();
void DrawDebug(FAnimInstanceProxy* AnimInstanceProxy);
void DebugDrawAxes(FAnimInstanceProxy* AnimInstanceProxy, const FTransform& Transform, bool DrawAxis = true,
FColor SphereColor = FColor::Silver);
/** The given Transform will only apply Translation if explicitly defined. */
void SetBoneTransform(TArray<FBoneTransform>& OutBoneTransforms, const FBoneReference& BoneToModify, const FTransform& InTransform,
FComponentSpacePoseContext& Output, const FBoneContainer& BoneContainer, bool bApplyRotation,
bool bApplyTranslation = false);
FVector GetAxisVector(const EBoneAxis Axis) const;
};
| 39.269058 | 139 | 0.759621 |
833cfd521558fa4466ce30f3bc6176702ab27cb7 | 481 | h | C | config.h | muflax-scholars/zathura | 6b0bd56842358a97ba3feba38dc48066ffc3a024 | [
"Zlib"
] | null | null | null | config.h | muflax-scholars/zathura | 6b0bd56842358a97ba3feba38dc48066ffc3a024 | [
"Zlib"
] | null | null | null | config.h | muflax-scholars/zathura | 6b0bd56842358a97ba3feba38dc48066ffc3a024 | [
"Zlib"
] | null | null | null | /* See LICENSE file for license and copyright information */
#ifndef CONFIG_H
#define CONFIG_H
#include "zathura.h"
/**
* This function loads the default values of the configuration
*
* @param zathura The zathura session
*/
void config_load_default(zathura_t* zathura);
/**
* Loads and evaluates a configuration file
*
* @param zathura The zathura session
* @param path Path to the configuration file
*/
void config_load_files(zathura_t* zathura);
#endif // CONFIG_H
| 20.041667 | 62 | 0.744283 |
833d27b71ef49f654652ed3764f268f0c1a34a8d | 10,891 | h | C | src/AgAVLTree_iter.h | Aditya-A-garwal/AVLtree | 6eb651a097222714f7522258439dcfeb78bdd40e | [
"MIT"
] | 1 | 2022-02-21T15:57:30.000Z | 2022-02-21T15:57:30.000Z | src/AgAVLTree_iter.h | Aditya-A-garwal/AVLtree | 6eb651a097222714f7522258439dcfeb78bdd40e | [
"MIT"
] | null | null | null | src/AgAVLTree_iter.h | Aditya-A-garwal/AVLtree | 6eb651a097222714f7522258439dcfeb78bdd40e | [
"MIT"
] | null | null | null | /**
* @file AgAVLTree_iter.h
* @author Aditya Agarwal (aditya,agarwal@dumblebots.com)
* @brief Implementation of AgAVLTree forward and reverse iterator methods
*/
/**
* @brief Construct a new avl tree::AVL<val t>::iterator::iterator object
*
* @note if pPtr is nullptr, then the iterator is said to be pointing to pTreePtr->end() (the logical element after the end in the forward direction)
*
* @param pPtr The pointer to encapsulate (points to node or nullptr)
* @param PTreeptr The point to the tree which contains the node
*/
template <typename val_t, auto mComp, auto mEquals>
AgAVLTree<val_t, mComp, mEquals>::iterator::iterator (node_ptr_t pPtr, tree_ptr_t pTreePtr) noexcept :
mPtr {pPtr}, mTreePtr {pTreePtr}
{}
/**
* @brief Dereferences and returns the value held by the encapsulated node
*
* @return AgAVLTree<val_t, mComp, mEquals>::iterator::ref_t Data held by tree node the iterator points to
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::iterator::ref_t
AgAVLTree<val_t, mComp, mEquals>::iterator::operator* () const
{
return mPtr->val;
}
/**
* @brief Prefix increment operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::iterator Incremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::iterator
AgAVLTree<val_t, mComp, mEquals>::iterator::operator++ ()
{
// if not pointing to end(), then get the next greater node
if (mPtr != nullptr) {
mPtr = mTreePtr->first_greater_strict_ptr (mPtr->val); // if a valid node is pointed to (not end()), then get the next greater node
}
return *this;
}
/**
* @brief Suffix increment operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::iterator Incremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::iterator
AgAVLTree<val_t, mComp, mEquals>::iterator::operator++ (int)
{
iterator cpy (this->mPtr, this->mTreePtr); // create a copy of the current iterator,
++(*this); // increment it,
return cpy; // and finally return the copy
}
/**
* @brief Prefix decrement operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::iterator Decremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::iterator
AgAVLTree<val_t, mComp, mEquals>::iterator::operator-- ()
{
if (mPtr != nullptr) { // if the node being being pointed to is valid,
node_ptr_t t {mTreePtr->last_smaller_strict_ptr (mPtr->val)}; // try to get the next smaller node
mPtr = (t != nullptr) ? (t) : (mPtr); // if such a node exists, use it
}
else { // else, if the current node is not valid (instance points to end())
mPtr = mTreePtr->find_max (); // then get the greateest (last) element of the tree
}
return *this;
}
/**
* @brief Suffix decrement operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::iterator Decremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::iterator
AgAVLTree<val_t, mComp, mEquals>::iterator::operator-- (int)
{
iterator cpy (this->mPtr, this->mTreePtr); // create a copy of the current iterator,
--(*this); // decrement it,
return cpy; // and finally return the copy
}
/**
* @brief Checks if the iterator points to the same node in the same tree
*
* @param pOther The iterator to compare to
*
* @return true If both iterators point to the same node of the same tree
* @return false If both iterators point to different nodes or belong to different trees
*/
template <typename val_t, auto mComp, auto mEquals>
bool
AgAVLTree<val_t, mComp, mEquals>::iterator::operator== (const AgAVLTree<val_t, mComp, mEquals>::iterator & pOther) const
{
return (mPtr == pOther.mPtr) && (mTreePtr == pOther.mTreePtr);
}
/**
* @brief Checks if the iterator points to different nodes or belong to different trees
*
* @param pOther The iterator to compare to
*
* @return true If both iterators point to the different nodes or belong to different trees
* @return false If both iterators point to the same node in the same tree
*/
template <typename val_t, auto mComp, auto mEquals>
bool
AgAVLTree<val_t, mComp, mEquals>::iterator::operator!= (const AgAVLTree<val_t, mComp, mEquals>::iterator & pOther) const
{
return (mPtr != pOther.mPtr) || (mTreePtr != pOther.mTreePtr);
}
/**
* @brief Construct a new avl tree::AVL<val t>::reverse_iterator instance
*
* @note if pPtr is nullptr, then the iterator is said to be pointing to pTreePtr->rend() (the logical element after the end in the reverse direction)
*
* @param pPtr The pointer to encapsulate (points to node or nullptr)
* @param pTreePtr The point to the tree which contains the node
*/
template <typename val_t, auto mComp, auto mEquals>
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::reverse_iterator (node_ptr_t pPtr, tree_ptr_t pTreePtr) noexcept :
mPtr {pPtr}, mTreePtr {pTreePtr}
{}
/**
* @brief Dereferences and returns the value held by the encapsulated node
*
* @return AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::ref_t Data held by tree node the iterator points to
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::ref_t
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::operator* () const
{
return mPtr->val;
}
/**
* @brief Prefix increment operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::reverse_iterator Incremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::reverse_iterator
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::operator++ ()
{
// if not pointing to rend(), then get the next greater node
if (mPtr != nullptr) {
mPtr = mTreePtr->last_smaller_strict_ptr (mPtr->val);
}
return *this;
}
/**
* @brief Suffix increment operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::reverse_iterator Incremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::reverse_iterator
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::operator++ (int)
{
reverse_iterator cpy (this->mPtr, this->mTreePtr); // create a copy of the current iterator,
++(*this); // increment it,
return cpy; // and finally return the copy
}
/**
* @brief Prefix decrement operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::iterator Decremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::reverse_iterator
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::operator-- ()
{
if (mPtr != nullptr) { // if the node being being pointed to is valid,
node_ptr_t t {mTreePtr->first_greater_strict_ptr (mPtr->val)}; // try to get the next greater node
mPtr = (t != nullptr) ? (t) : (mPtr); // if such a node exists, use it
}
else { // else, if the current node is not valid (instance points to rend())
mPtr = mTreePtr->find_min (); // then get the smallest (first) element of the tree
}
return *this;
}
/**
* @brief Suffix decrement operator (incremements the pointer to the next inorder node)
*
* @return AgAVLTree<val_t, mComp, mEquals>::reverse_iterator Decremented Iterator
*/
template <typename val_t, auto mComp, auto mEquals>
typename AgAVLTree<val_t, mComp, mEquals>::reverse_iterator
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::operator-- (int)
{
reverse_iterator cpy (this->mPtr, this->mTreePtr); // create a copy of the current iterator,
--(*this); // decrement it,
return cpy; // and finally return the copy
}
/**
* @brief Checks if the iterator points to different nodes or belong to different trees
*
* @param pOther The iterator to compare to
*
* @return true If both iterators point to the same node in the same tree
* @return false If both iterators point to the same nodes of belong to different trees
*/
template <typename val_t, auto mComp, auto mEquals>
bool
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::operator== (const AgAVLTree<val_t, mComp, mEquals>::reverse_iterator & pOther) const
{
return (mPtr == pOther.mPtr) && (mTreePtr == pOther.mTreePtr);
}
/**
* @brief Checks if the iterator points to different nodes or belong to different trees
*
* @param pOther The iterator to compare to
*
* @return true If both iterators point to the different nodes or belong to different trees
* @return false If both iterators point to the same node in the same tree
*/
template <typename val_t, auto mComp, auto mEquals>
bool
AgAVLTree<val_t, mComp, mEquals>::reverse_iterator::operator!= (const AgAVLTree<val_t, mComp, mEquals>::reverse_iterator & pOther) const
{
return (mPtr != pOther.mPtr) || (mTreePtr != pOther.mTreePtr);
}
| 44.81893 | 169 | 0.61234 |
833f777a2cb6538102cf8cd77742a2c3b22e4897 | 2,505 | h | C | CE4950-Networking-One/Workspace1/ce4950-term-project.cydsn/Generated_Source/PSoC5/Rx_IDLE_int.h | curthenrichs/Undergrad-Embedded-Projects | 1dde8079f50ebc5df5951f26ce633d25ea823515 | [
"BSD-3-Clause"
] | null | null | null | CE4950-Networking-One/Workspace1/ce4950-term-project.cydsn/Generated_Source/PSoC5/Rx_IDLE_int.h | curthenrichs/Undergrad-Embedded-Projects | 1dde8079f50ebc5df5951f26ce633d25ea823515 | [
"BSD-3-Clause"
] | null | null | null | CE4950-Networking-One/Workspace1/ce4950-term-project.cydsn/Generated_Source/PSoC5/Rx_IDLE_int.h | curthenrichs/Undergrad-Embedded-Projects | 1dde8079f50ebc5df5951f26ce633d25ea823515 | [
"BSD-3-Clause"
] | null | null | null | /*******************************************************************************
* File Name: Rx_IDLE_int.h
* Version 1.70
*
* Description:
* Provides the function definitions for the Interrupt Controller.
*
*
********************************************************************************
* Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
*******************************************************************************/
#if !defined(CY_ISR_Rx_IDLE_int_H)
#define CY_ISR_Rx_IDLE_int_H
#include <cytypes.h>
#include <cyfitter.h>
/* Interrupt Controller API. */
void Rx_IDLE_int_Start(void);
void Rx_IDLE_int_StartEx(cyisraddress address);
void Rx_IDLE_int_Stop(void);
CY_ISR_PROTO(Rx_IDLE_int_Interrupt);
void Rx_IDLE_int_SetVector(cyisraddress address);
cyisraddress Rx_IDLE_int_GetVector(void);
void Rx_IDLE_int_SetPriority(uint8 priority);
uint8 Rx_IDLE_int_GetPriority(void);
void Rx_IDLE_int_Enable(void);
uint8 Rx_IDLE_int_GetState(void);
void Rx_IDLE_int_Disable(void);
void Rx_IDLE_int_SetPending(void);
void Rx_IDLE_int_ClearPending(void);
/* Interrupt Controller Constants */
/* Address of the INTC.VECT[x] register that contains the Address of the Rx_IDLE_int ISR. */
#define Rx_IDLE_int_INTC_VECTOR ((reg32 *) Rx_IDLE_int__INTC_VECT)
/* Address of the Rx_IDLE_int ISR priority. */
#define Rx_IDLE_int_INTC_PRIOR ((reg8 *) Rx_IDLE_int__INTC_PRIOR_REG)
/* Priority of the Rx_IDLE_int interrupt. */
#define Rx_IDLE_int_INTC_PRIOR_NUMBER Rx_IDLE_int__INTC_PRIOR_NUM
/* Address of the INTC.SET_EN[x] byte to bit enable Rx_IDLE_int interrupt. */
#define Rx_IDLE_int_INTC_SET_EN ((reg32 *) Rx_IDLE_int__INTC_SET_EN_REG)
/* Address of the INTC.CLR_EN[x] register to bit clear the Rx_IDLE_int interrupt. */
#define Rx_IDLE_int_INTC_CLR_EN ((reg32 *) Rx_IDLE_int__INTC_CLR_EN_REG)
/* Address of the INTC.SET_PD[x] register to set the Rx_IDLE_int interrupt state to pending. */
#define Rx_IDLE_int_INTC_SET_PD ((reg32 *) Rx_IDLE_int__INTC_SET_PD_REG)
/* Address of the INTC.CLR_PD[x] register to clear the Rx_IDLE_int interrupt. */
#define Rx_IDLE_int_INTC_CLR_PD ((reg32 *) Rx_IDLE_int__INTC_CLR_PD_REG)
#endif /* CY_ISR_Rx_IDLE_int_H */
/* [] END OF FILE */
| 35.28169 | 95 | 0.695808 |
8340a054145168da5f75733947b5bf734f20a470 | 1,684 | h | C | Pod/Classes/SeafUploadFile.h | gzy403999903/seafile-iOS | dc842f4823ffa69d21a1c9ce70a5f4d68e184370 | [
"Apache-2.0"
] | 181 | 2015-01-01T14:20:20.000Z | 2022-02-19T17:37:46.000Z | Pod/Classes/SeafUploadFile.h | gzy403999903/seafile-iOS | dc842f4823ffa69d21a1c9ce70a5f4d68e184370 | [
"Apache-2.0"
] | 210 | 2015-01-02T07:21:53.000Z | 2022-02-23T03:39:30.000Z | Pod/Classes/SeafUploadFile.h | gzy403999903/seafile-iOS | dc842f4823ffa69d21a1c9ce70a5f4d68e184370 | [
"Apache-2.0"
] | 131 | 2015-01-08T17:13:50.000Z | 2022-02-14T01:54:50.000Z | //
// SeafUploadFile.h
// seafile
//
// Created by Wang Wei on 10/13/12.
// Copyright (c) 2012 Seafile Ltd. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <QuickLook/QuickLook.h>
#import <Photos/Photos.h>
#import "SeafPreView.h"
#import "SeafTaskQueue.h"
@class SeafConnection;
@class SeafUploadFile;
@class SeafDir;
typedef void (^SeafUploadCompletionBlock)(SeafUploadFile *file, NSString *oid, NSError *error);
@protocol SeafUploadDelegate <NSObject>
- (void)uploadProgress:(SeafUploadFile *)file progress:(float)progress;
- (void)uploadComplete:(BOOL)success file:(SeafUploadFile *)file oid:(NSString *)oid;
@end
@interface SeafUploadFile : NSObject<SeafPreView, QLPreviewItem, SeafTask>
@property (readonly) NSString *lpath;
@property (readonly) NSString *name;
@property (readonly) long long filesize;
@property (nonatomic, readonly, getter=isUploaded) BOOL uploaded;
@property (nonatomic, readonly, getter=isUploading) BOOL uploading;
@property (readwrite) BOOL overwrite;
@property (nonatomic, readonly) PHAsset *asset;
@property (nonatomic, readonly) NSURL *assetURL;
@property (nonatomic, readonly) NSString *assetIdentifier;
@property (readwrite) BOOL autoSync;
@property (readonly) float uProgress;
@property (nonatomic) id<SeafUploadDelegate> delegate;
@property (nonatomic) SeafUploadCompletionBlock completionBlock;
@property (readwrite) SeafDir *udir;
@property (nonatomic, strong) UIImage *previewImage;//NSItemProvider previewImage
@property (nonatomic, assign, getter=isStarred) BOOL starred;
- (id)initWithPath:(NSString *)lpath;
- (void)setPHAsset:(PHAsset *)asset url:(NSURL *)url;
- (BOOL)waitUpload;
- (void)cleanup;
@end
| 28.542373 | 95 | 0.767815 |
8341d7778d5ed4cb056a77ed846d7120a3f9cd5f | 1,161 | c | C | tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 5 | 2020-04-04T09:24:09.000Z | 2020-04-19T12:33:55.000Z | tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 30 | 2018-05-02T08:43:27.000Z | 2022-01-23T03:25:54.000Z | /*
* Copyright 2014, Michael Ellerman, IBM Corp.
* Licensed under GPLv2.
*/
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <signal.h>
#include "ebb.h"
/* Test that things work sanely if we have no handler */
static int no_handler_test(void)
{
struct event event;
u64 val;
int i;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);
event.attr.exclude_kernel = 1;
event.attr.exclude_hv = 1;
event.attr.exclude_idle = 1;
FAIL_IF(event_open(&event));
FAIL_IF(ebb_event_enable(&event));
val = mfspr(SPRN_EBBHR);
FAIL_IF(val != 0);
/* Make sure it overflows quickly */
sample_period = 1000;
mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
/* Spin to make sure the event has time to overflow */
for (i = 0; i < 1000; i++)
mb();
dump_ebb_state();
/* We expect to see the PMU frozen & PMAO set */
val = mfspr(SPRN_MMCR0);
FAIL_IF(val != 0x0000000080000080);
event_close(&event);
dump_ebb_state();
/* The real test is that we never took an EBB at 0x0 */
return 0;
}
int main(void)
{
return test_harness(no_handler_test,"no_handler_test");
}
| 18.140625 | 56 | 0.69509 |
834419ae147ebbf6cd287a03d179b643cc470f67 | 828 | h | C | YUKit/uikit/category/UIAlertController+YU.h | c6357/YUKit | a77d3f359c296aa323f6fbd0bb7dff4068496437 | [
"MIT"
] | 74 | 2015-11-28T10:19:55.000Z | 2021-01-06T03:04:07.000Z | YUKit/uikit/category/UIAlertController+YU.h | c6357/YUKit | a77d3f359c296aa323f6fbd0bb7dff4068496437 | [
"MIT"
] | null | null | null | YUKit/uikit/category/UIAlertController+YU.h | c6357/YUKit | a77d3f359c296aa323f6fbd0bb7dff4068496437 | [
"MIT"
] | 24 | 2015-11-28T11:08:36.000Z | 2019-03-22T02:47:29.000Z | //
// UIViewController+YU.m
// YUKit<https://github.com/c6357/YUKit>
//
// Created by BruceYu on 15/12/9.
// Copyright © 2015年 BruceYu. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIAlertController (YU)
/**
alertController title
*/
@property (nonatomic, strong) UILabel *yu_titleLabel;
/**
alertController message
*/
@property (nonatomic, strong) UILabel *yu_messageLabel;
+ (UIAlertController*)yu_alertControllerWithTitle:(NSString *)title message:(NSString *)message cancelTitle:(NSString *)cancelTitle cancelBlock:(void(^)(void))cancelBlock;
+ (UIAlertController*)yu_alertControllerWithTitle:(NSString *)title message:(NSString *)message submitTitle:(NSString *)submitTitle submitBlock:(void(^)(void))submitBlock cancelTitle:(NSString *)cancelTitle cancelBlock:(void(^)(void))cancelBlock;
@end
| 28.551724 | 246 | 0.754831 |
8345bfd4e1047eda11b7ed317b8153ecc8b6dedb | 661 | h | C | build/iphone/Classes/TiUIiOSAdViewProxy.h | jeffhamersly/ocho-app | 232bcd7b3e878ad9c217883da1ab1d52ff763d0e | [
"Apache-2.0"
] | 2 | 2015-08-30T19:39:01.000Z | 2015-09-06T12:58:34.000Z | build/iphone/Classes/TiUIiOSAdViewProxy.h | jeffhamersly/ocho-app | 232bcd7b3e878ad9c217883da1ab1d52ff763d0e | [
"Apache-2.0"
] | null | null | null | build/iphone/Classes/TiUIiOSAdViewProxy.h | jeffhamersly/ocho-app | 232bcd7b3e878ad9c217883da1ab1d52ff763d0e | [
"Apache-2.0"
] | null | null | null | /**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2015 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
* WARNING: This is generated code. Modify at your own risk and without support.
*/
#import "TiUIViewProxy.h"
#ifdef USE_TI_UIIOSADVIEW
@interface TiUIiOSAdViewProxy : TiUIViewProxy {
}
// Need these for sanity checking and constants, so they
// must be class-available rather than instance-available
+(NSString*)portraitSize;
+(NSString*)landscapeSize;
#pragma mark internal
-(void)fireLoad:(id)unused;
@end
#endif
| 24.481481 | 80 | 0.760968 |
8346ac898da62ec8fbe2b94cfbd9587c0e383229 | 706 | h | C | src/commands/ServerDeviceListCommand.h | jalowiczor/gateway | 612a08d6154e8768dfd30f1e1f00de1bfcad090f | [
"BSD-3-Clause"
] | null | null | null | src/commands/ServerDeviceListCommand.h | jalowiczor/gateway | 612a08d6154e8768dfd30f1e1f00de1bfcad090f | [
"BSD-3-Clause"
] | null | null | null | src/commands/ServerDeviceListCommand.h | jalowiczor/gateway | 612a08d6154e8768dfd30f1e1f00de1bfcad090f | [
"BSD-3-Clause"
] | null | null | null | #ifndef BEEEON_SERVER_DEVICE_LIST_COMMAND_H
#define BEEEON_SERVER_DEVICE_LIST_COMMAND_H
#include "core/Command.h"
#include "model/DevicePrefix.h"
namespace BeeeOn {
/*
* List of joined devices serves for device discovery,
* with which this device manager (identified by DevicePrefix)
* can communicate. This information should not be saved
* directly on gateway.
*/
class ServerDeviceListCommand : public Command {
public:
typedef Poco::AutoPtr<ServerDeviceListCommand> Ptr;
ServerDeviceListCommand(const DevicePrefix &prefix);
DevicePrefix devicePrefix() const;
std::string toString() const override;
protected:
~ServerDeviceListCommand();
private:
DevicePrefix m_prefix;
};
}
#endif
| 20.171429 | 62 | 0.787535 |
8346c1b03cf51a5d04cb3f277bd64887ca669765 | 7,781 | h | C | src/include/storage/write_ahead_log/log_io.h | tpan496/project3 | 82714c4b36132d8c932de3d2819859e314ef1b7c | [
"MIT"
] | null | null | null | src/include/storage/write_ahead_log/log_io.h | tpan496/project3 | 82714c4b36132d8c932de3d2819859e314ef1b7c | [
"MIT"
] | null | null | null | src/include/storage/write_ahead_log/log_io.h | tpan496/project3 | 82714c4b36132d8c932de3d2819859e314ef1b7c | [
"MIT"
] | null | null | null | #pragma once
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <cerrno>
#include <cstring>
#include <string>
#include "common/constants.h"
#include "common/macros.h"
#include "loggers/storage_logger.h"
namespace terrier::storage {
/**
* Modernized wrappers around Posix I/O sys calls to hide away the ugliness and use exceptions for error reporting.
*/
struct PosixIoWrappers {
PosixIoWrappers() = delete; // Un-instantiable
// TODO(Tianyu): Use a better exception than runtime_error.
/**
* Wrapper around posix open call
* @tparam Args type of varlen arguments
* @param path posix path arg
* @param oflag posix oflag arg
* @param args posix mode arg
* @throws runtime_error if the underlying posix call failed
* @return a non-negative interger that is the file descriptor if the opened file.
*/
template <class... Args>
static int Open(const char *path, int oflag, Args... args) {
while (true) {
int ret = open(path, oflag, args...);
if (ret == -1) {
if (errno == EINTR) continue;
throw std::runtime_error("Failed to open file with errno " + std::to_string(errno));
}
return ret;
}
}
/**
* Wrapper around posix close call
* @param fd posix filedes arg
* @throws runtime_error if the underlying posix call failed
*/
static void Close(int fd);
/**
* Wrapper around the posix read call, where a single function call will always read the specified amount of bytes
* unless eof is read. (unlike posix read, which can read arbitrarily many bytes less than the given amount)
* @param fd posix fildes arg
* @param buf posix buf arg
* @param nbyte posix nbyte arg
* @throws runtime_error if the underlying posix call failed
* @return nbyte if the read is successful, or the number of bytes actually read if eof is read before nbytes are
* read. (i.e. there aren't enough bytes left in the file to read out nbyte many)
*/
static uint32_t ReadFully(int fd, void *buf, size_t nbyte);
/**
* Wrapper around the posix write call, where a single function call will always write the entire buffer out.
* (unlike posix write, which can write arbitrarily many bytes less than the given amount)
* @param fd posix fildes arg
* @param buf posix buf arg
* @param nbyte posix nbyte arg
* @throws runtime_error if the underlying posix call failed
*/
static void WriteFully(int fd, const void *buf, size_t nbyte);
};
// TODO(Tianyu): we need control over when and what to flush as the log manager. Thus, we need to write our
// own wrapper around lower level I/O functions. I could be wrong, and in that case we should
// revert to using STL.
/**
* Handles buffered writes to the write ahead log, and provides control over flushing.
*/
class BufferedLogWriter {
// TODO(Tianyu): Checksum
public:
/**
* Instantiates a new BufferedLogWriter to write to the specified log file.
*
* @param log_file_path path to the the log file to write to. New entries are appended to the end of the file if the
* file already exists; otherwise, a file is created.
*/
explicit BufferedLogWriter(const char *log_file_path)
: out_(PosixIoWrappers::Open(log_file_path, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR)) {}
/**
* Must call before object is destructed
*/
void Close() { PosixIoWrappers::Close(out_); }
/**
* Write to the log file the given amount of bytes from the given location in memory, but buffer the write so the
* update is only written out when the BufferedLogWriter is persisted. Note that this function writes to the buffer
* only until it is full. If buffer gets full, then call FlushBuffer() and call BufferWrite(..) again with the correct
* offset of the data, depending on the number of bytes that were already written.
* @param data memory location of the bytes to write
* @param size number of bytes to write
* @return number of bytes written. This function only writes until the buffer gets full, so this can be used as the
* offset when calling this function again after flushing.
*/
uint32_t BufferWrite(const void *data, uint32_t size) {
// If we still do not have buffer space after flush, the write is too large to be buffered. We partially write the
// buffer and return the number of bytes written
if (!CanBuffer(size)) {
size = common::Constants::LOG_BUFFER_SIZE - buffer_size_;
}
std::memcpy(buffer_ + buffer_size_, data, size);
buffer_size_ += size;
return size;
}
/**
* Call fsync to make sure that all writes are consistent.
*/
void Persist() {
if (fsync(out_) == -1) throw std::runtime_error("fsync failed with errno " + std::to_string(errno));
}
/**
* Flush any buffered writes.
* @return amount of data flushed
*/
uint64_t FlushBuffer() {
auto size = buffer_size_;
WriteUnsynced(buffer_, buffer_size_);
buffer_size_ = 0;
return size;
}
/**
* @return if the buffer is full
*/
bool IsBufferFull() { return buffer_size_ == common::Constants::LOG_BUFFER_SIZE; }
private:
friend class LogManager; // access the out_ file descriptor
int out_; // fd of the output files
char buffer_[common::Constants::LOG_BUFFER_SIZE];
uint32_t buffer_size_ = 0;
bool CanBuffer(uint32_t size) { return common::Constants::LOG_BUFFER_SIZE - buffer_size_ >= size; }
void WriteUnsynced(const void *data, uint32_t size) { PosixIoWrappers::WriteFully(out_, data, size); }
};
/**
* Buffered reads from the write ahead log
*/
class BufferedLogReader {
// TODO(Tianyu): Checksum
public:
/**
* Instantiates a new BufferedLogReader to read from the specified log file.
* @param log_file_path path to the the log file to read from.
*/
explicit BufferedLogReader(const char *log_file_path) : in_(PosixIoWrappers::Open(log_file_path, O_RDONLY)) {}
/**
* Closes log file if it has not been closed already. While Read will close the file if it reaches the end, this will
* handle cases where we destroy the reader before reading the whole file.
*/
~BufferedLogReader() {
if (in_ != -1) PosixIoWrappers::Close(in_);
}
/**
* @return if there are contents left in the write ahead log
*/
bool HasMore() { return filled_size_ > read_head_ || in_ != -1; }
/**
* Read the specified number of bytes into the target location from the write ahead log. The method reads as many as
* possible if there are not enough bytes in the log and returns false. The underlying log file fd is automatically
* closed when all remaining bytes are buffered.
*
* @param dest pointer location to read into
* @param size number of bytes to read
* @return whether the log has the given number of bytes left
*/
bool Read(void *dest, uint32_t size);
/**
* Read a value of the specified type from the log. An exception is thrown if the log file does not
* have enough bytes left for a well formed value
* @tparam T type of value to read
* @return the value read
*/
template <class T>
T ReadValue() {
T result;
bool ret UNUSED_ATTRIBUTE = Read(&result, sizeof(T));
TERRIER_ASSERT(ret, "Reading of value failed");
return result;
}
private:
friend class Checkpoint; // access read_head_
int in_; // or -1 if closed
uint32_t read_head_ = 0, filled_size_ = 0;
char buffer_[common::Constants::LOG_BUFFER_SIZE];
void ReadFromBuffer(void *dest, uint32_t size) {
TERRIER_ASSERT(read_head_ + size <= filled_size_, "Not enough bytes in buffer for the read");
std::memcpy(dest, buffer_ + read_head_, size);
read_head_ += size;
}
void RefillBuffer();
};
} // namespace terrier::storage
| 35.692661 | 120 | 0.696954 |
8346cdc580402fbfa96be78ffff2a611c8db7fbf | 161 | c | C | src/php-src/auto/_php3_info.c | cuhk-seclab/XSym | 6e4f0a3d8cc78e8f4e85045bac2e0eb80511c193 | [
"MIT"
] | 3 | 2021-10-11T11:21:03.000Z | 2021-11-24T03:49:19.000Z | src/php-src/auto/_php3_info.c | cuhk-seclab/XSym | 6e4f0a3d8cc78e8f4e85045bac2e0eb80511c193 | [
"MIT"
] | null | null | null | src/php-src/auto/_php3_info.c | cuhk-seclab/XSym | 6e4f0a3d8cc78e8f4e85045bac2e0eb80511c193 | [
"MIT"
] | null | null | null | #include "stdio.h"
#include "phli.h"
void _php3_info(void);
int main(int argc, char* argv[]) {
char *result_dir="/data/phli/results/_php3_info/";
_php3_info();
} | 23 | 50 | 0.708075 |
8347704f48ca9283fd5fef75aa4e17236b450e33 | 7,305 | c | C | app/src/main/cpp/gl-shared/samples/chapter06/sample_rendering_triangle.c | ohtakazuki/hello-gl2 | 1a34ce270f08f03a9311572ca31c62397fa868ba | [
"Apache-2.0"
] | null | null | null | app/src/main/cpp/gl-shared/samples/chapter06/sample_rendering_triangle.c | ohtakazuki/hello-gl2 | 1a34ce270f08f03a9311572ca31c62397fa868ba | [
"Apache-2.0"
] | null | null | null | app/src/main/cpp/gl-shared/samples/chapter06/sample_rendering_triangle.c | ohtakazuki/hello-gl2 | 1a34ce270f08f03a9311572ca31c62397fa868ba | [
"Apache-2.0"
] | null | null | null | #include <GLES2/gl2.h>
#include "../../support/support.h"
typedef struct {
// レンダリング用シェーダープログラム
GLuint shader_program;
// 頂点シェーダー
GLuint vert_shader;
// フラグメントシェーダー
GLuint frag_shader;
// 位置情報属性
GLint attr_pos;
} Extension_RenderingTriangle;
/**
* アプリの初期化を行う
*/
void sample_RenderingTriangle_initialize(GLApplication *app) {
// サンプルアプリ用のメモリを確保する
app->extension = (Extension_RenderingTriangle*) malloc(sizeof(Extension_RenderingTriangle));
// サンプルアプリ用データを取り出す
Extension_RenderingTriangle *extension = (Extension_RenderingTriangle*) app->extension;
// 頂点シェーダーを用意する
{
const GLchar *vertex_shader_source =
//
"attribute mediump vec4 attr_pos;"
"void main() {"
" gl_Position = attr_pos;"
"}";
// シェーダーオブジェクトを作成する
extension->vert_shader = glCreateShader(GL_VERTEX_SHADER);
assert(extension->vert_shader != 0);
assert(glGetError() == GL_NO_ERROR);
glShaderSource(extension->vert_shader, 1, &vertex_shader_source, NULL);
glCompileShader(extension->vert_shader);
// コンパイルエラーをチェックする
{
GLint compileSuccess = 0;
glGetShaderiv(extension->vert_shader, GL_COMPILE_STATUS, &compileSuccess);
if (compileSuccess == GL_FALSE) {
// エラーが発生した
GLint infoLen = 0;
// エラーメッセージを取得
glGetShaderiv(extension->vert_shader, GL_INFO_LOG_LENGTH, &infoLen);
if (infoLen > 1) {
GLchar *message = (GLchar*) calloc(infoLen, sizeof(GLchar));
glGetShaderInfoLog(extension->vert_shader, infoLen, NULL, message);
__log(message);
free((void*) message);
} else {
__log("comple error not info...");
}
}
assert(compileSuccess == GL_TRUE);
}
}
// フラグメントシェーダーを用意する
{
const GLchar *fragment_shader_source = "void main() {"
" gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);"
"}";
// シェーダーオブジェクトを作成する
extension->frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
assert(extension->frag_shader != 0);
glShaderSource(extension->frag_shader, 1, &fragment_shader_source, NULL);
glCompileShader(extension->frag_shader);
// コンパイルエラーをチェックする
{
GLint compileSuccess = 0;
glGetShaderiv(extension->frag_shader, GL_COMPILE_STATUS, &compileSuccess);
if (compileSuccess == GL_FALSE) {
// エラーが発生した
GLint infoLen = 0;
// エラーメッセージを取得
glGetShaderiv(extension->frag_shader, GL_INFO_LOG_LENGTH, &infoLen);
if (infoLen > 1) {
GLchar *message = (GLchar*) calloc(infoLen, sizeof(GLchar));
glGetShaderInfoLog(extension->frag_shader, infoLen, NULL, message);
__log(message);
free((void*) message);
} else {
__log("comple error not info...");
}
}
assert(compileSuccess == GL_TRUE);
}
}
// リンクを行う
{
extension->shader_program = glCreateProgram();
assert(extension->shader_program != 0);
glAttachShader(extension->shader_program, extension->vert_shader); // 頂点シェーダーとプログラムを関連付ける
assert(glGetError() == GL_NO_ERROR);
glAttachShader(extension->shader_program, extension->frag_shader); // フラグメントシェーダーとプログラムを関連付ける
assert(glGetError() == GL_NO_ERROR);
// リンク処理を行う
glLinkProgram(extension->shader_program);
// リンクエラーをチェックする
{
GLint linkSuccess = 0;
glGetProgramiv(extension->shader_program, GL_LINK_STATUS, &linkSuccess);
if (linkSuccess == GL_FALSE) {
// エラーが発生したため、状態をチェックする
GLint infoLen = 0;
// エラーメッセージを取得
glGetProgramiv(extension->shader_program, GL_INFO_LOG_LENGTH, &infoLen);
if (infoLen > 1) {
GLchar *message = (GLchar*) calloc(infoLen, sizeof(GLchar));
glGetProgramInfoLog(extension->shader_program, infoLen, NULL, message);
__log(message);
free((void*) message);
}
}
// GL_NO_ERRORであることを検証する
assert(linkSuccess == GL_TRUE);
}
}
// attributeを取り出す
{
extension->attr_pos = glGetAttribLocation(extension->shader_program, "attr_pos");
assert(extension->attr_pos >= 0);
}
// シェーダーの利用を開始する
glUseProgram(extension->shader_program);
assert(glGetError() == GL_NO_ERROR);
}
/**
* レンダリングエリアが変更された
*/
void sample_RenderingTriangle_resized(GLApplication *app) {
// 描画領域を設定する
glViewport(0, 0, app->surface_width, app->surface_height);
}
/**
* アプリのレンダリングを行う
* 毎秒60回前後呼び出される。
*/
void sample_RenderingTriangle_rendering(GLApplication *app) {
// サンプルアプリ用データを取り出す
Extension_RenderingTriangle *extension = (Extension_RenderingTriangle*) app->extension;
glClearColor(0.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// attr_posを有効にする
glEnableVertexAttribArray(extension->attr_pos);
// 画面中央へ描画する
const GLfloat position[] = {
// v0
0.0f, 1.0f,
// v1
1.0f, -1.0f,
// v2
-1.0f, -1.0f };
glVertexAttribPointer(extension->attr_pos, 2, GL_FLOAT, GL_FALSE, 0, (GLvoid*) position);
glDrawArrays(GL_TRIANGLES, 0, 3);
// バックバッファをフロントバッファへ転送する。プラットフォームごとに内部の実装が異なる。
ES20_postFrontBuffer(app);
}
/**
* アプリのデータ削除を行う
*/
void sample_RenderingTriangle_destroy(GLApplication *app) {
// サンプルアプリ用データを取り出す
Extension_RenderingTriangle *extension = (Extension_RenderingTriangle*) app->extension;
#if 1 // #if 0に書き換えることで、glUseProgramされるまで削除が遅延されることを確認できる
// シェーダーの利用を終了する
glUseProgram(0);
assert(glGetError() == GL_NO_ERROR);
// シェーダープログラムを廃棄する
glDeleteProgram(extension->shader_program);
assert(glGetError() == GL_NO_ERROR);
// extension->shader_programがプログラムオブジェクトで無いことを検証する
assert(glIsProgram(extension->shader_program) == GL_FALSE);
#else
// シェーダープログラムを廃棄する
glDeleteProgram(extension->shader_program);
assert(glGetError() == GL_NO_ERROR);
// extension->shader_programがまだプログラムオブジェクトであることを検証する
assert(glIsProgram(extension->shader_program) == GL_TRUE);
// 削除ステータスがGL_TRUEであることを検証する
GLint programDeleted = -1;
glGetProgramiv(extension->shader_program, GL_DELETE_STATUS, &programDeleted);
assert(programDeleted == GL_TRUE);
// extension->shader_programをアンバインドすることでシェーダープログラムが廃棄されたことを確認する
glUseProgram(0);
assert(glGetError() == GL_NO_ERROR);
assert(glIsProgram(extension->shader_program) == GL_FALSE);
#endif
// シェーダーオブジェクトを廃棄する
glDeleteShader(extension->vert_shader);
assert(glGetError() == GL_NO_ERROR);
// シェーダーオブジェクトを廃棄する
glDeleteShader(extension->frag_shader);
assert(glGetError() == GL_NO_ERROR);
// サンプルアプリ用のメモリを解放する
free(app->extension);
}
| 31.351931 | 101 | 0.607255 |
834773511d11a2b2e472bd6ebe6f02b6e76c236c | 1,848 | h | C | src/postgres/src/include/utils/sharedtuplestore.h | hstenzel/yugabyte-db | b25c8f4d7a9e66d106c41c446b71af870aefa304 | [
"Apache-2.0",
"CC0-1.0"
] | 3,702 | 2019-09-17T13:49:56.000Z | 2022-03-31T21:50:59.000Z | src/postgres/src/include/utils/sharedtuplestore.h | hstenzel/yugabyte-db | b25c8f4d7a9e66d106c41c446b71af870aefa304 | [
"Apache-2.0",
"CC0-1.0"
] | 9,291 | 2019-09-16T21:47:07.000Z | 2022-03-31T23:52:28.000Z | src/postgres/src/include/utils/sharedtuplestore.h | hstenzel/yugabyte-db | b25c8f4d7a9e66d106c41c446b71af870aefa304 | [
"Apache-2.0",
"CC0-1.0"
] | 673 | 2019-09-16T21:27:53.000Z | 2022-03-31T22:23:59.000Z | /*-------------------------------------------------------------------------
*
* sharedtuplestore.h
* Simple mechinism for sharing tuples between backends.
*
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/utils/sharedtuplestore.h
*
*-------------------------------------------------------------------------
*/
#ifndef SHAREDTUPLESTORE_H
#define SHAREDTUPLESTORE_H
#include "access/htup.h"
#include "storage/fd.h"
#include "storage/sharedfileset.h"
struct SharedTuplestore;
typedef struct SharedTuplestore SharedTuplestore;
struct SharedTuplestoreAccessor;
typedef struct SharedTuplestoreAccessor SharedTuplestoreAccessor;
/*
* A flag indicating that the tuplestore will only be scanned once, so backing
* files can be unlinked early.
*/
#define SHARED_TUPLESTORE_SINGLE_PASS 0x01
extern size_t sts_estimate(int participants);
extern SharedTuplestoreAccessor *sts_initialize(SharedTuplestore *sts,
int participants,
int my_participant_number,
size_t meta_data_size,
int flags,
SharedFileSet *fileset,
const char *name);
extern SharedTuplestoreAccessor *sts_attach(SharedTuplestore *sts,
int my_participant_number,
SharedFileSet *fileset);
extern void sts_end_write(SharedTuplestoreAccessor *accessor);
extern void sts_reinitialize(SharedTuplestoreAccessor *accessor);
extern void sts_begin_parallel_scan(SharedTuplestoreAccessor *accessor);
extern void sts_end_parallel_scan(SharedTuplestoreAccessor *accessor);
extern void sts_puttuple(SharedTuplestoreAccessor *accessor,
void *meta_data,
MinimalTuple tuple);
extern MinimalTuple sts_parallel_scan_next(SharedTuplestoreAccessor *accessor,
void *meta_data);
#endif /* SHAREDTUPLESTORE_H */
| 29.806452 | 78 | 0.725108 |
8348e54ac6b42a910b1d51eb03c322805af25356 | 94 | c | C | drivers/src/glib/errno.c | Magneticraft-Team/Computer | 0e726056d035259f729e1e98d7f35fdb9bbb4c66 | [
"MIT"
] | null | null | null | drivers/src/glib/errno.c | Magneticraft-Team/Computer | 0e726056d035259f729e1e98d7f35fdb9bbb4c66 | [
"MIT"
] | null | null | null | drivers/src/glib/errno.c | Magneticraft-Team/Computer | 0e726056d035259f729e1e98d7f35fdb9bbb4c66 | [
"MIT"
] | null | null | null | //
// Created by cout970 on 2016-11-01.
//
#include "glib/errno.h"
int errno = E_NO_ERROR;
| 10.444444 | 36 | 0.648936 |
83490bd7f8ca5b27f3fbbb95c83e55645277fa83 | 213 | h | C | reef-env/amdgpu-dkms/amdgpu-4.3-52/include/kcl/header/drm/drm_device.h | SJTU-IPADS/reef-artifacts | 8750974f2d6655525a2cc317bf2471914fe68dab | [
"Apache-2.0"
] | 7 | 2022-03-23T07:04:20.000Z | 2022-03-30T02:44:42.000Z | reef-env/amdgpu-dkms/amdgpu-4.3-52/include/kcl/header/drm/drm_device.h | SJTU-IPADS/reef-artifacts | 8750974f2d6655525a2cc317bf2471914fe68dab | [
"Apache-2.0"
] | null | null | null | reef-env/amdgpu-dkms/amdgpu-4.3-52/include/kcl/header/drm/drm_device.h | SJTU-IPADS/reef-artifacts | 8750974f2d6655525a2cc317bf2471914fe68dab | [
"Apache-2.0"
] | null | null | null | /* SPDX-License-Identifier: MIT */
#ifndef _KCL_HEADER_DRM_DEVICE_H_H_
#define _KCL_HEADER_DRM_DEVICE_H_H_
#ifdef HAVE_DRM_DRM_DEVICE_H
#include_next <drm/drm_device.h>
#else
#include <drm/drmP.h>
#endif
#endif
| 17.75 | 35 | 0.802817 |
834923ea5c1ec78e09a6d52feb0d68a2e7fc30cc | 1,130 | h | C | SoA/MTRenderStateManager.h | Revan1985/SoACode-Public | c3ddd69355b534d5e70e2e6d0c489b4e93ab1ffe | [
"MIT"
] | 267 | 2018-06-03T23:05:05.000Z | 2022-03-17T00:28:40.000Z | SoA/MTRenderStateManager.h | davidkestering/SoACode-Public | c3ddd69355b534d5e70e2e6d0c489b4e93ab1ffe | [
"MIT"
] | 16 | 2018-06-05T18:59:11.000Z | 2021-09-28T05:05:16.000Z | SoA/MTRenderStateManager.h | davidkestering/SoACode-Public | c3ddd69355b534d5e70e2e6d0c489b4e93ab1ffe | [
"MIT"
] | 113 | 2018-06-03T23:56:13.000Z | 2022-03-21T00:07:16.000Z | ///
/// MTRenderStateManager.h
/// Seed of Andromeda
///
/// Created by Benjamin Arnold on 22 Feb 2015
/// Copyright 2014 Regrowth Studios
/// MIT License
///
/// Summary:
/// Manages the updating and access of triple buffered
/// render state on the render and update threads
///
#pragma once
#ifndef MTRenderStateManager_h__
#define MTRenderStateManager_h__
#include "MTRenderState.h"
#include <mutex>
class MTRenderStateManager {
public:
/// Gets the state for updating. Only call once per frame.
MTRenderState* getRenderStateForUpdate();
/// Marks state as finished updating. Only call once per frame,
/// must call for every call to getRenderStateForUpdate.
void finishUpdating();
/// Gets the state for rendering. Only call once per frame.
const MTRenderState* getRenderStateForRender();
private:
int m_updating = 0; ///< Currently updating state
int m_lastUpdated = 0; ///< Most recently updated state
int m_rendering = 0; ///< Currently rendering state
MTRenderState m_renderState[3]; ///< Triple-buffered state
std::mutex m_lock;
};
#endif // MTRenderStateManager_h__
| 28.25 | 67 | 0.722124 |
834fa598c66743718afe5a118bd8577542b49641 | 4,930 | c | C | pango/ext/pango/rbpangolayoutiter.c | cosmo0920/ruby-gnome2 | 88d17c64237c35d7cb38bf77fc290828b9269778 | [
"Ruby"
] | null | null | null | pango/ext/pango/rbpangolayoutiter.c | cosmo0920/ruby-gnome2 | 88d17c64237c35d7cb38bf77fc290828b9269778 | [
"Ruby"
] | null | null | null | pango/ext/pango/rbpangolayoutiter.c | cosmo0920/ruby-gnome2 | 88d17c64237c35d7cb38bf77fc290828b9269778 | [
"Ruby"
] | null | null | null | /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2011 Ruby-GNOME2 Project Team
* Copyright (C) 2002-2005 Masao Mutoh
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#include "rbpangoprivate.h"
#define RG_TARGET_NAMESPACE cLayoutIter
#define _SELF(r) (RVAL2PANGOLAYOUTITER(r))
/**********************************/
#ifndef HAVE_PANGO_LAYOUT_ITER_GET_TYPE
static PangoLayoutIter *
layout_iter_copy(const PangoLayoutIter *ref)
{
return (PangoLayoutIter *)ref;
}
GType
pango_layout_iter_get_type(void)
{
static GType our_type = 0;
if (our_type == 0)
our_type = g_boxed_type_register_static ("PangoLayoutIter",
(GBoxedCopyFunc)layout_iter_copy,
(GBoxedFreeFunc)pango_layout_iter_free);
return our_type;
}
#endif
/**********************************/
static VALUE
rg_next_run_bang(VALUE self)
{
return CBOOL2RVAL(pango_layout_iter_next_run(_SELF(self)));
}
static VALUE
rg_next_char_bang(VALUE self)
{
return CBOOL2RVAL(pango_layout_iter_next_char(_SELF(self)));
}
static VALUE
rg_next_cluster_bang(VALUE self)
{
return CBOOL2RVAL(pango_layout_iter_next_cluster(_SELF(self)));
}
static VALUE
rg_next_line_bang(VALUE self)
{
return CBOOL2RVAL(pango_layout_iter_next_line(_SELF(self)));
}
static VALUE
rg_at_last_line_p(VALUE self)
{
return CBOOL2RVAL(pango_layout_iter_at_last_line(_SELF(self)));
}
static VALUE
rg_index(VALUE self)
{
return INT2NUM(pango_layout_iter_get_index(_SELF(self)));
}
static VALUE
rg_baseline(VALUE self)
{
return INT2NUM(pango_layout_iter_get_baseline(_SELF(self)));
}
static VALUE
rg_run(VALUE self)
{
PangoLayoutRun* run = pango_layout_iter_get_run(_SELF(self));
return PANGOGLYPHITEM2RVAL(run);
}
static VALUE
rg_line(VALUE self)
{
return PANGOLAYOUTLINE2RVAL(pango_layout_iter_get_line(_SELF(self)));
}
static VALUE
rg_char_extents(VALUE self)
{
PangoRectangle logical_rect;
pango_layout_iter_get_char_extents(_SELF(self), &logical_rect);
return PANGORECTANGLE2RVAL(&logical_rect);
}
static VALUE
rg_cluster_extents(VALUE self)
{
PangoRectangle ink_rect, logical_rect;
pango_layout_iter_get_cluster_extents(_SELF(self), &ink_rect, &logical_rect);
return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect),
PANGORECTANGLE2RVAL(&logical_rect));
}
static VALUE
rg_run_extents(VALUE self)
{
PangoRectangle ink_rect, logical_rect;
pango_layout_iter_get_run_extents(_SELF(self), &ink_rect, &logical_rect);
return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect),
PANGORECTANGLE2RVAL(&logical_rect));
}
static VALUE
rg_line_yrange(VALUE self)
{
int y0, y1;
pango_layout_iter_get_line_yrange(_SELF(self), &y0, &y1);
return rb_assoc_new(INT2NUM(y0), INT2NUM(y1));
}
static VALUE
rg_line_extents(VALUE self)
{
PangoRectangle ink_rect, logical_rect;
pango_layout_iter_get_line_extents(_SELF(self), &ink_rect, &logical_rect);
return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect),
PANGORECTANGLE2RVAL(&logical_rect));
}
static VALUE
rg_layout_extents(VALUE self)
{
PangoRectangle ink_rect, logical_rect;
pango_layout_iter_get_layout_extents(_SELF(self), &ink_rect, &logical_rect);
return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect),
PANGORECTANGLE2RVAL(&logical_rect));
}
void
Init_pango_layout_iter(VALUE mPango)
{
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LAYOUT_ITER, "LayoutIter", mPango);
rbgobj_boxed_not_copy_obj(PANGO_TYPE_LAYOUT_ITER);
RG_DEF_METHOD_BANG(next_run, 0);
RG_DEF_METHOD_BANG(next_char, 0);
RG_DEF_METHOD_BANG(next_cluster, 0);
RG_DEF_METHOD_BANG(next_line, 0);
RG_DEF_METHOD_P(at_last_line, 0);
/* for backword compatibility. :< */
RG_DEF_ALIAS("at_last_line!", "at_last_line?");
RG_DEF_METHOD(index, 0);
RG_DEF_METHOD(baseline, 0);
RG_DEF_METHOD(run, 0);
RG_DEF_METHOD(line, 0);
RG_DEF_METHOD(char_extents, 0);
RG_DEF_METHOD(cluster_extents, 0);
RG_DEF_METHOD(run_extents, 0);
RG_DEF_METHOD(line_yrange, 0);
RG_DEF_METHOD(line_extents, 0);
RG_DEF_METHOD(layout_extents, 0);
}
| 25.947368 | 90 | 0.727181 |
83501958920f75f0b7e4ee6709a39092551d6ef8 | 1,764 | h | C | sdk-6.5.20/libs/sdklt/bcmltx/include/bcmltx/bcml2/bcmltx_l2_eif_dest.h | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmltx/include/bcmltx/bcml2/bcmltx_l2_eif_dest.h | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmltx/include/bcmltx/bcml2/bcmltx_l2_eif_dest.h | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*! \file bcmltx_l2_eif_dest.h
*
* L2_EIF_SYSTEM_DESTINATION.IS_TRUNK/SYSTEM_PORT/TRUNK_ID Transform Handler
*
* This file contains field transform information for
* L2_EIF_SYSTEM_DESTINATION.IS_TRUNK/SYSTEM_PORT/TRUNK_ID.
*/
/*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
#ifndef BCMLTX_L2_EIF_DEST_H
#define BCMLTX_L2_EIF_DEST_H
#include <bcmltd/bcmltd_handler.h>
/*!
* \brief L2_EIF_SYSTEM_DESTINATION.IS_TRUNK/SYSTEM_PORT/TRUNK_ID transform.
*
* \param [in] unit Unit Number.
* \param [in] in Input field values.
* \param [out] out Output field values.
* \param [in] arg Transform arguments.
*
* \retval SHR_E_NONE No errors.
* \retval !SHR_E_NONE Failure.
*/
extern int
bcmltx_l2_eif_dest_transform(int unit,
const bcmltd_fields_t *in,
bcmltd_fields_t *out,
const bcmltd_transform_arg_t *arg);
/*!
* \brief L2_EIF_SYSTEM_DESTINATION.IS_TRUNK/SYSTEM_PORT/TRUNK_ID rev transform.
*
* \param [in] unit Unit Number.
* \param [in] in Input field values.
* \param [out] out Output field values.
* \param [in] arg Transform arguments.
*
* \retval SHR_E_NONE No errors.
* \retval !SHR_E_NONE Failure.
*/
extern int
bcmltx_l2_eif_dest_rev_transform(int unit,
const bcmltd_fields_t *in,
bcmltd_fields_t *out,
const bcmltd_transform_arg_t *arg);
#endif /* BCMLTX_L2_EIF_DEST_H */
| 32.666667 | 134 | 0.630385 |
83507169d185449d18cb2555b3d464f6e959a11c | 4,196 | h | C | Projects/Editor/Source/Editor/SpaceController/CSceneController.h | niansa/skylicht-engine | ea3010aea3402bd050b62c3fd7effa16b33e96f5 | [
"MIT"
] | 310 | 2019-11-25T04:14:11.000Z | 2022-03-31T23:39:19.000Z | Projects/Editor/Source/Editor/SpaceController/CSceneController.h | niansa/skylicht-engine | ea3010aea3402bd050b62c3fd7effa16b33e96f5 | [
"MIT"
] | 79 | 2019-11-17T07:51:02.000Z | 2022-03-22T08:49:41.000Z | Projects/Editor/Source/Editor/SpaceController/CSceneController.h | niansa/skylicht-engine | ea3010aea3402bd050b62c3fd7effa16b33e96f5 | [
"MIT"
] | 24 | 2020-05-10T09:37:55.000Z | 2022-03-05T13:19:31.000Z | /*
!@
MIT License
Copyright (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/
#pragma once
#include "Utils/CGameSingleton.h"
#include "Scene/CScene.h"
#include "Editor/Space/Scene/CSpaceScene.h"
#include "Editor/Space/Hierarchy/CSpaceHierarchy.h"
#include "Editor/Space/Hierarchy/CHierachyNode.h"
#include "Editor/Gizmos/CGizmos.h"
#include "EditorComponents/SelectObject/CSelectObjectSystem.h"
#include "CContextMenuScene.h"
#include "Reactive/CObserver.h"
#include "Reactive/CSubject.h"
namespace Skylicht
{
namespace Editor
{
class CSceneController :
public CGameSingleton<CSceneController>,
public IObserver,
public IFileLoader
{
protected:
CSpaceScene* m_spaceScene;
CSpaceHierarchy* m_spaceHierarchy;
CHierachyNode* m_hierachyNode;
CHierachyNode* m_contextNode;
CHierachyNode* m_focusNode;
CScene* m_scene;
CZone* m_zone;
CSceneHistory* m_history;
GUI::CCanvas* m_canvas;
CContextMenuScene* m_contextMenuScene;
std::vector<CGizmos*> m_gizmos;
std::string m_scenePath;
bool m_modify;
public:
CSceneController();
virtual ~CSceneController();
void update();
void refresh();
void addGizmos(CGizmos* gizmos);
void removeGizmos(CGizmos* gizmos);
void initContextMenu(GUI::CCanvas* canvas);
void setSpaceScene(CSpaceScene* scene);
inline CSpaceScene* getSpaceScene()
{
return m_spaceScene;
}
CSelectObjectSystem* getSelectObjectSystem()
{
return m_spaceScene->getSelectObjectSystem();
}
void setSpaceHierarchy(CSpaceHierarchy* hierarchy);
inline CSpaceHierarchy* getSpaceHierarchy()
{
return m_spaceHierarchy;
}
inline void modify()
{
m_modify = true;
}
bool needSave();
void save(const char* path);
virtual void loadFile(const std::string& path);
void doLoadScene(const std::string& path);
void doFinishLoadScene();
const std::string& getScenePath()
{
return m_scenePath;
}
void setScene(CScene* scene);
inline CScene* getScene()
{
return m_scene;
}
void setZone(CZone* zone);
CZone* getZone()
{
return m_zone;
}
CSceneHistory* getHistory()
{
return m_history;
}
void buildHierarchyNodes();
void onCommand(const std::wstring& objectType);
void onContextMenu(CHierachyNode* node);
void onUpdateNode(CHierachyNode* node);
void onSelectNode(CHierachyNode* node, bool selected);
void onObjectChange(CGameObject* object);
virtual void onNotify(ISubject* subject, IObserver* from);
void deselectAllOnHierachy();
void selectOnHierachy(CGameObject* gameObject);
inline CHierachyNode* getContextNode()
{
return m_contextNode;
}
inline void clearContextNode()
{
m_contextNode = NULL;
}
void createZone();
void createEmptyObject(CContainerObject* parent);
void createContainerObject(CContainerObject* parent);
protected:
CHierachyNode* buildHierarchyNodes(CGameObject* object, CHierachyNode* parentNode);
void setNodeEvent(CHierachyNode* node);
};
}
} | 21.740933 | 141 | 0.734032 |
83511e7971020f8e4ed7dfe408e2e72d294abfab | 5,910 | c | C | src/objects/score_matrix.c | TravisWheelerLab/MMOREseqs | 492eda6efa4fd95ac0a787405a40db5a860bf3dc | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | null | null | null | src/objects/score_matrix.c | TravisWheelerLab/MMOREseqs | 492eda6efa4fd95ac0a787405a40db5a860bf3dc | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | null | null | null | src/objects/score_matrix.c | TravisWheelerLab/MMOREseqs | 492eda6efa4fd95ac0a787405a40db5a860bf3dc | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | null | null | null | /*******************************************************************************
* - FILE: submat.c
* - DESC: SCORE_MATRIX Object.
* Substitution Matrix for BLOSUM62, etc.
*******************************************************************************/
/* imports */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
/* local imports */
#include "structs.h"
#include "../utilities/_utilities.h"
#include "_objects.h"
/* header */
#include "score_matrix.h"
/* Constructor */
SCORE_MATRIX* SCORE_MATRIX_Create() {
SCORE_MATRIX* submat;
submat = ERROR_malloc(sizeof(SCORE_MATRIX));
submat->filename = NULL;
submat->alph = NULL;
submat->scores = NULL;
SCORE_MATRIX_SetAlphabet(submat, ALPH_AMINO_CHARS);
return submat;
}
/* Destructor */
void SCORE_MATRIX_Destroy(SCORE_MATRIX* submat) {
ERROR_free(submat->filename);
ERROR_free(submat->alph);
ERROR_free(submat->scores);
ERROR_free(submat);
}
/* Parse .submat file and build SCORE_MATRIX object */
SCORE_MATRIX* SCORE_MATRIX_Load(char* filename) {
SCORE_MATRIX* submat;
submat = SCORE_MATRIX_Create();
submat->filename = STR_Create(filename);
/* line reader objects */
char* line_buf = NULL;
size_t line_buf_size = 0;
int line_count = 0;
ssize_t line_size = 0;
char* token = NULL;
/* line parser objects */
bool hasHeader = false;
char* header = STR_Create(ALPH_AMINO_CHARS);
char delim[] = " \t\n";
char* parser = NULL;
int x = 0; /* index of row in matrix */
int y = 0; /* index of column in matrix */
char a = 0; /* char at row index */
char b = 0; /* char at column index */
float score = 0; /* match score */
/* open file */
FILE* fp;
fp = fopen(filename, "r");
if (fp == NULL) {
fprintf(stderr, "Error while opening file: %s\n", filename);
ERRORCHECK_exit(EXIT_FAILURE);
}
/* read a line */
while ((line_size = getline(&line_buf, &line_buf_size, fp)), line_size != -1) {
/* get first non-whitespace word */
parser = strtok(line_buf, delim);
/* if comment or blank line, skip */
if (parser == NULL || parser[0] == '#') {
continue;
}
/* header leads with a > character */
if (parser[0] == '>' && !hasHeader) {
header = (char*)realloc(header, sizeof(char) * 256);
int i = 0;
/* parse header elements */
while ((parser = strtok(NULL, delim)), parser != NULL) {
header[i] = parser[0];
i++;
}
header[i] = '\0';
hasHeader = true;
SCORE_MATRIX_SetAlphabet(submat, header);
continue;
}
/* if line begins with letter from alphabet, we are on a data row */
if (strchr(header, parser[0]) != NULL) {
/* first element on line is member of alphabet */
b = parser[0];
/* tab-delimited scores */
x = 0;
while ((parser = strtok(NULL, delim)), parser != NULL) {
/* get next query character */
a = header[x];
score = atof(parser);
// map protein pair to int (both directions)
*(SCORE_MATRIX_Score(submat, a, b)) = score;
*(SCORE_MATRIX_Score(submat, b, a)) = score;
x++;
}
y++;
continue;
}
}
fclose(fp);
ERROR_free(header);
ERROR_free(line_buf);
return submat;
}
/* Set alphabet and the initialize score matrix based on size */
void SCORE_MATRIX_SetAlphabet(SCORE_MATRIX* submat,
char* alph) {
int alph_len = strlen(alph);
submat->alph = NULL;
submat->alph = STR_Create(alph);
submat->alph_len = alph_len;
/* initialize map */
for (int i = 0; i < 256; i++) {
submat->map[i] = -1;
}
/* create map from char -> index */
for (int i = 0; i < strlen(alph); i++) {
submat->map[alph[i]] = i;
}
submat->scores = (float*)realloc(submat->scores, sizeof(float) * alph_len * alph_len);
if (submat == NULL) {
perror("Error while malloc'ing SCORES in SCORE_MATRIX.\n");
ERRORCHECK_exit(EXIT_FAILURE);
}
}
/* Maps 2D-coords to 1D-coords in SUBSTITUTION MATRIX */
int SCORE_MATRIX_Keymap(SCORE_MATRIX* submat,
char q_ch,
char t_ch) {
int X = submat->map[q_ch];
int Y = submat->map[t_ch];
return ((X * submat->alph_len) + Y);
}
/* Get score from SCORE_MATRIX, given query/target chars. Returns reference. */
inline float* SCORE_MATRIX_Score(SCORE_MATRIX* submat,
char q_ch,
char t_ch) {
int key = SCORE_MATRIX_Keymap(submat, q_ch, t_ch);
return &(submat->scores[key]);
}
/* Get score from SCORE_MATRIX, given query/target chars */
inline float SCORE_MATRIX_GetScore(SCORE_MATRIX* submat,
char q_ch,
char t_ch) {
int key = SCORE_MATRIX_Keymap(submat, q_ch, t_ch);
return submat->scores[key];
}
/* Output SCORE_MATRIX to FILE pointer */
void SCORE_MATRIX_Dump(SCORE_MATRIX* submat,
FILE* fp) {
fprintf(fp, "# ====== SCORE_MATRIX ======\n");
fprintf(fp, "# FILE:\t%s\n", submat->filename);
fprintf(fp, "# ALPH:\t%s\n", submat->alph);
char q_ch = 0;
char t_ch = 0;
float score = 0.0;
int i = 0;
int j = 0;
char* alph = submat->alph;
int alph_len = submat->alph_len;
/* print header */
fprintf(fp, ">\t");
for (i = 0; i < alph_len; i++) {
fprintf(fp, "%c\t", alph[i]);
}
fprintf(fp, "\n");
/* print each row */
for (i = 0; i < alph_len; i++) {
fprintf(fp, "%c\t", alph[i]);
for (j = 0; j < alph_len; j++) {
score = *(SCORE_MATRIX_Score(submat, alph[i], alph[j]));
fprintf(fp, "%f\t", score);
}
fprintf(fp, "\n");
}
fprintf(fp, "# ============================\n");
}
/* for now, just create generic amino alphabet */
ALPHABET* ALPHABET_Create(ALPHABET alph_type) {
}
| 26.266667 | 88 | 0.568697 |
83543e7129cb2a594df7e3eb45e0c6290056bd61 | 6,109 | h | C | src/pygcransac/include/types.h | YiqunPan/graph-cut-ransac | 71e03f462435e12ff52be2cd44cc807e0e5fffa4 | [
"MIT"
] | 1 | 2019-11-02T08:38:28.000Z | 2019-11-02T08:38:28.000Z | src/pygcransac/include/types.h | YiqunPan/graph-cut-ransac | 71e03f462435e12ff52be2cd44cc807e0e5fffa4 | [
"MIT"
] | null | null | null | src/pygcransac/include/types.h | YiqunPan/graph-cut-ransac | 71e03f462435e12ff52be2cd44cc807e0e5fffa4 | [
"MIT"
] | null | null | null | // Copyright (C) 2019 Czech Technical University.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * 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.
//
// * Neither the name of Czech Technical University nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDERS OR CONTRIBUTORS 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.
//
// Please contact the author of this library if you have any questions.
// Author: Daniel Barath (barath.daniel@sztaki.mta.hu)
#pragma once
#include <vector>
#include <numeric>
#include "fundamental_estimator.h"
#include "homography_estimator.h"
#include "essential_estimator.h"
#include "perspective_n_point_estimator.h"
#include "solver_fundamental_matrix_seven_point.h"
#include "solver_fundamental_matrix_eight_point.h"
#include "solver_p3p.h"
#include "solver_dls_pnp.h"
#include "solver_homography_four_point.h"
#include "solver_essential_matrix_five_point_stewenius.h"
namespace gcransac
{
namespace utils
{
// The default estimator for fundamental matrix fitting
typedef estimator::FundamentalMatrixEstimator<estimator::solver::FundamentalMatrixSevenPointSolver, // The solver used for fitting a model to a minimal sample
estimator::solver::FundamentalMatrixEightPointSolver> // The solver used for fitting a model to a non-minimal sample
DefaultFundamentalMatrixEstimator;
// The default estimator for homography fitting
typedef estimator::RobustHomographyEstimator<estimator::solver::HomographyFourPointSolver, // The solver used for fitting a model to a minimal sample
estimator::solver::HomographyFourPointSolver> // The solver used for fitting a model to a non-minimal sample
DefaultHomographyEstimator;
// The default estimator for essential matrix fitting
typedef estimator::EssentialMatrixEstimator<estimator::solver::EssentialMatrixFivePointSteweniusSolver, // The solver used for fitting a model to a minimal sample
estimator::solver::EssentialMatrixFivePointSteweniusSolver> // The solver used for fitting a model to a non-minimal sample
DefaultEssentialMatrixEstimator;
// The default estimator for PnP fitting
typedef estimator::PerspectiveNPointEstimator<estimator::solver::P3PSolver, // The solver used for fitting a model to a minimal sample
estimator::solver::DLSPnP> // The solver used for fitting a model to a non-minimal sample
DefaultPnPEstimator;
struct Settings {
bool do_final_iterated_least_squares, // Flag to decide a final iterated least-squares fitting is needed to polish the output model parameters.
do_local_optimization, // Flag to decide if local optimization is needed
do_graph_cut, // Flag to decide of graph-cut is used in the local optimization
use_inlier_limit; // Flag to decide if an inlier limit is used in the local optimization to speed up the procedure
size_t desired_fps; // The desired FPS
size_t max_local_optimization_number, // Maximum number of local optimizations
min_iteration_number_before_lo, // Minimum number of RANSAC iterations before applying local optimization
min_iteration_number, // Minimum number of RANSAC iterations
max_iteration_number, // Maximum number of RANSAC iterations
max_unsuccessful_model_generations, // Maximum number of unsuccessful model generations
max_least_squares_iterations, // Maximum number of iterated least-squares iterations
max_graph_cut_number, // Maximum number of graph-cuts applied in each iteration
core_number; // Number of parallel threads
double confidence, // Required confidence in the result
neighborhood_sphere_radius, // The radius of the ball used for creating the neighborhood graph
threshold, // The inlier-outlier threshold
spatial_coherence_weight; // The weight of the spatial coherence term
Settings() :
do_final_iterated_least_squares(true),
do_local_optimization(true),
do_graph_cut(true),
use_inlier_limit(false),
desired_fps(-1),
max_local_optimization_number(10),
max_graph_cut_number(10),
max_least_squares_iterations(10),
min_iteration_number_before_lo(20),
min_iteration_number(20),
neighborhood_sphere_radius(20),
max_iteration_number(std::numeric_limits<size_t>::max()),
max_unsuccessful_model_generations(100),
core_number(1),
spatial_coherence_weight(0.14),
threshold(2.0),
confidence(0.95)
{
}
};
struct RANSACStatistics
{
size_t graph_cut_number,
local_optimization_number,
iteration_number,
neighbor_number;
std::string main_sampler_name,
local_optimizer_sampler_name;
double processing_time;
std::vector<size_t> inliers;
RANSACStatistics() :
graph_cut_number(0),
local_optimization_number(0),
iteration_number(0),
neighbor_number(0),
processing_time(0.0)
{
}
};
}
} | 42.131034 | 164 | 0.77083 |
83543f58880d5ea92f0fcf1f8715baa84dbf8b93 | 1,057 | c | C | pacman/src/pacman_shut_left.c | GhostToast/lightwall | 56caad653fb27acbb85b89d22771a39db71fddfe | [
"MIT"
] | 2 | 2018-07-26T14:41:22.000Z | 2019-01-14T17:33:12.000Z | pacman/src/pacman_shut_left.c | GhostToast/lightwall | 56caad653fb27acbb85b89d22771a39db71fddfe | [
"MIT"
] | null | null | null | pacman/src/pacman_shut_left.c | GhostToast/lightwall | 56caad653fb27acbb85b89d22771a39db71fddfe | [
"MIT"
] | null | null | null | // Generated by : ImageConverter 565 Online
// Generated from : pacman_shut_left.png
// Time generated : Sun, 22 Apr 18 18:15:39 +0200 (Server timezone: CET)
// Image Size : 8x9 pixels
// Memory usage : 144 bytes
#if defined(__AVR__)
#include <avr/pgmspace.h>
#elif defined(__PIC32MX__)
#define PROGMEM
#elif defined(__arm__)
#define PROGMEM
#endif
const unsigned short pacman_shut_left[72] PROGMEM={
0x0000, 0x5280, 0xA500, 0xBDE0, 0x9CE0, 0x39E0, 0x0000, 0x0000, 0x6B40, 0xF780, 0xF780, 0xF780, 0xF780, 0xF780, 0x7BE0, 0x0000, // 0x0010 (16) pixels
0x2940, 0xE700, 0xE700, 0x0000, 0xEF60, 0xF780, 0xF780, 0x4220, 0xE700, 0xEF40, 0xEF40, 0xEF40, 0xEF20, 0xF780, 0xF780, 0xA520, // 0x0020 (32) pixels
0x94A0, 0x8C20, 0x8C40, 0x9CA0, 0xA500, 0xF780, 0xF780, 0xBDE0, 0xE700, 0xEF40, 0xE720, 0xEF40, 0xF780, 0xF780, 0xF780, 0x9CC0, // 0x0030 (48) pixels
0x4220, 0xE700, 0xF760, 0xF780, 0xF780, 0xF780, 0xEF60, 0x3180, 0x2120, 0xEF40, 0xF780, 0xF780, 0xF780, 0xEF40, 0x5AC0, 0x0000, // 0x0040 (64) pixels
};
| 48.045455 | 152 | 0.701987 |
8355ddc850e8711b236ee625354d33c0e3171ace | 263 | c | C | src/test/kc/array-length-symbolic-min.c | jbrandwood/kickc | d4b68806f84f8650d51b0e3ef254e40f38b0ffad | [
"MIT"
] | 2 | 2022-03-01T02:21:14.000Z | 2022-03-01T04:33:35.000Z | src/test/kc/array-length-symbolic-min.c | jbrandwood/kickc | d4b68806f84f8650d51b0e3ef254e40f38b0ffad | [
"MIT"
] | null | null | null | src/test/kc/array-length-symbolic-min.c | jbrandwood/kickc | d4b68806f84f8650d51b0e3ef254e40f38b0ffad | [
"MIT"
] | null | null | null | // Illustrates symbolic array lengths
const byte SZ = 15;
byte items[SZ];
// Fills the array item by item with $is, where i is the item# and s is the sub#
void main() {
byte* cur_item = items;
for( byte sub: 0..SZ) {
cur_item[sub] = sub;
}
} | 21.916667 | 80 | 0.619772 |
8356d42bd82518188d559b03b07f8a580c3d5f53 | 10,615 | c | C | main.c | Waistax/ME331EmbeddedSoftware | 703718274c50d96fda84b9f51dc547b9eba6c6c3 | [
"MIT"
] | 1 | 2021-02-10T19:10:59.000Z | 2021-02-10T19:10:59.000Z | main.c | Waistax/ME331EmbeddedSoftware | 703718274c50d96fda84b9f51dc547b9eba6c6c3 | [
"MIT"
] | null | null | null | main.c | Waistax/ME331EmbeddedSoftware | 703718274c50d96fda84b9f51dc547b9eba6c6c3 | [
"MIT"
] | null | null | null | /*
* ME331 FALL2020 Term Project Group 7
* Author: Cem
* Version: 1.47
*
* Created on 28.1.2021, 21:44
*/
//#define READING
#define LOGGING
#define MOVEMENT
#define SERIAL
// Serial
#ifdef SERIAL
#define PRINT(X) Serial.print(X)
#define PRINTLN(X) Serial.println(X)
#else
#define PRINT(X)
#define PRINTLN(X)
#endif
// L I B R A R I E S
// ~~~~~~~~~~~~~~~~~
// For SD Card
#include <SPI.h>
#include <SD.h>
// For Gyro
#include <Wire.h>
#include <MPU6050.h>
// C O N S T A N T S
// ~~~~~~~~~~~~~~~~~
// Physical
#define DISPLACEMENT_PER_SECOND 0.00019
#define DELAY_AFTER_SETUP 10
// Serial
#define ANALOG_TO_CELSIUS 500.0/1023.0
#define ANGLE_THRESHOLD 0.01
#define FORWARD_ANGLE_THRESHOLD 0.1
// Logical
#define STATE_VERTICAL 0
#define STATE_HORIZONTAL 1
#define STATE_ANGULAR 2
#define STATE_ERROR 3
#define STATE_DONE 4
// Electronical
// Left Wheel
#define PIN_DRIVER_AIN1 7
#define PIN_DRIVER_AIN2 6
#define PIN_DRIVER_APWM 5
// Right Wheel
#define PIN_DRIVER_BIN1 2
#define PIN_DRIVER_BIN2 4
#define PIN_DRIVER_BPWM 3
// Temperature Sensor
#define PIN_TEMPERATURE_SENSOR A0
// Information LEDs
#define PIN_GREEN_LED 8
#define PIN_RED_LED 9
// F I E L D S
// ~~~~~~~~~~~
// Set by the user.
float rowLength;
float stepSize;
float rowWidth;
int rowCount;
// State of the robot.
int row;
int dataPoint;
float position;
float speed;
float aimedYaw;
float angle;
unsigned char turnsCCW;
unsigned char blink;
unsigned char state;
unsigned char aimedState;
unsigned long elapsedTime;
// SD card
File currentFile;
// Gyro
MPU6050 mpu;
float yaw;
// E L E C T R O N I C S I M P L E M E N T A T I O N
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/** Outputs the signal to the driver that is connected to the given pins.
* The turn is counter-clockwise if the signal is negative. */
void driver(int signal, char in1, char in2, char pwm) {
#ifdef MOVEMENT
// If the signal is negative turns counter-clockwise.
if (signal < 0) {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(pwm, -signal);
} else {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(pwm, signal);
}
#endif
}
/** Signals the wheels to rotate with the given intensity.
* If the signals are negative they turn backwards. */
void wheels(int left, int right) {
// For the left wheels backwards is clockwise.
driver(-left, PIN_DRIVER_AIN1, PIN_DRIVER_AIN2, PIN_DRIVER_APWM);
// For the right wheels backwards is counter-clockwise.
driver(right, PIN_DRIVER_BIN1, PIN_DRIVER_BIN2, PIN_DRIVER_BPWM);
}
/** Returns the current temperature reading. */
float temperature() {
#ifdef LOGGING
return analogRead(PIN_TEMPERATURE_SENSOR) * ANALOG_TO_CELSIUS;
#else
return 0.0;
#endif
}
/** Loads the necessary pins. */
void setup() {
#ifdef SERIAL
Serial.begin(115200);
#endif
// Set the pin mode for the on-board LED.
pinMode(LED_BUILTIN, OUTPUT);
#ifdef MOVEMENT
PRINTLN("Movement active.");
// Set the pin modes for the driver connections.
pinMode(PIN_DRIVER_AIN1, OUTPUT);
pinMode(PIN_DRIVER_AIN2, OUTPUT);
pinMode(PIN_DRIVER_APWM, OUTPUT);
pinMode(PIN_DRIVER_BIN1, OUTPUT);
pinMode(PIN_DRIVER_BIN2, OUTPUT);
pinMode(PIN_DRIVER_BPWM, OUTPUT);
pinMode(PIN_GREEN_LED, OUTPUT);
pinMode(PIN_RED_LED, OUTPUT);
// Initialize gyro
if (!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) {
error();
return;
}
// Set the gyro.
mpu.calibrateGyro();
mpu.setThreshold(3);
#endif
// Set the initial state.
state = STATE_VERTICAL;
// Default
rowLength = 1.0;
stepSize = 0.1;
rowWidth = 0.1;
rowCount = 3;
turnsCCW = 0;
#ifdef LOGGING
PRINTLN("Logging active.");
// Set up the SD card.
// Initialize the SD library and read the input file.
// If the library fails to initialize.
if (!SD.begin()) {
PRINTLN("Failed to initialize SD library!");
// Set the state to DONE.
error();
return;
}
#endif
#ifdef READING
PRINTLN("Reading active.");
// If there is not enough data given.
if (!(currentFile = SD.open("input.txt"))) {
PRINTLN("Failed to open the input.bin file!");
// Set the state to DONE.
error();
return;
}
String buffer;
// Read the input data as string.
buffer = currentFile.readStringUntil('\n');
rowLength = buffer.toFloat();
buffer = currentFile.readStringUntil('\n');
stepSize = buffer.toFloat();
buffer = currentFile.readStringUntil('\n');
rowWidth = buffer.toFloat();
buffer = currentFile.readStringUntil('\n');
rowCount = buffer.toInt();
buffer = currentFile.readStringUntil('\n');
turnsCCW = buffer.toInt() ? 1 : 0;
// Close the file.
currentFile.close();
#endif
#ifdef LOGGING
// Open the output file.
if (!(currentFile = SD.open("output.txt", FILE_WRITE))) {
PRINTLN("Failed to open the output file!");
// Set the state to DONE if the file could not be opened.
error();
return;
}
// Write the data given by the user.
currentFile.print("Row Length: ");
currentFile.println(rowLength);
currentFile.print("Step Size: ");
currentFile.println(stepSize);
currentFile.print("Row Width: ");
currentFile.println(rowWidth);
currentFile.print("Row Count: ");
currentFile.println(rowCount);
currentFile.print("Initial Turn CW: ");
currentFile.println(turnsCCW);
// Close the file.
currentFile.close();
#endif
#ifdef DELAY_AFTER_SETUP
PRINT("Delaying for ");
PRINT(DELAY_AFTER_SETUP);
PRINTLN(" seconds...");
delay(1000 * DELAY_AFTER_SETUP);
#endif
PRINTLN("Values:");
PRINT("Row Length: ");
PRINTLN(rowLength);
PRINT("Step Size: ");
PRINTLN(stepSize);
PRINT("Row Width: ");
PRINTLN(rowWidth);
PRINT("Row Count: ");
PRINTLN(rowCount);
PRINT("Initial Turn CCW: ");
PRINTLN(turnsCCW);
}
// E L E C T R O N I C S I N T E R F A C E
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/** Sets the signals so the wheels make the robot go forwards. */
void forward() {
wheels(255, 255);
speed = DISPLACEMENT_PER_SECOND;
}
/** Sets the signals so the wheels stop turning. */
void stop() {
wheels(0, 0);
speed = 0.0;
}
/** Stores the current temperature to the SD card. */
void storeTemperature() {
#ifdef LOGGING
// Open the output file.
if (!(currentFile = SD.open("output.txt", FILE_WRITE))) {
PRINTLN("Failed to open the output file!");
// Set the state to DONE if the file could not be opened.
error();
return;
}
// Write the temperature.
currentFile.print("Row: ");
currentFile.print(row);
currentFile.print(" | Position: ");
currentFile.print(position);
currentFile.print(" | Data Point: ");
currentFile.print(dataPoint);
currentFile.print(" | Temperature: ");
currentFile.println(temperature());
// Close the file.
currentFile.close();
#endif
}
// L O G I C
// ~~~~~~~~~
void prepareForTurn() {
position = 0.0;
aimedYaw = yaw - 90.0 + turnsCCW * 180.0;
speed = 0.0;
}
/** Updates the vertical state. */
void verticalStateUpdate() {
// Move by a tick.
forward();
PRINT("Aimed Yaw:");
PRINT(aimedYaw);
PRINT(" Yaw:");
PRINT(yaw);
PRINT(" Angle:");
PRINT(angle);
PRINT(" Position:");
PRINT(position);
PRINT(" Data Point:");
PRINTLN(dataPoint);
if (abs(angle) > FORWARD_ANGLE_THRESHOLD) {
PRINT("Deviated from the path by: ");
PRINTLN(angle);
state = STATE_ANGULAR;
aimedState = STATE_VERTICAL;
speed = 0.0;
}
// Check for the end of the row.
if (position >= rowLength) {
PRINTLN("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
PRINT("End of the row ");
PRINTLN(row);
// Change the state to rotation.
state = STATE_ANGULAR;
// Revert the turning direction.
PRINT("Change turnsCCW from: ");
PRINT(turnsCCW);
turnsCCW = turnsCCW ? 0 : 1;
PRINT(" to: ");
PRINTLN(turnsCCW);
PRINTLN("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
// If the previous row was the last one.
if (++row == rowCount) {
// Change the state to done.
itIsDone();
return;
}
// Prepare for the rotation state.
aimedState = STATE_HORIZONTAL;
prepareForTurn();
// Check for the measurement spot.
} else if (position - dataPoint * stepSize > 0.0) {
digitalWrite(PIN_GREEN_LED, HIGH);
stop();
// Store the temperature.
storeTemperature();
dataPoint++;
digitalWrite(PIN_GREEN_LED, LOW);
}
}
/** Updates the horizontal state. */
void horizontalStateUpdate() {
// Move by a tick.
forward();
PRINT("Aimed Yaw:");
PRINT(aimedYaw);
PRINT(" Yaw:");
PRINT(yaw);
PRINT(" Angle:");
PRINT(angle);
PRINT(" Position:");
PRINTLN(position);
if (abs(angle) > FORWARD_ANGLE_THRESHOLD) {
PRINT("Deviated from the path by: ");
PRINTLN(angle);
state = STATE_ANGULAR;
aimedState = STATE_HORIZONTAL;
speed = 0.0;
}
// Check for the start of the row.
if (position >= rowWidth) {
PRINTLN("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
PRINT("Start of the row: ");
PRINTLN(row);
PRINTLN("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
// Change the state to rotation.
state = STATE_ANGULAR;
// Prepare for the rotation state.
aimedState = STATE_VERTICAL;
dataPoint = 0;
prepareForTurn();
}
}
/** Updates the angular state. */
void angularStateUpdate() {
// Turn by a tick.
int turnSignalCCW = angle > 0.0 ? 255 : -255;
wheels(-turnSignalCCW, turnSignalCCW);
// If the robot completed the turn.
if (abs(angle) <= ANGLE_THRESHOLD) {
// Change to the next state.
state = aimedState;
PRINTLN("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
PRINT("End of the turn CCW: ");
PRINTLN(turnsCCW);
PRINTLN("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
PRINT("Aimed Yaw:");
PRINT(aimedYaw);
PRINT(" Yaw:");
PRINT(yaw);
PRINT(" Angle:");
PRINTLN(angle);
}
/** Changes the state to ERROR and signals the wheels to stop. */
void error() {
PRINTLN("An error occured!");
state = STATE_ERROR;
// Stop the wheels.
stop();
}
/** Changes the state to DONE and signals the wheels to stop. */
void itIsDone() {
PRINTLN("Done!");
state = STATE_DONE;
// Stop the wheels.
stop();
}
/** Updates the state of the robot. */
void loop() {
unsigned long timer = millis();
#ifdef MOVEMENT
// Read normalized values
Vector norm = mpu.readNormalizeGyro();
// Calculate Pitch, Roll and Yaw
yaw += norm.ZAxis * elapsedTime / 1000.0;
angle = aimedYaw - yaw;
// Record the displacement.
position += speed * elapsedTime;
#endif
// Break up the logic into different functions to increase readability.
switch (state) {
case STATE_VERTICAL:
verticalStateUpdate();
break;
case STATE_HORIZONTAL:
horizontalStateUpdate();
break;
case STATE_ANGULAR:
angularStateUpdate();
break;
case STATE_ERROR:
// Blink the on-board LED.
digitalWrite(LED_BUILTIN, blink = blink ? 0 : 1);
digitalWrite(PIN_RED_LED, blink);
delay(100);
break;
case STATE_DONE:
break;
}
// Wait for the correct tick rate.
elapsedTime = millis() - timer;
}
| 23.227571 | 73 | 0.667923 |
83584e020ff8753727b597814ac73f8b681b7fcd | 255 | c | C | functions.c | jonnor/formulate | 91416aa500cab13097f88dc8bba73a76f4f0dd27 | [
"MIT"
] | null | null | null | functions.c | jonnor/formulate | 91416aa500cab13097f88dc8bba73a76f4f0dd27 | [
"MIT"
] | null | null | null | functions.c | jonnor/formulate | 91416aa500cab13097f88dc8bba73a76f4f0dd27 | [
"MIT"
] | null | null | null |
static inline float
min(float a, float b) {
return (a < b) ? a : b;
}
static inline float
max(float a, float b) {
return (a > b) ? a : b;
}
static inline float
bound(float v, float upper, float lower) {
return min(max(v, lower), upper);
}
| 15 | 42 | 0.607843 |
835c5b164b496a3509df2745c3e99c71cb080ebe | 416 | h | C | Silicon/AlderlakePkg/Include/RegAccess.h | kokweich/slimbootloader | 6fd1141c75a33894e3a7937dbc55859e4a6dacae | [
"BSD-2-Clause-NetBSD",
"PSF-2.0",
"BSD-2-Clause",
"Apache-2.0",
"MIT",
"BSD-2-Clause-Patent"
] | 1 | 2022-03-18T08:47:53.000Z | 2022-03-18T08:47:53.000Z | Silicon/AlderlakePkg/Include/RegAccess.h | kokweich/slimbootloader | 6fd1141c75a33894e3a7937dbc55859e4a6dacae | [
"BSD-2-Clause-NetBSD",
"PSF-2.0",
"BSD-2-Clause",
"Apache-2.0",
"MIT",
"BSD-2-Clause-Patent"
] | null | null | null | Silicon/AlderlakePkg/Include/RegAccess.h | kokweich/slimbootloader | 6fd1141c75a33894e3a7937dbc55859e4a6dacae | [
"BSD-2-Clause-NetBSD",
"PSF-2.0",
"BSD-2-Clause",
"Apache-2.0",
"MIT",
"BSD-2-Clause-Patent"
] | null | null | null | /** @file
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __REG_ACCESS_H__
#define __REG_ACCESS_H__
#define R_IOPORT_CMOS_STANDARD_INDEX 0x70
#define R_IOPORT_CMOS_STANDARD_DATA 0x71
#define R_IOPORT_CMOS_IDX_DIAGNOSTIC_STATUS 0x0E
#define ONLY_REGISTER_OFFSET(x) (x & 0xFFF)
#endif /* __REG_ACCESS_H__ */
| 23.111111 | 65 | 0.740385 |
835d64123d5f4e5e5f71fbb04fd0932ff6592e9c | 1,323 | h | C | symbol_table/symTable.h | saswatlevin/Bell | 1c81d52d4d4d182f460b830b5d4b081b5d5bd479 | [
"MIT"
] | 1 | 2019-05-15T03:00:41.000Z | 2019-05-15T03:00:41.000Z | symbol_table/symTable.h | saswatlevin/ring-parser | 1c81d52d4d4d182f460b830b5d4b081b5d5bd479 | [
"MIT"
] | null | null | null | symbol_table/symTable.h | saswatlevin/ring-parser | 1c81d52d4d4d182f460b830b5d4b081b5d5bd479 | [
"MIT"
] | null | null | null | #ifndef symTable_h
#define symTable_h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TABLE_SIZE 20
int hashIndex=0;
typedef struct {
int index;
char name[10];
int scope;
char datatype[10];
int isFunction;
char returnType[10];
int argCount;
int* argsID;
}TOKEN;
TOKEN* SYMTABLE[TABLE_SIZE];
TOKEN* newToken() {
TOKEN* temp = (TOKEN*)malloc(sizeof(TOKEN));
return temp;
}
TOKEN* initialiseArgs(TOKEN* f, int argCount) {
f->argCount = argCount;
f->argsID = (int*)calloc(argCount,sizeof(int));
int i;
for(i=0; i<argCount; i++) {
f->argsID[i]=-1;
}
}
int hashFunction() {
return hashIndex++;
}
void initialiseTable() {
int i;
for(i=0; i<TABLE_SIZE; i++) {
SYMTABLE[i] = NULL;
}
}
void printToken(TOKEN* t) {
printf("%-12d%-12s%-12s",t->index,t->name,t->datatype);
t->scope==1?printf("\tL\n"): printf("\tG\n");
}
void printSymbolTable() {
int i;
printf("--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--\n");
printf("\t\t\tSYMBOL TABLE\n\n");
printf("index\tlexemeName\tDatatype\tscope\n\n");
for(i=0; i<TABLE_SIZE; i++) {
if(SYMTABLE[i]==NULL)
continue;
printToken(SYMTABLE[i]);
}
}
int searchTable(char* item) {
int i;
for(i=0; i<TABLE_SIZE; i++) {
if(SYMTABLE[i]!=NULL && strcmp(SYMTABLE[i]->name,item)==0) return i;
}
return -1;
}
#endif | 18.375 | 76 | 0.632653 |
835e672d59fb75cfffccb8ed12539d3bd92af7cf | 821 | h | C | third_party/aub_stream/headers/allocation_params.h | mattcarter2017/compute-runtime | 1f52802aac02c78c19d5493dd3a2402830bbe438 | [
"Intel",
"MIT"
] | null | null | null | third_party/aub_stream/headers/allocation_params.h | mattcarter2017/compute-runtime | 1f52802aac02c78c19d5493dd3a2402830bbe438 | [
"Intel",
"MIT"
] | null | null | null | third_party/aub_stream/headers/allocation_params.h | mattcarter2017/compute-runtime | 1f52802aac02c78c19d5493dd3a2402830bbe438 | [
"Intel",
"MIT"
] | null | null | null | /*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <cstddef>
#include <cstdint>
namespace aub_stream {
struct AllocationParams {
AllocationParams() = delete;
AllocationParams(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize)
: gfxAddress(gfxAddress), size(size), pageSize(pageSize), memoryBanks(memoryBanks), hint(hint), memory(memory) {
additionalParams = {};
}
uint64_t gfxAddress = 0;
size_t size = 0;
size_t pageSize;
uint32_t memoryBanks;
int hint = 0;
const void *memory = nullptr;
struct AdditionalParams {
bool compressionEnabled :1;
bool uncached : 1;
bool padding : 6;
} additionalParams;
};
} // namespace aub_stream
| 23.457143 | 123 | 0.674787 |
835e6850ab32e925389ecfc239ab8a28f408fa66 | 5,183 | h | C | cpdp/include/tencentcloud/cpdp/v20190820/model/QueryTransferResultData.h | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 43 | 2019-08-14T08:14:12.000Z | 2022-03-30T12:35:09.000Z | cpdp/include/tencentcloud/cpdp/v20190820/model/QueryTransferResultData.h | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 12 | 2019-07-15T10:44:59.000Z | 2021-11-02T12:35:00.000Z | cpdp/include/tencentcloud/cpdp/v20190820/model/QueryTransferResultData.h | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 28 | 2019-07-12T09:06:22.000Z | 2022-03-30T08:04:18.000Z | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENCENTCLOUD_CPDP_V20190820_MODEL_QUERYTRANSFERRESULTDATA_H_
#define TENCENTCLOUD_CPDP_V20190820_MODEL_QUERYTRANSFERRESULTDATA_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
#include <tencentcloud/core/AbstractModel.h>
namespace TencentCloud
{
namespace Cpdp
{
namespace V20190820
{
namespace Model
{
/**
* 智能代发-单笔代发转账查询接口返回内容
*/
class QueryTransferResultData : public AbstractModel
{
public:
QueryTransferResultData();
~QueryTransferResultData() = default;
void ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const;
CoreInternalOutcome Deserialize(const rapidjson::Value &value);
/**
* 获取平台交易流水号
* @return TradeSerialNo 平台交易流水号
*/
std::string GetTradeSerialNo() const;
/**
* 设置平台交易流水号
* @param TradeSerialNo 平台交易流水号
*/
void SetTradeSerialNo(const std::string& _tradeSerialNo);
/**
* 判断参数 TradeSerialNo 是否已赋值
* @return TradeSerialNo 是否已赋值
*/
bool TradeSerialNoHasBeenSet() const;
/**
* 获取订单号
* @return OrderId 订单号
*/
std::string GetOrderId() const;
/**
* 设置订单号
* @param OrderId 订单号
*/
void SetOrderId(const std::string& _orderId);
/**
* 判断参数 OrderId 是否已赋值
* @return OrderId 是否已赋值
*/
bool OrderIdHasBeenSet() const;
/**
* 获取交易状态。
0 处理中
1 提交成功
2 交易成功
3 交易失败
4 未知渠道异常
99 未知系统异常
* @return TradeStatus 交易状态。
0 处理中
1 提交成功
2 交易成功
3 交易失败
4 未知渠道异常
99 未知系统异常
*/
int64_t GetTradeStatus() const;
/**
* 设置交易状态。
0 处理中
1 提交成功
2 交易成功
3 交易失败
4 未知渠道异常
99 未知系统异常
* @param TradeStatus 交易状态。
0 处理中
1 提交成功
2 交易成功
3 交易失败
4 未知渠道异常
99 未知系统异常
*/
void SetTradeStatus(const int64_t& _tradeStatus);
/**
* 判断参数 TradeStatus 是否已赋值
* @return TradeStatus 是否已赋值
*/
bool TradeStatusHasBeenSet() const;
/**
* 获取业务备注
注意:此字段可能返回 null,表示取不到有效值。
* @return Remark 业务备注
注意:此字段可能返回 null,表示取不到有效值。
*/
std::string GetRemark() const;
/**
* 设置业务备注
注意:此字段可能返回 null,表示取不到有效值。
* @param Remark 业务备注
注意:此字段可能返回 null,表示取不到有效值。
*/
void SetRemark(const std::string& _remark);
/**
* 判断参数 Remark 是否已赋值
* @return Remark 是否已赋值
*/
bool RemarkHasBeenSet() const;
private:
/**
* 平台交易流水号
*/
std::string m_tradeSerialNo;
bool m_tradeSerialNoHasBeenSet;
/**
* 订单号
*/
std::string m_orderId;
bool m_orderIdHasBeenSet;
/**
* 交易状态。
0 处理中
1 提交成功
2 交易成功
3 交易失败
4 未知渠道异常
99 未知系统异常
*/
int64_t m_tradeStatus;
bool m_tradeStatusHasBeenSet;
/**
* 业务备注
注意:此字段可能返回 null,表示取不到有效值。
*/
std::string m_remark;
bool m_remarkHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_CPDP_V20190820_MODEL_QUERYTRANSFERRESULTDATA_H_
| 27.42328 | 116 | 0.468455 |
8360b1e2fb7b49afecae202969f9cab2f54dc03e | 566 | h | C | ShenQi/HJSDKDemo/HJSDKDemo/SDK/Framework/VVSDK.framework/Headers/VVSDK.h | zhongaiyemaozi/HJSDK | 242cdb9408b5f43bea1fff142878197fd383b5a2 | [
"MIT"
] | 1 | 2020-10-26T17:43:04.000Z | 2020-10-26T17:43:04.000Z | ShenQi/HJSDKDemo/HJSDKDemo/SDK/Framework/VVSDK.framework/Headers/VVSDK.h | zhongaiyemaozi/HJSDK | 242cdb9408b5f43bea1fff142878197fd383b5a2 | [
"MIT"
] | null | null | null | ShenQi/HJSDKDemo/HJSDKDemo/SDK/Framework/VVSDK.framework/Headers/VVSDK.h | zhongaiyemaozi/HJSDK | 242cdb9408b5f43bea1fff142878197fd383b5a2 | [
"MIT"
] | null | null | null | //
// VVSDK.h
// VVSDK
//
// Created by 唐 on 2017/8/21.
// Copyright © 2017年 Weep Yan. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for VVSDK.
FOUNDATION_EXPORT double VVSDKVersionNumber;
//! Project version string for VVSDK.
FOUNDATION_EXPORT const unsigned char VVSDKVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <VVSDK/PublicHeader.h>
#import "VVDefines.h"
#import "VVCallBack.h"
#import "VVSDKInstance.h"
#import "VVPay.h"
#import "VVError.h"
| 22.64 | 130 | 0.736749 |
83616eda1ad22e770d4efb662783d399f7024e2c | 2,554 | h | C | src/libraries/include/sg_context_typedefs.h | jeffhostetler/veracity | 7af449ab8c23f5e74ef0c56d6e7d4d075545aa47 | [
"Apache-2.0"
] | 1 | 2020-11-22T14:14:18.000Z | 2020-11-22T14:14:18.000Z | src/libraries/include/sg_context_typedefs.h | jeffhostetler/veracity | 7af449ab8c23f5e74ef0c56d6e7d4d075545aa47 | [
"Apache-2.0"
] | null | null | null | src/libraries/include/sg_context_typedefs.h | jeffhostetler/veracity | 7af449ab8c23f5e74ef0c56d6e7d4d075545aa47 | [
"Apache-2.0"
] | null | null | null | /*
Copyright 2010-2013 SourceGear, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
*
* @file sg_context_typedefs.h
*
*/
#ifndef H_SG_CONTEXT_TYPEDEFS_H
#define H_SG_CONTEXT_TYPEDEFS_H
BEGIN_EXTERN_C;
//////////////////////////////////////////////////////////////////
// These are garden-variety public definitions.
// (You need not pretend you didn't see them here.)
typedef void SG_context__msg_callback(
SG_context * pCtx,
const char * pszMsg);
//////////////////////////////////////////////////////////////////
// ALL OF THESE DEFINITIONS SHOULD BE CONSIDERED *PRIVATE* TO sg_context.c
// Normally, these would be hidden within sg_context.c and only the typedef
// would be public, but we need the structure declarations to allow (for
// performance reasons) some of the SG_ERR_ macros to look at the error
// state directly without doing a function call. So pretend you didn't
// see this in a public header file.
#define SG_CONTEXT_MAX_STACK_TRACE_LEN_BYTES 1048576
#define SG_CONTEXT_LEN_DESCRIPTION 1023
#define SG_CONTEXT_MAX_ERROR_LEVELS 100
struct _sg_context
{
SG_process_id process; // ID of the process this context was allocated in.
SG_thread_id thread; // ID of the thread this context was allocated in
SG_uint32 level; // current error value is errValue[level]
SG_uint32 lenStackTrace; // current strlen(szStackTrace)
SG_error errValues[SG_CONTEXT_MAX_ERROR_LEVELS];
SG_bool bStackTraceAtLimit; // Rather than returning an error if we run out of space for the stack trace,
// we set this true and ignore subsequent string appends.
char szDescription[SG_CONTEXT_LEN_DESCRIPTION + 1];
char szStackTrace[SG_CONTEXT_MAX_STACK_TRACE_LEN_BYTES + 1];
struct _sg_log__context* pLogContext;
};
// We already defined the following in <sg.h>
// typedef struct _sg_context SG_context;
// so we can't do it here.
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
END_EXTERN_C;
#endif//H_SG_CONTEXT_TYPEDEFS_H
| 32.329114 | 108 | 0.690681 |
8361c10f0b2d87460fab17f84763fb79c3a47802 | 1,067 | h | C | C++GP17/donto/client/Action.h | dhanak/competitive-coding | 9e28298f8c646f169b7389d0ef20f99c5ef68f00 | [
"MIT"
] | null | null | null | C++GP17/donto/client/Action.h | dhanak/competitive-coding | 9e28298f8c646f169b7389d0ef20f99c5ef68f00 | [
"MIT"
] | null | null | null | C++GP17/donto/client/Action.h | dhanak/competitive-coding | 9e28298f8c646f169b7389d0ef20f99c5ef68f00 | [
"MIT"
] | null | null | null | #pragma once
#include "Client.h"
struct ACTION
{
virtual void Execute(CLIENT* Client, int HeroId) = 0;
virtual ~ACTION() {}
};
struct ATTACK : public ACTION
{
int mTargetId;
explicit ATTACK(int TargetId)
: mTargetId(TargetId)
{}
virtual void Execute(CLIENT* Client, int HeroId) override
{
Client->Attack(HeroId, mTargetId);
MAP_OBJECT * pEnemy = Client->mParser.GetUnitByID(mTargetId);
//printf("ATTACK %d: enemy %d (type %d) at %d,%d\n",
// HeroId,
// mTargetId,
// pEnemy ? pEnemy->t : -1,
// POS_TO_FMT(pEnemy ? pEnemy->pos : POS())
// );
}
};
struct MOVE : public ACTION
{
POS mTargetPos;
explicit MOVE(POS TargetPos)
: mTargetPos(TargetPos)
{}
virtual void Execute(CLIENT* Client, int HeroId) override
{
if (mTargetPos==POS())
printf("Going to 0,0\n");
//MAP_OBJECT * pHero = Client->mParser.GetUnitByID(HeroId);
//printf("MOVE %d: %d,%d -> %d,%d\n", HeroId, POS_TO_FMT(pHero ? pHero->pos : POS()), POS_TO_FMT(mTargetPos));
Client->Move(HeroId, mTargetPos);
}
}; | 22.229167 | 113 | 0.628866 |
8363528e42f3230c60b06307f7b76f72343f2ceb | 1,494 | h | C | ge/graph/passes/ref_identity_delete_op_pass.h | Ascend/graphengine | 45d6a09b12a07eb3c854452f83dab993eba79716 | [
"Apache-2.0"
] | 207 | 2020-03-28T02:12:50.000Z | 2021-11-23T18:27:45.000Z | ge/graph/passes/ref_identity_delete_op_pass.h | Ascend/graphengine | 45d6a09b12a07eb3c854452f83dab993eba79716 | [
"Apache-2.0"
] | 4 | 2020-04-17T07:32:44.000Z | 2021-06-26T04:55:03.000Z | ge/graph/passes/ref_identity_delete_op_pass.h | Ascend/graphengine | 45d6a09b12a07eb3c854452f83dab993eba79716 | [
"Apache-2.0"
] | 13 | 2020-03-28T02:52:26.000Z | 2021-07-03T23:12:54.000Z | /**
* Copyright 2020 Huawei Technologies Co., Ltd
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_
#define GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_
#include <map>
#include <string>
#include "framework/common/ge_inner_error_codes.h"
#include "inc/graph_pass.h"
namespace ge {
class RefIdentityDeleteOpPass : public GraphPass {
public:
Status Run(ComputeGraphPtr graph);
private:
Status DealNoOutputRef(const NodePtr &node, const NodePtr &ref_identity, int input_index,
const ComputeGraphPtr &graph);
NodePtr GetVariableRef(const NodePtr &ref, const NodePtr &ref_identity, NodePtr &first_node);
bool CheckControlEdge(const NodePtr &ref, const NodePtr &variable_ref);
Status RemoveUselessControlEdge(const NodePtr &ref, const NodePtr &variable_ref);
NodePtr GetRefNode(const NodePtr &node, int &input_index);
};
} // namespace ge
#endif // GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_
| 36.439024 | 95 | 0.771754 |
83653fb538fbf7388522efe40aaaa77fefec8431 | 5,076 | h | C | chrome/browser/views/tabs/grid.h | rwatson/chromium-capsicum | b03da8e897f897c6ad2cda03ceda217b760fd528 | [
"BSD-3-Clause"
] | 11 | 2015-03-20T04:08:08.000Z | 2021-11-15T15:51:36.000Z | chrome/browser/views/tabs/grid.h | changbai1980/chromium | c4625eefca763df86471d798ee5a4a054b4716ae | [
"BSD-3-Clause"
] | null | null | null | chrome/browser/views/tabs/grid.h | changbai1980/chromium | c4625eefca763df86471d798ee5a4a054b4716ae | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_VIEWS_TABS_GRID_H_
#define CHROME_BROWSER_VIEWS_TABS_GRID_H_
#include <vector>
#include "app/slide_animation.h"
#include "base/gfx/rect.h"
#include "views/view.h"
// Grid is a view that positions its children (cells) in a grid. Grid
// attempts to layout the children at their preferred size (assuming
// all cells have the same preferred size) in a single row. If the sum
// of the widths is greater than the max width, then a new row is
// added. Once the max number of rows and columns are reached, the
// cells are shrunk to fit.
//
// Grid offers methods to move, insert and remove cells. These end up changing
// the child views, and animating the transition.
class Grid : public views::View, public AnimationDelegate {
public:
Grid();
// Sets the max size for the Grid. See description above class for details.
void set_max_size(const gfx::Size& size) { max_size_ = size; }
const gfx::Size& max_size() const { return max_size_; }
// Moves the child view to the specified index, animating the move.
void MoveCell(int old_index, int new_index);
// Inserts a cell at the specified index, animating the insertion.
void InsertCell(int index, views::View* cell);
// Removes the cell at the specified index, animating the removal.
// WARNING: this does NOT delete the view, it's up to the caller to do that.
void RemoveCell(int index);
// Calculates the target bounds of each cell and starts the animation timer
// (assuming it isn't already running). This is invoked for you, but may
// be invoked to retrigger animation, perhaps after changing the floating
// index.
void AnimateToTargetBounds();
// Sets the index of the floating cell. The floating cells bounds are NOT
// updated along with the rest of the cells, and the floating cell is painted
// after all other cells. This is typically used during drag and drop when
// the user is dragging a cell around.
void set_floating_index(int index) { floating_index_ = index; }
// Returns the number of columns.
int columns() const { return columns_; }
// Returns the number of rows.
int rows() const { return rows_; }
// Returns the width of a cell.
int cell_width() const { return cell_width_; }
// Returns the height of a cell.
int cell_height() const { return cell_height_; }
// Returns the bounds of the specified cell.
gfx::Rect CellBounds(int index);
// Returns the value based on the current animation. |start| gives the
// starting coordinate and |target| the target coordinate. The resulting
// value is between |start| and |target| based on the current animation.
int AnimationPosition(int start, int target);
// Convenience for returning a rectangle between |start_bounds| and
// |target_bounds| based on the current animation.
gfx::Rect AnimationPosition(const gfx::Rect& start_bounds,
const gfx::Rect& target_bounds);
// View overrides.
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child);
virtual gfx::Size GetPreferredSize();
virtual void Layout();
void PaintChildren(gfx::Canvas* canvas);
// AnimationDelegate overrides.
virtual void AnimationEnded(const Animation* animation);
virtual void AnimationProgressed(const Animation* animation);
virtual void AnimationCanceled(const Animation* animation);
// Padding between cells.
static const int kCellXPadding;
static const int kCellYPadding;
private:
// Calculates the bounds of each of the cells, adding the result to |bounds|.
void CalculateCellBounds(std::vector<gfx::Rect>* bounds);
// Resets start_bounds_ to the bounds of the current cells, and invokes
// CalculateCellBounds to determine the target bounds. Then starts the
// animation if it isn't already running.
void CalculateTargetBoundsAndStartAnimation();
// Resets the bounds of each cell to that of target_bounds_.
void SetViewBoundsToTarget();
// The animation.
SlideAnimation animation_;
// If true, we're adding/removing a child and can ignore the change in
// ViewHierarchyChanged.
bool modifying_children_;
// Do we need a layout? This is set to true any time a child is added/removed.
bool needs_layout_;
// Max size we layout to.
gfx::Size max_size_;
// Preferred size.
int pref_width_;
int pref_height_;
// Current cell size.
int cell_width_;
int cell_height_;
// Number of rows/columns.
int columns_;
int rows_;
// See description above setter.
int floating_index_;
// Used during animation, gives the initial bounds of the views.
std::vector<gfx::Rect> start_bounds_;
// Used during animation, gives the target bounds of the views.
std::vector<gfx::Rect> target_bounds_;
DISALLOW_COPY_AND_ASSIGN(Grid);
};
#endif // CHROME_BROWSER_VIEWS_TABS_GRID_H_
| 35.006897 | 80 | 0.723404 |
8369bdde2bfb4b72d301d13da074a538ca3ccccf | 11,512 | c | C | platforms/unix/plugins/ScratchPlugin/unixSeriaPort2Ops.c | bavison/opensmalltalk-vm | d494240736f7c0309e3e819784feb1d53ed0985a | [
"MIT"
] | 445 | 2016-06-30T08:19:11.000Z | 2022-03-28T06:09:49.000Z | platforms/unix/plugins/ScratchPlugin/unixSeriaPort2Ops.c | bavison/opensmalltalk-vm | d494240736f7c0309e3e819784feb1d53ed0985a | [
"MIT"
] | 439 | 2016-06-29T20:14:36.000Z | 2022-03-17T19:59:58.000Z | platforms/unix/plugins/ScratchPlugin/unixSeriaPort2Ops.c | bavison/opensmalltalk-vm | d494240736f7c0309e3e819784feb1d53ed0985a | [
"MIT"
] | 137 | 2016-07-02T17:32:07.000Z | 2022-03-20T11:17:25.000Z | /* unixSerialPort2Ops.c -- Scratch operations for unix based OSes. Support
* for SerialPort2 primitives under Unix, including OSX and Linux.
*
*
* Copyright (C) 2011 Massachusetts Institute of Technology
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
#include "ScratchPlugin.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
// support for systems with a single hardware flow control bit
// on such systems setting hardware handshaking for input sets it for output as well
#ifndef CRTS_IFLOW
# define CRTS_IFLOW CRTSCTS
#endif
#ifndef CCTS_OFLOW
# define CCTS_OFLOW CRTSCTS
#endif
// globals
#define PORT_COUNT 32
static int gFileDescr[PORT_COUNT] = { // file descriptors for open serial ports
-1, -1, -1, -1, -1, -1, -1, -1, // the portNum kept by Squeak is an index
-1, -1, -1, -1, -1, -1, -1, -1, // into this array. -1 marks unused entries.
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1};
static struct termios gOrigTermios[PORT_COUNT]; // original termios settings for open ports
#define PRIM_FAILED -1
// helper function declarations
int FileDescrForEntry(int portNum);
int OpenPortNamed(const char *bsdPath, int baudRate, int entryIndex);
int isPrefix(char *prefix, char *s);
int isSerialPortDev(char *s);
int SerialPortCount(void) {
DIR *dirPtr;
struct dirent *entryPtr;
int cnt = 0;
if ((dirPtr = opendir("/dev")) == NULL) return 0;
while ((entryPtr = readdir(dirPtr)) != NULL) {
if (isSerialPortDev(entryPtr->d_name)) cnt++;
}
closedir(dirPtr);
return cnt;
}
// Find the name of the given port number. Fill in bsdPath if successful.
// Otherwise, make bsdPath be the empty string.
void SerialPortName(int portIndex, char *bsdPath, int maxPathSize) {
DIR *dirPtr;
struct dirent *entryPtr;
int cnt = 0;
*bsdPath = '\0'; // result is the empty string if port not found
if (portIndex < 1) return;
if ((dirPtr = opendir("/dev")) == NULL) return;
while ((entryPtr = readdir(dirPtr)) != NULL) {
if (isSerialPortDev(entryPtr->d_name)) cnt++;
if (cnt == portIndex) {
strncat(bsdPath, "/dev/", maxPathSize);
strncat(bsdPath, entryPtr->d_name, maxPathSize);
closedir(dirPtr);
return;
}
}
closedir(dirPtr);
}
int SerialPortOpenPortNamed(char *portName, int baudRate) {
int entryIndex;
// scan for first free entry
for (entryIndex = 0; entryIndex < PORT_COUNT; entryIndex++) {
if (gFileDescr[entryIndex] == -1) break;
}
if (entryIndex >= PORT_COUNT) return PRIM_FAILED; // no free entry
if (!OpenPortNamed(portName, baudRate, entryIndex)) return PRIM_FAILED;
return entryIndex;
}
void SerialPortClose(int portNum) {
int fDescr;
if ((fDescr = FileDescrForEntry(portNum)) < 0) return; // already closed
// restore the serial port settings to their original state
tcsetattr(fDescr, TCSANOW, &gOrigTermios[portNum]);
close(fDescr);
gFileDescr[portNum] = -1;
}
int SerialPortIsOpen(int portNum) {
return FileDescrForEntry(portNum) != -1;
}
int SerialPortRead(int portNum, char *bufPtr, int bufSize) {
int fDescr, count = 0;
if ((fDescr = FileDescrForEntry(portNum)) < 0) return 0;
count = read(fDescr, bufPtr, bufSize);
if (count < 0) return 0; // read error
return count;
}
int SerialPortWrite(int portNum, char *bufPtr, int bufSize) {
int fDescr, count = 0;
if ((fDescr = FileDescrForEntry(portNum)) < 0) return 0;
count = write(fDescr, bufPtr, bufSize);
if (count < 0) return 0; // write error
return count;
}
// Port options for SetOption/GetOption:
// 1. baud rate
// 2. data bits
// 3. stop bits
// 4. parity type
// 5. input flow control type
// 6. output flow control type
// 20-25: handshake line bits (DTR, RTS, CTS, DSR, CD, RD)
int SerialPortSetOption(int portNum, int optionNum, int newValue) {
int fDescr, handshake;
struct termios options;
if ((fDescr = FileDescrForEntry(portNum)) < 0) return PRIM_FAILED;
if (tcgetattr(fDescr, &options) == -1) return PRIM_FAILED;
switch (optionNum) {
case 1: // baud rate
if (cfsetspeed(&options, newValue) == -1) return PRIM_FAILED;
break;
case 2: // # of data bits
switch(newValue) {
case 5:
options.c_cflag = (options.c_cflag & ~CSIZE) | CS5;
break;
case 6:
options.c_cflag = (options.c_cflag & ~CSIZE) | CS6;
break;
case 7:
options.c_cflag = (options.c_cflag & ~CSIZE) | CS7;
break;
case 8:
options.c_cflag = (options.c_cflag & ~CSIZE) | CS8;
break;
}
break;
case 3: // 1 or 2 stop bits
if (newValue > 1) options.c_cflag |= CSTOPB; // two stop bits
else options.c_cflag &= ~CSTOPB; // one stop bit
break;
case 4: // parity
options.c_cflag &= ~(PARENB | PARODD); // no parity
if (newValue == 1) options.c_cflag |= (PARENB | PARODD); // odd parity
if (newValue == 2) options.c_cflag |= PARENB; // even parity
break;
case 5: // input flow control
options.c_iflag &= ~IXOFF; // disable xoff input flow control
options.c_cflag &= ~CRTS_IFLOW; // disable RTS (hardware) input flow control
if (newValue == 1) options.c_iflag |= IXOFF; // enable xoff input flow control
if (newValue == 2) {
options.c_cflag |= CRTS_IFLOW; // enable RTS (hardware) input flow control
if (CRTS_IFLOW == CCTS_OFLOW) { // on systems with a single hardware flow control bit:
options.c_iflag &= ~(IXON | IXOFF); // disable xon/xoff flow control
}
}
break;
case 6: // output flow control
options.c_iflag &= ~IXON; // disable xon output flow control
options.c_cflag &= ~CCTS_OFLOW; // disable CTS (hardware) output flow control
if (newValue == 1) options.c_iflag |= IXON; // enable xon output flow control
if (newValue == 2) {
options.c_cflag |= CCTS_OFLOW; // enable CTS (hardware) output flow control
if (CRTS_IFLOW == CCTS_OFLOW) { // on systems with a single hardware flow control bit:
options.c_iflag &= ~(IXON | IXOFF); // disable xon/xoff flow control
}
}
break;
case 20: // set DTR line state
if (ioctl(fDescr, TIOCMGET, &handshake) == -1) return PRIM_FAILED;
handshake = newValue ? (handshake | TIOCM_DTR) : (handshake & ~TIOCM_DTR);
if (ioctl(fDescr, TIOCMSET, &handshake) == -1) return PRIM_FAILED;
break;
case 21: // set RTS line state
if (ioctl(fDescr, TIOCMGET, &handshake) == -1) return PRIM_FAILED;
handshake = newValue ? (handshake | TIOCM_RTS) : (handshake & ~TIOCM_RTS);
if (ioctl(fDescr, TIOCMSET, &handshake) == -1) return PRIM_FAILED;
break;
}
if (tcsetattr(fDescr, TCSANOW, &options) == -1) return PRIM_FAILED;
return 0;
}
int SerialPortGetOption(int portNum, int optionNum) {
int fDescr, handshake = -1;
struct termios options;
if ((fDescr = FileDescrForEntry(portNum)) < 0) return PRIM_FAILED;
if (tcgetattr(fDescr, &options) == -1) return PRIM_FAILED;
if (ioctl(fDescr, TIOCMGET, &handshake) == -1) return PRIM_FAILED;
switch (optionNum) {
case 1: return (int) cfgetispeed(&options);
case 2:
if ((options.c_cflag & CSIZE) == CS5) return 5;
if ((options.c_cflag & CSIZE) == CS6) return 6;
if ((options.c_cflag & CSIZE) == CS7) return 7;
if ((options.c_cflag & CSIZE) == CS8) return 8;
return PRIM_FAILED;
case 3: return (options.c_cflag & CSTOPB) ? 2 : 1;
case 4:
if (!(options.c_cflag & PARENB)) return 0;
return (options.c_cflag & PARODD) ? 1 : 2;
case 5:
if (options.c_iflag & IXOFF) return 1;
if (options.c_cflag & CRTS_IFLOW) return 2;
return 0;
case 6:
if (options.c_iflag & IXON) return 1;
if (options.c_cflag & CCTS_OFLOW) return 2;
return 0;
case 20: return (handshake & TIOCM_DTR) > 0;
case 21: return (handshake & TIOCM_RTS) > 0;
case 22: return (handshake & TIOCM_CTS) > 0;
case 23: return (handshake & TIOCM_DSR) > 0;
case 24: return (handshake & TIOCM_CD) > 0;
case 25: return (handshake & TIOCM_RI) > 0;
}
return PRIM_FAILED;
}
// ***** helper functions *****
// Return the file descriptor for the given entry or -1 if either the
// given port number (index) is out of range or the port is not open.
int FileDescrForEntry(int portNum) {
if ((portNum < 0) || (portNum >= PORT_COUNT)) return PRIM_FAILED;
return gFileDescr[portNum];
}
// Given the path to a serial device, open the device and configure it for
// using given entryIndex. Answer 1 if the operation succeeds, 0 if it fails.
int OpenPortNamed(const char *bsdPath, int baudRate, int entryIndex) {
int fDescr = -1;
struct termios options;
// open the serial port read/write with no controlling terminal; don't block
fDescr = open(bsdPath, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fDescr == -1) {
printf("Error opening serial port %s - %s(%d).\n", bsdPath, strerror(errno), errno);
goto error;
}
// request exclusive access to the port
if (ioctl(fDescr, TIOCEXCL) == -1) {
printf("Error setting TIOCEXCL on %s - %s(%d).\n", bsdPath, strerror(errno), errno);
goto error;
}
// save port settings so we can restore them later
if (tcgetattr(fDescr, &gOrigTermios[entryIndex]) == -1) {
printf("Error getting attributes %s - %s(%d).\n", bsdPath, strerror(errno), errno);
goto error;
}
// port settings are made by modifying a copy of the termios struct
// and then calling tcsetattr() to make those changes take effect.
options = gOrigTermios[entryIndex];
// set the baud rate
if (cfsetspeed(&options, baudRate) == -1) {
printf("Error setting speed %d %s - %s(%d).\n", baudRate, bsdPath, strerror(errno), errno);
goto error;
}
// set raw input (non-canonical) mode, with writes not blocking.
cfmakeraw(&options);
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 0;
// install the new port settings
if (tcsetattr(fDescr, TCSANOW, &options) == -1) {
printf("Error setting attributes %s - %s(%d).\n", bsdPath, strerror(errno), errno);
goto error;
}
gFileDescr[entryIndex] = fDescr;
return 1; // success!
error:
if (fDescr != -1) close(fDescr);
return 0;
}
int isSerialPortDev(char *s) {
return isPrefix("ttyusb", s) || isPrefix("ttyAMA", s);
}
int isPrefix(char *prefix, char *s) {
int prefixC, c;
while (1) {
prefixC = *prefix++;
c = *s++;
if (prefixC == 0) return 1; // match!
if (c == 0) return 0; // s is shorter than prefix
if (c != prefixC) {
if (('a' <= c) && (c <= 'z')) c -= 32;
if (('a' <= prefixC) && (prefixC <= 'z')) prefixC -= 32;
if (c != prefixC) return 0; // non-match
}
}
}
| 32.246499 | 94 | 0.677206 |
836aec30afa0b229234ee2c47b2f826deb4b4462 | 837 | h | C | openapps/rrt/rrt.h | slahmer97/openwsn-fw | 7046d4e407566b9935947bd517191110f75f0781 | [
"BSD-3-Clause"
] | null | null | null | openapps/rrt/rrt.h | slahmer97/openwsn-fw | 7046d4e407566b9935947bd517191110f75f0781 | [
"BSD-3-Clause"
] | null | null | null | openapps/rrt/rrt.h | slahmer97/openwsn-fw | 7046d4e407566b9935947bd517191110f75f0781 | [
"BSD-3-Clause"
] | null | null | null | #ifndef __RRT_H
#define __RRT_H
/**
\addtogroup AppCoAP
\{
\addtogroup rrt
\{
*/
#include "opendefs.h"
#include "opencoap.h"
#include "schedule.h"
//=========================== define ==========================================
//=========================== typedef =========================================
//=========================== variables =======================================
typedef struct {
coap_resource_desc_t desc;
uint8_t discovered;
opentimers_id_t timerId;
int start;
int go;
int counter;
} rrt_vars_t;
//=========================== prototypes ======================================
void rrt_init(void);
void rrt_sendCoAPMsg(char actionMsg, uint8_t *ipv6mote);
void rrt_sendDone(OpenQueueEntry_t* msg, owerror_t error);
/**
\}
\}
*/
#endif | 19.465116 | 80 | 0.432497 |
836d1341822a3b3934296d783691e7b1e87fffb8 | 680 | h | C | Source/TPS/Characters/TPSPlayerController.h | JHPBear/TPS | 7e686a800490d25ca0c1e869bb8a314e691b9dbd | [
"MIT"
] | null | null | null | Source/TPS/Characters/TPSPlayerController.h | JHPBear/TPS | 7e686a800490d25ca0c1e869bb8a314e691b9dbd | [
"MIT"
] | null | null | null | Source/TPS/Characters/TPSPlayerController.h | JHPBear/TPS | 7e686a800490d25ca0c1e869bb8a314e691b9dbd | [
"MIT"
] | null | null | null | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CommonDefines.h"
#include "GameFramework/PlayerController.h"
#include "TPSPlayerController.generated.h"
/**
*
*/
UCLASS()
class ATPSPlayerController : public APlayerController
{
GENERATED_BODY()
public:
ATPSPlayerController();
virtual void PostInitializeComponents() override;
virtual void OnPossess(APawn* aPawn) override;
UPROPERTY()
class UTPSUserWidget* TPSWidget;
void SettingWidget();
protected:
virtual void BeginPlay() override;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = UI)
TSubclassOf<class UTPSUserWidget> TPSWidgetClass;
};
| 18.888889 | 78 | 0.779412 |
836d9d11a352331e2279d68801eecda4f2c71a28 | 4,289 | h | C | tests/syntax.h | schwering/limbo | 76900ff3eee221eb303bf73ce7fd246839fb0b23 | [
"MIT"
] | 247 | 2017-05-06T20:04:42.000Z | 2022-01-22T04:15:09.000Z | tests/syntax.h | schwering/lela | 76900ff3eee221eb303bf73ce7fd246839fb0b23 | [
"MIT"
] | 1 | 2017-08-02T11:09:11.000Z | 2017-08-02T11:09:11.000Z | tests/syntax.h | schwering/lela | 76900ff3eee221eb303bf73ce7fd246839fb0b23 | [
"MIT"
] | 16 | 2017-05-06T20:18:06.000Z | 2022-03-24T04:17:11.000Z | // vim:filetype=cpp:textwidth=120:shiftwidth=2:softtabstop=2:expandtab
// Copyright 2016-2017 Christoph Schwering
// Licensed under the MIT license. See LICENSE file in the project root.
//
// Overloads some operators to provide a higher-level syntax for formulas.
#ifndef LIMBO_FORMAT_CPP_SYNTAX_H_
#define LIMBO_FORMAT_CPP_SYNTAX_H_
#include <utility>
#include <limbo/formula.h>
#include <limbo/clause.h>
#include <limbo/literal.h>
#include <limbo/solver.h>
#include <limbo/term.h>
#define MARK (std::cout << __FILE__ << ":" << __LINE__ << std::endl)
namespace limbo {
namespace format {
namespace cpp {
class HiTerm : public Term {
public:
HiTerm() = default;
explicit HiTerm(Term t) : Term(t) {}
};
class HiSymbol : public Symbol {
public:
HiSymbol(Term::Factory* tf, Symbol s) : Symbol(s), tf_(tf) {}
template<typename... Args>
HiTerm operator()(Args... args) const { return HiTerm(tf_->CreateTerm(*this, Term::Vector({args...}))); }
private:
Term::Factory* const tf_;
};
class HiFormula;
class HiFormula {
public:
HiFormula(const Literal& a) : HiFormula(Clause({a})) {} // NOLINT
HiFormula(const limbo::Clause& c) : HiFormula(Formula::Factory::Atomic(c)) {} // NOLINT
HiFormula(const Formula::Ref& phi) : HiFormula(*phi) {} // NOLINT
HiFormula(const Formula& phi) : phi_(phi.Clone()) {} // NOLINT
operator Formula::Ref&() { return phi_; }
operator const Formula::Ref&() const { return phi_; }
operator Formula&() { return phi(); }
operator const Formula&() const { return phi(); }
Formula& phi() { return *phi_; }
const Formula& phi() const { return *phi_; }
Formula::Ref& operator->() { return phi_; }
const Formula::Ref& operator->() const { return phi_; }
Formula::Ref operator*() { return std::move(phi_); }
Clause as_clause() const {
internal::Maybe<Clause> c = phi_->AsUnivClause();
assert(c);
return c.val;
}
private:
Formula::Ref phi_;
};
class Context {
public:
Context() : solver_(sf(), tf()) {}
Symbol::Sort CreateNonrigidSort() {
return sf()->CreateNonrigidSort();
}
Symbol::Sort CreateRigidSort() {
return sf()->CreateRigidSort();
}
HiTerm CreateName(Symbol::Sort sort) {
return HiTerm(tf()->CreateTerm(sf()->CreateName(sort)));
}
HiTerm CreateVariable(Symbol::Sort sort) {
return HiTerm(tf()->CreateTerm(sf()->CreateVariable(sort)));
}
HiSymbol CreateFunction(Symbol::Sort sort, Symbol::Arity arity) {
return HiSymbol(tf(), sf()->CreateFunction(sort, arity));
}
void AddClause(const Formula& phi) {
Formula::Ref psi = phi.NF(sf(), tf());
internal::Maybe<Clause> c = psi->AsUnivClause();
assert(c);
solver_.grounder().AddClause(c.val);
}
void AddClause(const Clause& c) {
solver_.grounder().AddClause(c);
}
Solver* solver() { return &solver_; }
const Solver& solver() const { return solver_; }
Symbol::Factory* sf() { return Symbol::Factory::Instance(); }
Term::Factory* tf() { return Term::Factory::Instance(); }
private:
Solver solver_;
};
inline HiFormula operator==(HiTerm t1, HiTerm t2) { return HiFormula(Literal::Eq(t1, t2)); }
inline HiFormula operator!=(HiTerm t1, HiTerm t2) { return HiFormula(Literal::Neq(t1, t2)); }
inline HiFormula operator~(const HiFormula& phi) { return Formula::Factory::Not(phi.phi().Clone()); }
inline HiFormula operator!(const HiFormula& phi) { return ~phi; }
inline HiFormula operator||(const HiFormula& phi, const HiFormula& psi) {
return Formula::Factory::Or(phi.phi().Clone(), psi.phi().Clone()); }
inline HiFormula operator&&(const HiFormula& phi, const HiFormula& psi) { return ~(~phi || ~psi); }
inline HiFormula operator>>(const HiFormula& phi, const HiFormula& psi) { return (~phi || psi); }
inline HiFormula operator<<(const HiFormula& phi, const HiFormula& psi) { return (phi || ~psi); }
inline HiFormula operator==(const HiFormula& phi, const HiFormula& psi) { return (phi >> psi) && (phi << psi); }
inline HiFormula Ex(HiTerm x, const HiFormula& phi) { return Formula::Factory::Exists(x, phi.phi().Clone()); }
inline HiFormula Fa(HiTerm x, const HiFormula& phi) { return ~Ex(x, ~phi); }
} // namespace cpp
} // namespace format
} // namespace limbo
#endif // LIMBO_FORMAT_CPP_SYNTAX_H_
| 31.07971 | 112 | 0.667755 |
836de53d18cc730123fc0b31ab4694ead6d5029e | 18,281 | c | C | picoquictest/sacktest.c | Dmytry/picoquic | ae81b77ca69145f8bfedaf7177517a0e1876b3cc | [
"MIT"
] | 1 | 2021-12-25T17:06:24.000Z | 2021-12-25T17:06:24.000Z | picoquictest/sacktest.c | Dmytry/picoquic | ae81b77ca69145f8bfedaf7177517a0e1876b3cc | [
"MIT"
] | null | null | null | picoquictest/sacktest.c | Dmytry/picoquic | ae81b77ca69145f8bfedaf7177517a0e1876b3cc | [
"MIT"
] | null | null | null | /*
* Author: Christian Huitema
* Copyright (c) 2017, Private Octopus, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 Private Octopus, Inc. 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.
*/
#include "picoquic_internal.h"
#include <stdlib.h>
#include <string.h>
/*
* Test of the SACK functionality
*/
static const uint64_t test_pn64[] = {
3, 4, 0, 2, 7, 8, 11, 12, 13, 17, 19, 21, 18, 16, 20, 10, 5, 6, 9, 1, 14, 15
};
static const size_t nb_test_pn64 = sizeof(test_pn64) / sizeof(uint64_t);
struct expected_ack_t {
uint64_t highest_received;
uint64_t last_range;
uint8_t num_blocks;
};
static struct expected_ack_t expected_ack[] = {
{ 3, 0, 0 },
{ 4, 1, 0 },
{ 4, 1, 1 },
{ 4, 2, 1 },
{ 7, 0, 2 },
{ 8, 1, 2 },
{ 11, 0, 3 },
{ 12, 1, 2 },
{ 13, 2, 1 },
{ 17, 0, 2 },
{ 19, 0, 2 },
{ 21, 0, 3 },
{ 21, 0, 2 },
{ 21, 0, 1 },
{ 21, 5, 0 },
{ 21, 5, 1 },
{ 21, 5, 2 },
{ 21, 5, 2 },
{ 21, 5, 1 },
{ 21, 5, 1 },
{ 21, 5, 1 },
{ 21, 21, 0 }
};
int check_ack_ranges(picoquic_sack_list_t* sack_list)
{
int ret = 0;
for (int r = 0; r < 2; r++) {
int range_sum[PICOQUIC_MAX_ACK_RANGE_REPEAT] = { 0 };
picoquic_sack_item_t* sack = picoquic_sack_first_item(sack_list);
while (sack != NULL) {
if (sack->nb_times_sent[r] < 0) {
ret = -1;
break;
}
else if (sack->nb_times_sent[r] < PICOQUIC_MAX_ACK_RANGE_REPEAT) {
range_sum[sack->nb_times_sent[r]] += 1;
}
sack = picoquic_sack_next_item(sack);
}
for (int i = 0; ret == 0 && i < PICOQUIC_MAX_ACK_RANGE_REPEAT; i++) {
if (sack_list->rc[r].range_counts[i] != range_sum[i]) {
ret = -1;
}
}
}
return ret;
}
int sacktest()
{
int ret = 0;
picoquic_cnx_t cnx;
uint64_t current_time = 0;
uint64_t highest_seen = 0;
uint64_t highest_seen_time = 0;
picoquic_packet_context_enum pc = 0;
memset(&cnx, 0, sizeof(cnx));
ret = picoquic_sack_list_init(&cnx.ack_ctx[pc].sack_list);
/* Do a basic test with packet zero */
if (picoquic_is_pn_already_received(&cnx, pc,
cnx.local_cnxid_first, 0) != 0) {
ret = -1;
}
else if (picoquic_record_pn_received(&cnx, pc, cnx.local_cnxid_first,
0, current_time) != 0) {
ret = -1;
}
else if (picoquic_is_pn_already_received(&cnx, pc,
cnx.local_cnxid_first, 0) == 0) {
ret = -1;
}
else if (picoquic_sack_list_first(&cnx.ack_ctx[pc].sack_list) != 0 ||
picoquic_sack_list_last(&cnx.ack_ctx[pc].sack_list) != 0 ||
picoquic_sack_list_first_range(&cnx.ack_ctx[pc].sack_list) != NULL) {
ret = -1;
}
else {
/* reset for the next test */
picoquic_sack_list_free(&cnx.ack_ctx[pc].sack_list);
memset(&cnx, 0, sizeof(cnx));
picoquic_sack_list_init(&cnx.ack_ctx[pc].sack_list);
}
if (ret == 0) {
ret = check_ack_ranges(&cnx.ack_ctx[pc].sack_list);
}
for (size_t i = 0; ret == 0 && i < nb_test_pn64; i++) {
current_time = ((uint64_t)i) * 100 + 1;
if (test_pn64[i] > highest_seen) {
highest_seen = test_pn64[i];
highest_seen_time = current_time;
}
if (picoquic_record_pn_received(&cnx, pc, cnx.local_cnxid_first, test_pn64[i], current_time) != 0) {
ret = -1;
}
if (ret == 0) {
ret = check_ack_ranges(&cnx.ack_ctx[pc].sack_list);
}
for (size_t j = 0; ret == 0 && j <= i; j++) {
if (picoquic_is_pn_already_received(&cnx, pc,
cnx.local_cnxid_first, test_pn64[j]) == 0) {
ret = -1;
}
if (picoquic_record_pn_received(&cnx, pc, cnx.local_cnxid_first, test_pn64[j], current_time) != 1) {
ret = -1;
}
}
for (size_t j = i + 1; ret == 0 && j < nb_test_pn64; j++) {
if (picoquic_is_pn_already_received(&cnx, pc,
cnx.local_cnxid_first, test_pn64[j]) != 0) {
ret = -1;
}
}
}
if (ret == 0) {
if (picoquic_sack_list_last(&cnx.ack_ctx[pc].sack_list) != 21 ||
picoquic_sack_list_first(&cnx.ack_ctx[pc].sack_list) != 0 ||
cnx.ack_ctx[pc].time_stamp_largest_received != highest_seen_time ||
picoquic_sack_list_first_range(&cnx.ack_ctx[pc].sack_list) != NULL) {
ret = -1;
}
}
/* Free the sack lists*/
picoquic_sack_list_free(&cnx.ack_ctx[pc].sack_list);
return ret;
}
static void ack_range_mask(uint64_t* mask, uint64_t highest, uint64_t range)
{
for (uint64_t i = 0; i < range; i++) {
*mask |= 1ull << (highest & 63);
highest--;
}
}
static int basic_ack_parse(uint8_t* bytes, size_t bytes_max,
struct expected_ack_t* expected_ack, uint64_t * previous_mask, uint64_t expected_mask)
{
int ret = 0;
size_t byte_index = 1;
uint8_t first_byte = bytes[0];
uint64_t num_block = 0;
uint64_t largest = 0;
uint64_t last_range = 0;
uint64_t ack_range = 0;
uint64_t acked_mask = 0;
uint64_t gap_begin = 0;
size_t l_largest = 0;
size_t l_delay = 0;
size_t l_num_block = 0;
size_t l_last_range = 0;
if (first_byte != picoquic_frame_type_ack) {
ret = -1;
} else {
/* Largest */
if (byte_index < bytes_max) {
l_largest = picoquic_varint_decode(bytes + byte_index, bytes_max - byte_index, &largest);
byte_index += l_largest;
}
/* ACK delay */
if (byte_index < bytes_max) {
l_delay = picoquic_varint_skip(bytes + byte_index);
byte_index += l_delay;
}
/* Num blocks */
if (byte_index < bytes_max) {
l_num_block = picoquic_varint_decode(bytes + byte_index, bytes_max - byte_index, &num_block);
byte_index += l_num_block;
}
/* last range */
if (byte_index < bytes_max) {
l_last_range = picoquic_varint_decode(bytes + byte_index, bytes_max - byte_index, &last_range);
byte_index += l_last_range;
}
if (l_largest == 0 || l_delay == 0 || l_num_block == 0 || l_last_range == 0 || byte_index > bytes_max) {
ret = -1;
} else {
if (last_range <= largest) {
ack_range_mask(&acked_mask, largest, last_range + 1);
gap_begin = largest - last_range - 1;
} else {
ret = -1;
}
for (int i = 0; ret == 0 && i < num_block; i++) {
size_t l_gap = 0;
size_t l_range = 0;
uint64_t gap = 0;
/* Decode the gap */
if (byte_index < bytes_max) {
l_gap = picoquic_varint_decode(bytes + byte_index, bytes_max - byte_index, &gap);
byte_index += l_gap;
gap += 1;
}
/* decode the range */
if (byte_index < bytes_max) {
l_range = picoquic_varint_decode(bytes + byte_index, bytes_max - byte_index, &ack_range);
byte_index += l_range;
}
if (l_gap == 0 || l_range == 0) {
ret = -1;
} else if (gap > gap_begin) {
ret = -1;
} else {
gap_begin -= gap;
if (gap_begin >= ack_range) {
/* mark the range as received */
ack_range_mask(&acked_mask, gap_begin, ++ack_range);
/* start of next gap */
gap_begin -= ack_range;
} else {
ret = -1;
}
}
}
}
if (ret == 0) {
if (byte_index != bytes_max) {
ret = -1;
}
}
if (ret == 0) {
if (largest != expected_ack->highest_received || last_range != expected_ack->last_range || num_block != expected_ack->num_blocks) {
ret = -1;
}
}
if (ret == 0) {
acked_mask |= *previous_mask;
if (acked_mask != expected_mask) {
ret = -1;
}
*previous_mask = acked_mask;
}
}
return ret;
}
int sendacktest()
{
int ret = 0;
picoquic_cnx_t cnx;
uint64_t current_time;
uint64_t received_mask = 0;
uint64_t previous_mask = 0;
uint8_t bytes[256];
picoquic_packet_context_enum pc = 0;
memset(&cnx, 0, sizeof(cnx));
picoquic_sack_list_init(&cnx.ack_ctx[pc].sack_list);
cnx.sending_ecn_ack = 0; /* don't write an ack_ecn frame */
if (check_ack_ranges(&cnx.ack_ctx[pc].sack_list) != 0) {
ret = -1;
}
for (size_t i = 0; ret == 0 && i < nb_test_pn64; i++) {
current_time = ((uint64_t)i) * 100;
if (picoquic_record_pn_received(&cnx, pc, cnx.local_cnxid_first, test_pn64[i], current_time) != 0) {
ret = -1;
}
if (check_ack_ranges(&cnx.ack_ctx[pc].sack_list) != 0) {
ret = -1;
}
if (ret == 0) {
int more_data = 0;
uint8_t* bytes_next = picoquic_format_ack_frame(&cnx, bytes, bytes + sizeof(bytes), &more_data, 0, pc, 0);
received_mask |= 1ull << (test_pn64[i] & 63);
if (check_ack_ranges(&cnx.ack_ctx[pc].sack_list) != 0) {
ret = -1;
}
if (ret == 0) {
ret = basic_ack_parse(bytes, bytes_next - bytes, &expected_ack[i], &previous_mask, received_mask);
}
if (ret != 0) {
ret = -1; /* useless code, but helps with checkpointing */
}
}
}
picoquic_sack_list_free(&cnx.ack_ctx[pc].sack_list);
return ret;
}
typedef struct st_test_ack_range_t {
uint64_t range_min;
uint64_t range_max;
} test_ack_range_t;
static const test_ack_range_t ack_range[] = {
{ 1, 1000 },
{ 0, 0 },
{ 3001, 4000 },
{ 4001, 5000 },
{ 6001, 7000 },
{ 5001, 6000 },
{ 1501, 2500 },
{ 501, 1500 },
{ 501, 7500 }
};
static const size_t nb_ack_range = sizeof(ack_range) / sizeof(test_ack_range_t);
int ackrange_test()
{
int ret = 0;
picoquic_sack_list_t sack0;
ret = picoquic_sack_list_init(&sack0);
for (size_t i = 0; ret == 0 && i < nb_ack_range; i++) {
ret = picoquic_check_sack_list(&sack0,
ack_range[i].range_min, ack_range[i].range_max);
if (ret == 0) {
ret = picoquic_update_sack_list(&sack0,
ack_range[i].range_min, ack_range[i].range_max, 0);
}
if (ret == 0) {
ret = check_ack_ranges(&sack0);
}
for (size_t j = 0; j < i; j++) {
if (picoquic_check_sack_list(&sack0,
ack_range[j].range_min, ack_range[j].range_max)
== 0) {
ret = -1;
break;
}
}
if (ret != 0) {
break;
}
}
if (ret == 0 && picoquic_sack_list_first(&sack0) != 0) {
ret = -1;
}
if (ret == 0 && picoquic_sack_list_last(&sack0)!= 7500) {
ret = -1;
}
if (ret == 0 && picoquic_sack_list_first_range(&sack0) != NULL) {
ret = -1;
}
picoquic_sack_list_free(&sack0);
return ret;
}
/* Examine what happens when the packets are received in disorder. In this test, even packets (0, 2..)
* are received through a high latency path, odd packets (1..3) through a low latency path, and the
* ack-of-ack is sent after 32 packets are received. The goal is to verify that ack ranges are
* retained long enough to allow for coalescing. We measure the maximum nimber of ack ranges in the mix.
*
* The "horizon" variant studies what happens when setting an "horizon" under which ack ranges shall
* be kept, in order to allow merging of ranges.
*/
#define ACK_DISORDER_LOG "ack_disorder_test.csv"
#define ACK_HORIZON_LOG "ack_horizon_test.csv"
typedef struct st_ack_disorder_ackk_t {
uint64_t pn;
uint64_t arrive_time;
uint64_t ackk_time;
size_t nb_ranges_arrive;
size_t nb_ranges_ack;
size_t nb_acked;
} ack_disorder_ackk_t;
int ack_disorder_receive_pn(picoquic_sack_list_t * sack0,
uint64_t pn, uint64_t next_time, uint64_t ack_interval,
size_t * nb_ackk, size_t nb_ranges, ack_disorder_ackk_t* ackk_list)
{
int ret = 0;
if (picoquic_update_sack_list(sack0, pn, pn, next_time) != 0) {
ret = -1;
}
else if (*nb_ackk >= nb_ranges){
ret = -1;
}
else {
ackk_list[*nb_ackk].pn = pn;
ackk_list[*nb_ackk].arrive_time = next_time;
ackk_list[*nb_ackk].ackk_time = next_time + ack_interval;
ackk_list[*nb_ackk].nb_ranges_arrive = picoquic_sack_list_size(sack0);
ackk_list[*nb_ackk].nb_ranges_ack = 0;
*nb_ackk += 1;
}
return ret;
}
int ack_disorder_test_one(char const * log_name, int64_t horizon_delay, double range_average_max)
{
size_t const nb_ranges = 1000;
size_t const nb_even_ranges = nb_ranges / 2;
size_t const nb_odd_ranges = nb_ranges - nb_even_ranges;
uint64_t const low_latency = 11111;
uint64_t const high_latency = 300000;
uint64_t const ack_interval = 100000;
uint64_t const packet_interval = 1000;
ack_disorder_ackk_t* ackk_list = (ack_disorder_ackk_t*)malloc(nb_ranges * sizeof(ack_disorder_ackk_t));
size_t nb_ackk = 0;
size_t i_ackk = 0;
size_t i_even_arrive = 0;
size_t i_odd_arrive = 0;
uint64_t t_even_arrive = low_latency;
uint64_t t_odd_arrive = packet_interval + high_latency;
uint64_t pn;
int ret = 0;
picoquic_sack_list_t sack0;
/* Initialize the test sack list */
if (ackk_list == NULL) {
ret = -1;
}
else {
ret = picoquic_sack_list_init(&sack0);
}
sack0.horizon_delay = horizon_delay;
/* Run a loop to simulate arrival of packets and ack of ack */
while (ret == 0 && (i_even_arrive < nb_even_ranges || i_odd_arrive < nb_odd_ranges || i_ackk < nb_ackk)) {
uint64_t next_time = UINT64_MAX;
int i_action = -1; /* by default do odd arrival */
if (i_odd_arrive < nb_odd_ranges) {
i_action = 0;
next_time = t_odd_arrive;
}
if (i_even_arrive < nb_even_ranges && t_even_arrive < next_time) {
i_action = 1;
next_time = t_even_arrive;
}
if (i_ackk < nb_ackk && ackk_list[i_ackk].ackk_time < next_time) {
i_action = 2;
next_time = ackk_list[i_ackk].ackk_time;
}
switch (i_action) {
case 0: /* arrival on odd path */
pn = 2 * i_odd_arrive + 1;
i_odd_arrive++;
t_odd_arrive += packet_interval;
if (ack_disorder_receive_pn(&sack0, pn, next_time, ack_interval, &nb_ackk, nb_ranges, ackk_list) != 0) {
ret = -1;
}
break;
case 1: /* arrival on even path */
pn = 2 * i_even_arrive;
i_even_arrive++;
t_even_arrive += packet_interval;
if (ack_disorder_receive_pn(&sack0, pn, next_time, ack_interval, &nb_ackk, nb_ranges, ackk_list) != 0) {
ret = -1;
}
break;
case 2: /* ack of ack */
(void)picoquic_process_ack_of_ack_range(&sack0, NULL, ackk_list[i_ackk].pn, ackk_list[i_ackk].pn);
ackk_list[i_ackk].nb_ranges_ack = picoquic_sack_list_size(&sack0);
i_ackk++;
break;
}
}
if (ret == 0) {
FILE* F = picoquic_file_open(log_name, "w");
if (F == NULL) {
ret = -1;
}
else {
fprintf(F, "pn,arrive_time,ackk_time,nb_ranges_arrive,nb_ranges_ack\n");
for (size_t i = 0; i < nb_ackk; i++) {
(void)fprintf(F, "%"PRIu64 ", %"PRIu64 ", %"PRIu64 ", %zu, %zu\n",
ackk_list[i].pn, ackk_list[i].arrive_time, ackk_list[i].ackk_time,
ackk_list[i].nb_ranges_arrive, ackk_list[i].nb_ranges_ack);
}
(void) picoquic_file_close(F);
}
}
if (ret == 0) {
/* Compute average number of ACK frames at ACK time */
uint64_t sum_ranges_ack = 0;
double range_average;
for (size_t i = 0; i < nb_ackk; i++) {
sum_ranges_ack += ackk_list[i].nb_ranges_ack;
}
range_average = (double)sum_ranges_ack / (double)nb_ackk;
if (range_average > range_average_max) {
DBG_PRINTF("Got %f ranges, larger than expected %f", range_average, range_average_max);
ret = -1;
}
}
if (ackk_list != NULL) {
free(ackk_list);
}
picoquic_sack_list_free(&sack0);
return ret;
}
int ack_disorder_test()
{
int ret = ack_disorder_test_one(ACK_DISORDER_LOG, 0, 133.0);
return ret;
}
int ack_horizon_test()
{
int ret = ack_disorder_test_one(ACK_HORIZON_LOG, 1000000, 196.0);
return ret;
} | 30.116969 | 143 | 0.559762 |
836e6835096c6be599ffc84890d529b3efb20083 | 3,523 | c | C | examples/example_pause.c | ygj6/libevhtp | 3b4b728e502ae6749b9e6dc0e029d9865d68fd1f | [
"BSD-3-Clause"
] | null | null | null | examples/example_pause.c | ygj6/libevhtp | 3b4b728e502ae6749b9e6dc0e029d9865d68fd1f | [
"BSD-3-Clause"
] | null | null | null | examples/example_pause.c | ygj6/libevhtp | 3b4b728e502ae6749b9e6dc0e029d9865d68fd1f | [
"BSD-3-Clause"
] | null | null | null | /*
* Quick example of how to pause a request, and in this case, simply
* set a timer to emit the response 10 seconds later.
*
* This is a good way to long running tasks before responding (thus
* not blocking any other processing).
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include "internal.h"
#include "evhtp/evhtp.h"
#include "./eutils.h"
struct paused_request_ {
struct event * _timeoutev;
struct timeval _timeout;
evhtp_request_t * _request;
};
/* once 10 seconds has passed, this function is called, it will
* resume the request, and send the final response back to the
* client.
*/
static void
http_resume__callback_(int sock, short events, void * arg) {
struct paused_request_ * preq;
evhtp_request_t * req;
evhtp_assert(arg != NULL);
preq = (struct paused_request_ *)arg;
req = preq->_request;
evhtp_assert(req != NULL);
evhtp_safe_free(preq->_timeoutev, event_free);
evhtp_safe_free(preq, free);
/* inform the evhtp API to resume this connection request */
evhtp_request_resume(req);
/* add the current time to our output buffer to the client */
evbuffer_add_printf(req->buffer_out, "time end %ld\n", time(NULL));
/* finally send the response to the client, YAY! */
evhtp_send_reply(req, EVHTP_RES_OK);
}
/* this is our default callback, it is the one who sets up the evtimer
* that triggers the response after 10 seconds.
*/
static void
http_pause__callback_(evhtp_request_t * req, void * arg) {
struct timeval * tv = (struct timeval *)arg;
struct paused_request_ * preq;
/* allocate a little structure that holds our evtimer and the
* pending request, se the timeout to 10 seconds.
*/
preq = malloc(sizeof(*preq));
evhtp_alloc_assert(preq);
preq->_request = req;
preq->_timeout.tv_sec = tv->tv_sec;
preq->_timeout.tv_usec = tv->tv_usec;
/* when 10 seconds is up, the function http_resume__callback_ will
* be called, this function will actually send the response.
*/
preq->_timeoutev = evtimer_new(req->htp->evbase, http_resume__callback_, preq);
evhtp_alloc_assert(preq->_timeoutev);
/* just for debugging, add the time the request was first seen */
evbuffer_add_printf(req->buffer_out, "time start %ld\n", time(NULL));
/* add the timer to the event loop */
evtimer_add(preq->_timeoutev, &preq->_timeout);
/* notify the evhtp API to "pause" this request (meaning it will no
* longer do any work on this connection until it is "resumed".
*/
evhtp_request_pause(req);
}
int
main(int argc, char ** argv) {
int res;
evhtp_t * htp;
struct event_base * evbase;
struct timeval timeo = { 10, 0 };
#ifdef _WIN32
WSADATA wsaData;
(void)WSAStartup(0x0202, &wsaData);
#endif
evbase = event_base_new();
evhtp_alloc_assert(evbase);
htp = evhtp_new(evbase, NULL);
evhtp_alloc_assert(htp);
/* we just set the default callback for any requests to
* the function that pauses the session, sets a timer,
* and 10 seconds later, sends the response.
*/
evhtp_set_gencb(htp, http_pause__callback_, &timeo);
log_info("response delayed for 10s: "
"curl http://127.0.0.1:%d/", bind__sock_port0_(htp));
res = event_base_loop(evbase, 0);
#ifdef _WIN32
WSACleanup();
#endif
return res;
}
| 29.358333 | 89 | 0.663071 |
837085a949eab043b7d9ed44b8aab03bb174a124 | 241 | h | C | src/util.h | lloydroc/pibeets | 63fe5a179185e9ae643c299e0e159f4b5e50e55c | [
"MIT"
] | 1 | 2020-02-29T13:35:58.000Z | 2020-02-29T13:35:58.000Z | src/util.h | lloydroc/pibeets | 63fe5a179185e9ae643c299e0e159f4b5e50e55c | [
"MIT"
] | null | null | null | src/util.h | lloydroc/pibeets | 63fe5a179185e9ae643c299e0e159f4b5e50e55c | [
"MIT"
] | null | null | null | #ifndef UTIL_DEFINED
#define UTIL_DEFINED
#include<sys/time.h>
// Utility functions for the project
// Print the time it took for something to complete
void print_timetaken(char label[], struct timeval start, struct timeval end);
#endif
| 20.083333 | 77 | 0.775934 |
8371f7ea973c36258d1a1b0a26e841f55e0725ed | 536 | h | C | 3.3/Classes/BookmarkHelper.h | sonsongithub/museum2tch | 2808156d2511379cd7a30564a0f359b59f3164da | [
"BSD-3-Clause"
] | 16 | 2021-09-18T05:45:31.000Z | 2021-09-27T12:40:29.000Z | 3.3/Classes/BookmarkHelper.h | sonsongithub/museum2tch | 2808156d2511379cd7a30564a0f359b59f3164da | [
"BSD-3-Clause"
] | null | null | null | 3.3/Classes/BookmarkHelper.h | sonsongithub/museum2tch | 2808156d2511379cd7a30564a0f359b59f3164da | [
"BSD-3-Clause"
] | null | null | null | //
// BookmarkHelper.h
// 2tch
//
// Created by sonson on 08/12/06.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface BookmarkHelper : NSObject {
}
+ (void)insertThreadIntoBookmarkOfDat:(int)dat path:(NSString*)path;
+ (int)threadInfoOfDat:(int)dat path:(NSString*)path;
+ (BOOL)isInsertedThreadToBookmark:(int)bookmark_key;
+ (void)insertBoardIntoBookmarkOfPath:(NSString*)path;
+ (int)boardOfPath:(NSString*)path;
+ (BOOL)isInsertedBoardToBookmark:(int)bookmark_key;
@end
| 26.8 | 68 | 0.755597 |
8372618b5e52c09af74fab74895327d16ab91ec9 | 83,062 | c | C | libgifsicle/src/main/cpp/quantize.c | jastrelax/AndroidBricks | e4f47a8a3e88851556c5120b8fd94ebf499a9ec6 | [
"MIT"
] | 1 | 2020-08-12T21:23:24.000Z | 2020-08-12T21:23:24.000Z | libgifsicle/src/main/cpp/quantize.c | jastrelax/AndroidBricks | e4f47a8a3e88851556c5120b8fd94ebf499a9ec6 | [
"MIT"
] | null | null | null | libgifsicle/src/main/cpp/quantize.c | jastrelax/AndroidBricks | e4f47a8a3e88851556c5120b8fd94ebf499a9ec6 | [
"MIT"
] | null | null | null | /* quantize.c - Histograms and quantization for gifsicle.
Copyright (C) 1997-2019 Eddie Kohler, ekohler@gmail.com
This file is part of gifsicle.
Gifsicle is free software. It is distributed under the GNU Public License,
version 2; you can copy, distribute, or alter it at will, as long
as this notice is kept intact and this source code is made available. There
is no warranty, express or implied. */
#include <config.h>
#include "gifsicle.h"
#include "kcolor.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <math.h>
/* Invariant: (0<=x<256) ==> (srgb_revgamma[srgb_gamma[x] >> 7] <= x). */
static const uint16_t srgb_gamma_table_256[256] = {
0, 10, 20, 30, 40, 50, 60, 70,
80, 90, 99, 110, 120, 132, 144, 157,
170, 184, 198, 213, 229, 246, 263, 281,
299, 319, 338, 359, 380, 403, 425, 449,
473, 498, 524, 551, 578, 606, 635, 665,
695, 727, 759, 792, 825, 860, 895, 931,
968, 1006, 1045, 1085, 1125, 1167, 1209, 1252,
1296, 1341, 1386, 1433, 1481, 1529, 1578, 1629,
1680, 1732, 1785, 1839, 1894, 1950, 2007, 2065,
2123, 2183, 2244, 2305, 2368, 2432, 2496, 2562,
2629, 2696, 2765, 2834, 2905, 2977, 3049, 3123,
3198, 3273, 3350, 3428, 3507, 3587, 3668, 3750,
3833, 3917, 4002, 4088, 4176, 4264, 4354, 4444,
4536, 4629, 4723, 4818, 4914, 5011, 5109, 5209,
5309, 5411, 5514, 5618, 5723, 5829, 5936, 6045,
6154, 6265, 6377, 6490, 6604, 6720, 6836, 6954,
7073, 7193, 7315, 7437, 7561, 7686, 7812, 7939,
8067, 8197, 8328, 8460, 8593, 8728, 8863, 9000,
9139, 9278, 9419, 9560, 9704, 9848, 9994, 10140,
10288, 10438, 10588, 10740, 10893, 11048, 11204, 11360,
11519, 11678, 11839, 12001, 12164, 12329, 12495, 12662,
12831, 13000, 13172, 13344, 13518, 13693, 13869, 14047,
14226, 14406, 14588, 14771, 14955, 15141, 15328, 15516,
15706, 15897, 16089, 16283, 16478, 16675, 16872, 17071,
17272, 17474, 17677, 17882, 18088, 18295, 18504, 18714,
18926, 19138, 19353, 19569, 19786, 20004, 20224, 20445,
20668, 20892, 21118, 21345, 21573, 21803, 22034, 22267,
22501, 22736, 22973, 23211, 23451, 23692, 23935, 24179,
24425, 24672, 24920, 25170, 25421, 25674, 25928, 26184,
26441, 26700, 26960, 27222, 27485, 27749, 28016, 28283,
28552, 28823, 29095, 29368, 29643, 29920, 30197, 30477,
30758, 31040, 31324, 31610, 31897, 32185, 32475, 32767
};
static const uint16_t srgb_revgamma_table_256[256] = {
0, 1628, 2776, 3619, 4309, 4904, 5434, 5914,
6355, 6765, 7150, 7513, 7856, 8184, 8497, 8798,
9086, 9365, 9634, 9895, 10147, 10393, 10631, 10864,
11091, 11312, 11528, 11739, 11946, 12148, 12347, 12541,
12732, 12920, 13104, 13285, 13463, 13639, 13811, 13981,
14149, 14314, 14476, 14637, 14795, 14951, 15105, 15257,
15408, 15556, 15703, 15848, 15991, 16133, 16273, 16412,
16549, 16685, 16819, 16953, 17084, 17215, 17344, 17472,
17599, 17725, 17849, 17973, 18095, 18217, 18337, 18457,
18575, 18692, 18809, 18925, 19039, 19153, 19266, 19378,
19489, 19600, 19710, 19819, 19927, 20034, 20141, 20247,
20352, 20457, 20560, 20664, 20766, 20868, 20969, 21070,
21170, 21269, 21368, 21466, 21564, 21661, 21758, 21854,
21949, 22044, 22138, 22232, 22326, 22418, 22511, 22603,
22694, 22785, 22875, 22965, 23055, 23144, 23232, 23321,
23408, 23496, 23583, 23669, 23755, 23841, 23926, 24011,
24095, 24180, 24263, 24347, 24430, 24512, 24595, 24676,
24758, 24839, 24920, 25001, 25081, 25161, 25240, 25319,
25398, 25477, 25555, 25633, 25710, 25788, 25865, 25941,
26018, 26094, 26170, 26245, 26321, 26396, 26470, 26545,
26619, 26693, 26766, 26840, 26913, 26986, 27058, 27130,
27202, 27274, 27346, 27417, 27488, 27559, 27630, 27700,
27770, 27840, 27910, 27979, 28048, 28117, 28186, 28255,
28323, 28391, 28459, 28527, 28594, 28661, 28728, 28795,
28862, 28928, 28995, 29061, 29127, 29192, 29258, 29323,
29388, 29453, 29518, 29582, 29646, 29711, 29775, 29838,
29902, 29965, 30029, 30092, 30155, 30217, 30280, 30342,
30404, 30466, 30528, 30590, 30652, 30713, 30774, 30835,
30896, 30957, 31017, 31078, 31138, 31198, 31258, 31318,
31378, 31437, 31497, 31556, 31615, 31674, 31733, 31791,
31850, 31908, 31966, 32024, 32082, 32140, 32198, 32255,
32313, 32370, 32427, 32484, 32541, 32598, 32654, 32711
};
uint16_t* gamma_tables[2] = {
(uint16_t*) srgb_gamma_table_256,
(uint16_t*) srgb_revgamma_table_256
};
#if ENABLE_THREADS
pthread_mutex_t kd3_sort_lock;
#endif
const char* kc_debug_str(kcolor x) {
static int whichbuf = 0;
static char buf[4][32];
whichbuf = (whichbuf + 1) % 4;
if (x.a[0] >= 0 && x.a[1] >= 0 && x.a[2] >= 0) {
kc_revgamma_transform(&x);
sprintf(buf[whichbuf], "#%02X%02X%02X",
x.a[0] >> 7, x.a[1] >> 7, x.a[2] >> 7);
} else
sprintf(buf[whichbuf], "<%d,%d,%d>", x.a[0], x.a[1], x.a[2]);
return buf[whichbuf];
}
void kc_set_gamma(int type, double gamma) {
#if HAVE_POW
static int cur_type = KC_GAMMA_SRGB;
static double cur_gamma = 2.2;
int i, j;
if (type == cur_type && (type != KC_GAMMA_NUMERIC || gamma == cur_gamma))
return;
if (type == KC_GAMMA_SRGB) {
if (gamma_tables[0] != srgb_gamma_table_256) {
Gif_DeleteArray(gamma_tables[0]);
Gif_DeleteArray(gamma_tables[1]);
}
gamma_tables[0] = (uint16_t*) srgb_gamma_table_256;
gamma_tables[1] = (uint16_t*) srgb_revgamma_table_256;
} else {
if (gamma_tables[0] == srgb_gamma_table_256) {
gamma_tables[0] = Gif_NewArray(uint16_t, 256);
gamma_tables[1] = Gif_NewArray(uint16_t, 256);
}
for (j = 0; j != 256; ++j) {
gamma_tables[0][j] = (int) (pow(j/255.0, gamma) * 32767 + 0.5);
gamma_tables[1][j] = (int) (pow(j/256.0, 1/gamma) * 32767 + 0.5);
/* The ++gamma_tables[][] ensures that round-trip gamma correction
always preserve the input colors. Without it, one might have,
for example, input values 0, 1, and 2 all mapping to
gamma-corrected value 0. Then a round-trip through gamma
correction loses information.
*/
for (i = 0; i != 2; ++i)
while (j && gamma_tables[i][j] <= gamma_tables[i][j-1]
&& gamma_tables[i][j] < 32767)
++gamma_tables[i][j];
}
}
cur_type = type;
cur_gamma = gamma;
#else
(void) type, (void) gamma;
#endif
}
void kc_revgamma_transform(kcolor* x) {
int d;
for (d = 0; d != 3; ++d) {
int c = gamma_tables[1][x->a[d] >> 7];
while (c < 0x7F80 && x->a[d] >= gamma_tables[0][(c + 0x80) >> 7])
c += 0x80;
x->a[d] = c;
}
}
#if 0
static void kc_test_gamma() {
int x, y, z;
for (x = 0; x != 256; ++x)
for (y = 0; y != 256; ++y)
for (z = 0; z != 256; ++z) {
kcolor k;
kc_set8g(&k, x, y, z);
kc_revgamma_transform(&k);
if ((k.a[0] >> 7) != x || (k.a[1] >> 7) != y
|| (k.a[2] >> 7) != z) {
kcolor kg;
kc_set8g(&kg, x, y, z);
fprintf(stderr, "#%02X%02X%02X ->g #%04X%04X%04X ->revg #%02X%02X%02X!\n",
x, y, z, kg.a[0], kg.a[1], kg.a[2],
k.a[0] >> 7, k.a[1] >> 7, k.a[2] >> 7);
assert(0);
}
}
}
#endif
static int kchist_sizes[] = {
4093, 16381, 65521, 262139, 1048571, 4194301, 16777213,
67108859, 268435459, 1073741839
};
static void kchist_grow(kchist* kch);
void kchist_init(kchist* kch) {
int i;
kch->h = Gif_NewArray(kchistitem, kchist_sizes[0]);
kch->n = 0;
kch->capacity = kchist_sizes[0];
for (i = 0; i != kch->capacity; ++i)
kch->h[i].count = 0;
}
void kchist_cleanup(kchist* kch) {
Gif_DeleteArray(kch->h);
kch->h = NULL;
}
kchistitem* kchist_add(kchist* kch, kcolor k, kchist_count_t count) {
unsigned hash1, hash2 = 0;
kacolor ka;
kchistitem *khi;
ka.k = k;
ka.a[3] = 0;
if (!kch->capacity
|| kch->n > ((kch->capacity * 3) >> 4))
kchist_grow(kch);
hash1 = (((ka.a[0] & 0x7FE0) << 15)
| ((ka.a[1] & 0x7FE0) << 5)
| ((ka.a[2] & 0x7FE0) >> 5)) % kch->capacity;
while (1) {
khi = &kch->h[hash1];
if (!khi->count
|| memcmp(&khi->ka, &ka, sizeof(ka)) == 0)
break;
if (!hash2) {
hash2 = (((ka.a[0] & 0x03FF) << 20)
| ((ka.a[1] & 0x03FF) << 10)
| (ka.a[2] & 0x03FF)) % kch->capacity;
hash2 = hash2 ? hash2 : 1;
}
hash1 += hash2;
if (hash1 >= (unsigned) kch->capacity)
hash1 -= kch->capacity;
}
if (!khi->count) {
khi->ka = ka;
++kch->n;
}
khi->count += count;
if (khi->count < count)
khi->count = (kchist_count_t) -1;
return khi;
}
static void kchist_grow(kchist* kch) {
kchistitem* oldh = kch->h;
int i, oldcapacity = kch->capacity ? kch->capacity : kch->n;
for (i = 0; kchist_sizes[i] <= oldcapacity; ++i)
/* do nothing */;
kch->capacity = kchist_sizes[i];
kch->h = Gif_NewArray(kchistitem, kch->capacity);
kch->n = 0;
for (i = 0; i != kch->capacity; ++i)
kch->h[i].count = 0;
for (i = 0; i != oldcapacity; ++i)
if (oldh[i].count)
kchist_add(kch, oldh[i].ka.k, oldh[i].count);
Gif_DeleteArray(oldh);
}
void kchist_compress(kchist* kch) {
int i, j;
for (i = 0, j = kch->n; i != kch->n; )
if (kch->h[i].count)
++i;
else if (kch->h[j].count) {
kch->h[i] = kch->h[j];
++i, ++j;
} else
++j;
kch->capacity = 0;
}
void kchist_make(kchist* kch, Gif_Stream* gfs, uint32_t* ntransp_store) {
uint32_t gcount[256], lcount[256];
uint32_t nbackground = 0, ntransparent = 0;
int x, y, i, imagei;
kchist_init(kch);
for (i = 0; i != 256; ++i)
gcount[i] = 0;
/* Count pixels */
for (imagei = 0; imagei < gfs->nimages; ++imagei) {
Gif_Image* gfi = gfs->images[imagei];
Gif_Colormap* gfcm = gfi->local ? gfi->local : gfs->global;
uint32_t* count = gfi->local ? lcount : gcount;
uint32_t old_transparent_count = 0;
int only_compressed = (gfi->img == 0);
if (!gfcm)
continue;
if (count == lcount)
for (i = 0; i != 256; ++i)
count[i] = 0;
if (gfi->transparent >= 0)
old_transparent_count = count[gfi->transparent];
/* unoptimize the image if necessary */
if (only_compressed)
Gif_UncompressImage(gfs, gfi);
/* sweep over the image data, counting pixels */
for (y = 0; y < gfi->height; ++y) {
const uint8_t* data = gfi->img[y];
for (x = 0; x < gfi->width; ++x, ++data)
++count[*data];
}
/* add counted colors to global histogram (local only) */
if (gfi->local)
for (i = 0; i != gfcm->ncol; ++i)
if (count[i] && i != gfi->transparent)
kchist_add(kch, kc_makegfcg(&gfcm->col[i]), count[i]);
if (gfi->transparent >= 0
&& count[gfi->transparent] != old_transparent_count) {
ntransparent += count[gfi->transparent] - old_transparent_count;
count[gfi->transparent] = old_transparent_count;
}
/* if this image has background disposal, count its size towards the
background's pixel count */
if (gfi->disposal == GIF_DISPOSAL_BACKGROUND)
nbackground += (unsigned) gfi->width * (unsigned) gfi->height;
/* throw out compressed image if necessary */
if (only_compressed)
Gif_ReleaseUncompressedImage(gfi);
}
if (gfs->images[0]->transparent < 0
&& gfs->global && gfs->background < gfs->global->ncol)
gcount[gfs->background] += nbackground;
else
ntransparent += nbackground;
if (gfs->global)
for (i = 0; i != gfs->global->ncol; ++i)
if (gcount[i])
kchist_add(kch, kc_makegfcg(&gfs->global->col[i]), gcount[i]);
/* now, make the linear histogram from the hashed histogram */
kchist_compress(kch);
*ntransp_store = ntransparent;
}
static int red_kchistitem_compare(const void* va, const void* vb) {
const kchistitem* a = (const kchistitem*) va;
const kchistitem* b = (const kchistitem*) vb;
return a->ka.a[0] - b->ka.a[0];
}
static int green_kchistitem_compare(const void* va, const void* vb) {
const kchistitem* a = (const kchistitem*) va;
const kchistitem* b = (const kchistitem*) vb;
return a->ka.a[1] - b->ka.a[1];
}
static int blue_kchistitem_compare(const void* va, const void* vb) {
const kchistitem* a = (const kchistitem*) va;
const kchistitem* b = (const kchistitem*) vb;
return a->ka.a[2] - b->ka.a[2];
}
static int popularity_kchistitem_compare(const void* va, const void* vb) {
const kchistitem* a = (const kchistitem*) va;
const kchistitem* b = (const kchistitem*) vb;
return a->count > b->count ? -1 : a->count != b->count;
}
static int popularity_sort_compare(const void* va, const void* vb) {
const Gif_Color* a = (const Gif_Color*) va;
const Gif_Color* b = (const Gif_Color*) vb;
return a->pixel > b->pixel ? -1 : a->pixel != b->pixel;
}
/* COLORMAP FUNCTIONS return a palette (a vector of Gif_Colors). The
pixel fields are undefined; the haspixel fields are all 0. */
typedef struct {
int first;
int size;
uint32_t pixel;
} adaptive_slot;
Gif_Colormap* colormap_median_cut(kchist* kch, Gt_OutputData* od)
{
int adapt_size = od->colormap_size;
adaptive_slot *slots = Gif_NewArray(adaptive_slot, adapt_size);
Gif_Colormap *gfcm = Gif_NewFullColormap(adapt_size, 256);
Gif_Color *adapt = gfcm->col;
int nadapt;
int i, j, k;
/* This code was written with reference to ppmquant by Jef Poskanzer,
part of the pbmplus package. */
if (adapt_size < 2 || adapt_size > 256)
fatal_error("adaptive palette size must be between 2 and 256");
if (adapt_size >= kch->n && !od->colormap_fixed)
warning(1, "trivial adaptive palette (only %d %s in source)",
kch->n, kch->n == 1 ? "color" : "colors");
if (adapt_size >= kch->n)
adapt_size = kch->n;
/* 0. remove any transparent color from consideration; reduce adaptive
palette size to accommodate transparency if it looks like that'll be
necessary */
if (adapt_size > 2 && adapt_size < kch->n && kch->n <= 265
&& od->colormap_needs_transparency)
adapt_size--;
/* 1. set up the first slot, containing all pixels. */
slots[0].first = 0;
slots[0].size = kch->n;
slots[0].pixel = 0;
for (i = 0; i < kch->n; i++)
slots[0].pixel += kch->h[i].count;
/* 2. split slots until we have enough. */
for (nadapt = 1; nadapt < adapt_size; nadapt++) {
adaptive_slot *split = 0;
kcolor minc, maxc;
kchistitem *slice;
/* 2.1. pick the slot to split. */
{
uint32_t split_pixel = 0;
for (i = 0; i < nadapt; i++)
if (slots[i].size >= 2 && slots[i].pixel > split_pixel) {
split = &slots[i];
split_pixel = slots[i].pixel;
}
if (!split)
break;
}
slice = &kch->h[split->first];
/* 2.2. find its extent. */
{
kchistitem *trav = slice;
minc = maxc = trav->ka.k;
for (i = 1, trav++; i < split->size; i++, trav++)
for (k = 0; k != 3; ++k) {
minc.a[k] = min(minc.a[k], trav->ka.a[k]);
maxc.a[k] = max(maxc.a[k], trav->ka.a[k]);
}
}
/* 2.3. decide how to split it. use the luminance method. also sort
the colors. */
{
double red_diff = 0.299 * (maxc.a[0] - minc.a[0]);
double green_diff = 0.587 * (maxc.a[1] - minc.a[1]);
double blue_diff = 0.114 * (maxc.a[2] - minc.a[2]);
if (red_diff >= green_diff && red_diff >= blue_diff)
qsort(slice, split->size, sizeof(kchistitem), red_kchistitem_compare);
else if (green_diff >= blue_diff)
qsort(slice, split->size, sizeof(kchistitem), green_kchistitem_compare);
else
qsort(slice, split->size, sizeof(kchistitem), blue_kchistitem_compare);
}
/* 2.4. decide where to split the slot and split it there. */
{
uint32_t half_pixels = split->pixel / 2;
uint32_t pixel_accum = slice[0].count;
uint32_t diff1, diff2;
for (i = 1; i < split->size - 1 && pixel_accum < half_pixels; i++)
pixel_accum += slice[i].count;
/* We know the area before the split has more pixels than the
area after, possibly by a large margin (bad news). If it
would shrink the margin, change the split. */
diff1 = 2*pixel_accum - split->pixel;
diff2 = split->pixel - 2*(pixel_accum - slice[i-1].count);
if (diff2 < diff1 && i > 1) {
i--;
pixel_accum -= slice[i].count;
}
slots[nadapt].first = split->first + i;
slots[nadapt].size = split->size - i;
slots[nadapt].pixel = split->pixel - pixel_accum;
split->size = i;
split->pixel = pixel_accum;
}
}
/* 3. make the new palette by choosing one color from each slot. */
for (i = 0; i < nadapt; i++) {
double px[3];
kchistitem* slice = &kch->h[ slots[i].first ];
kcolor kc;
px[0] = px[1] = px[2] = 0;
for (j = 0; j != slots[i].size; ++j)
for (k = 0; k != 3; ++k)
px[k] += slice[j].ka.a[k] * (double) slice[j].count;
kc.a[0] = (int) (px[0] / slots[i].pixel);
kc.a[1] = (int) (px[1] / slots[i].pixel);
kc.a[2] = (int) (px[2] / slots[i].pixel);
adapt[i] = kc_togfcg(&kc);
}
Gif_DeleteArray(slots);
gfcm->ncol = nadapt;
return gfcm;
}
void kcdiversity_init(kcdiversity* div, kchist* kch, int dodither) {
int i;
div->kch = kch;
qsort(kch->h, kch->n, sizeof(kchistitem), popularity_kchistitem_compare);
div->closest = Gif_NewArray(int, kch->n);
div->min_dist = Gif_NewArray(uint32_t, kch->n);
for (i = 0; i != kch->n; ++i)
div->min_dist[i] = (uint32_t) -1;
if (dodither) {
div->min_dither_dist = Gif_NewArray(uint32_t, kch->n);
for (i = 0; i != kch->n; ++i)
div->min_dither_dist[i] = (uint32_t) -1;
} else
div->min_dither_dist = NULL;
div->chosen = Gif_NewArray(int, kch->n);
div->nchosen = 0;
}
void kcdiversity_cleanup(kcdiversity* div) {
Gif_DeleteArray(div->closest);
Gif_DeleteArray(div->min_dist);
Gif_DeleteArray(div->min_dither_dist);
Gif_DeleteArray(div->chosen);
}
int kcdiversity_find_popular(kcdiversity* div) {
int i, n = div->kch->n;
for (i = 0; i != n && div->min_dist[i] == 0; ++i)
/* spin */;
return i;
}
int kcdiversity_find_diverse(kcdiversity* div, double ditherweight) {
int i, n = div->kch->n, chosen = kcdiversity_find_popular(div);
if (chosen == n)
/* skip */;
else if (!ditherweight || !div->min_dither_dist) {
for (i = chosen + 1; i != n; ++i)
if (div->min_dist[i] > div->min_dist[chosen])
chosen = i;
} else {
double max_dist = div->min_dist[chosen] + ditherweight * div->min_dither_dist[chosen];
for (i = chosen + 1; i != n; ++i)
if (div->min_dist[i] != 0) {
double dist = div->min_dist[i] + ditherweight * div->min_dither_dist[i];
if (dist > max_dist) {
chosen = i;
max_dist = dist;
}
}
}
return chosen;
}
int kcdiversity_choose(kcdiversity* div, int chosen, int dodither) {
int i, j, k, n = div->kch->n;
kchistitem* hist = div->kch->h;
div->min_dist[chosen] = 0;
if (div->min_dither_dist)
div->min_dither_dist[chosen] = 0;
div->closest[chosen] = chosen;
/* adjust the min_dist array */
for (i = 0; i != n; ++i)
if (div->min_dist[i]) {
uint32_t dist = kc_distance(&hist[i].ka.k, &hist[chosen].ka.k);
if (dist < div->min_dist[i]) {
div->min_dist[i] = dist;
div->closest[i] = chosen;
}
}
/* also account for dither distances */
if (dodither && div->min_dither_dist)
for (i = 0; i != div->nchosen; ++i) {
kcolor x = hist[chosen].ka.k, *y = &hist[div->chosen[i]].ka.k;
/* penalize combinations with large luminance difference */
double dL = abs(kc_luminance(&x) - kc_luminance(y));
dL = (dL > 8192 ? dL * 4 / 32767. : 1);
/* create combination */
for (k = 0; k != 3; ++k)
x.a[k] = (x.a[k] + y->a[k]) >> 1;
/* track closeness of combination to other colors */
for (j = 0; j != n; ++j)
if (div->min_dist[j]) {
double dist = kc_distance(&hist[j].ka.k, &x) * dL;
if (dist < div->min_dither_dist[j])
div->min_dither_dist[j] = (uint32_t) dist;
}
}
div->chosen[div->nchosen] = chosen;
++div->nchosen;
return chosen;
}
static void colormap_diversity_do_blend(kcdiversity* div) {
int i, j, k, n = div->kch->n;
kchistitem* hist = div->kch->h;
int* chosenmap = Gif_NewArray(int, n);
scale_color* di = Gif_NewArray(scale_color, div->nchosen);
for (i = 0; i != div->nchosen; ++i)
for (k = 0; k != 4; ++k)
di[i].a[k] = 0;
for (i = 0; i != div->nchosen; ++i)
chosenmap[div->chosen[i]] = i;
for (i = 0; i != n; ++i) {
double count = hist[i].count;
if (div->closest[i] == i)
count *= 3;
j = chosenmap[div->closest[i]];
for (k = 0; k != 3; ++k)
di[j].a[k] += hist[i].ka.a[k] * count;
di[j].a[3] += count;
}
for (i = 0; i != div->nchosen; ++i) {
int match = div->chosen[i];
if (di[i].a[3] >= 5 * hist[match].count)
for (k = 0; k != 3; ++k)
hist[match].ka.a[k] = (int) (di[i].a[k] / di[i].a[3]);
}
Gif_DeleteArray(chosenmap);
Gif_DeleteArray(di);
}
static Gif_Colormap *
colormap_diversity(kchist* kch, Gt_OutputData* od, int blend)
{
int adapt_size = od->colormap_size;
kcdiversity div;
Gif_Colormap* gfcm = Gif_NewFullColormap(adapt_size, 256);
int nadapt = 0;
int chosen;
/* This code was uses XV's modified diversity algorithm, and was written
with reference to XV's implementation of that algorithm by John Bradley
<bradley@cis.upenn.edu> and Tom Lane <Tom.Lane@g.gp.cs.cmu.edu>. */
if (adapt_size < 2 || adapt_size > 256)
fatal_error("adaptive palette size must be between 2 and 256");
if (adapt_size > kch->n && !od->colormap_fixed)
warning(1, "trivial adaptive palette (only %d colors in source)", kch->n);
if (adapt_size > kch->n)
adapt_size = kch->n;
/* 0. remove any transparent color from consideration; reduce adaptive
palette size to accommodate transparency if it looks like that'll be
necessary */
/* It will be necessary to accommodate transparency if (1) there is
transparency in the image; (2) the adaptive palette isn't trivial; and
(3) there are a small number of colors in the image (arbitrary constant:
<= 265), so it's likely that most images will use most of the slots, so
it's likely there won't be unused slots. */
if (adapt_size > 2 && adapt_size < kch->n && kch->n <= 265
&& od->colormap_needs_transparency)
adapt_size--;
/* blending has bad effects when there are very few colors */
if (adapt_size < 4)
blend = 0;
/* 1. initialize min_dist and sort the colors in order of popularity. */
kcdiversity_init(&div, kch, od->dither_type != dither_none);
/* 2. choose colors one at a time */
for (nadapt = 0; nadapt < adapt_size; nadapt++) {
/* 2.1. choose the color to be added */
if (nadapt == 0 || (nadapt >= 10 && nadapt % 2 == 0))
/* 2.1a. want most popular unchosen color */
chosen = kcdiversity_find_popular(&div);
else if (od->dither_type == dither_none)
/* 2.1b. choose based on diversity from unchosen colors */
chosen = kcdiversity_find_diverse(&div, 0);
else {
/* 2.1c. choose based on diversity from unchosen colors, but allow
dithered combinations to stand in for colors, particularly early
on in the color finding process */
/* Weight assigned to dithered combinations drops as we proceed. */
#if HAVE_POW
double ditherweight = 0.05 + pow(0.25, 1 + (nadapt - 1) / 3.);
#else
double ditherweight = nadapt < 4 ? 0.25 : 0.125;
#endif
chosen = kcdiversity_find_diverse(&div, ditherweight);
}
kcdiversity_choose(&div, chosen,
od->dither_type != dither_none
&& nadapt > 0 && nadapt < 64);
}
/* 3. make the new palette by choosing one color from each slot. */
if (blend)
colormap_diversity_do_blend(&div);
for (nadapt = 0; nadapt != div.nchosen; ++nadapt)
gfcm->col[nadapt] = kc_togfcg(&kch->h[div.chosen[nadapt]].ka.k);
gfcm->ncol = nadapt;
kcdiversity_cleanup(&div);
return gfcm;
}
Gif_Colormap* colormap_blend_diversity(kchist* kch, Gt_OutputData* od) {
return colormap_diversity(kch, od, 1);
}
Gif_Colormap* colormap_flat_diversity(kchist* kch, Gt_OutputData* od) {
return colormap_diversity(kch, od, 0);
}
/*****
* kd_tree allocation and deallocation
**/
struct kd3_treepos {
int pivot;
int offset;
};
void kd3_init(kd3_tree* kd3, void (*transform)(kcolor*)) {
kd3->tree = NULL;
kd3->ks = Gif_NewArray(kcolor, 256);
kd3->nitems = 0;
kd3->items_cap = 256;
kd3->transform = transform;
kd3->xradius = NULL;
kd3->disabled = -1;
}
void kd3_cleanup(kd3_tree* kd3) {
Gif_DeleteArray(kd3->tree);
Gif_DeleteArray(kd3->ks);
Gif_DeleteArray(kd3->xradius);
}
void kd3_add_transformed(kd3_tree* kd3, const kcolor* k) {
if (kd3->nitems == kd3->items_cap) {
kd3->items_cap *= 2;
Gif_ReArray(kd3->ks, kcolor, kd3->items_cap);
}
kd3->ks[kd3->nitems] = *k;
++kd3->nitems;
if (kd3->tree) {
Gif_DeleteArray(kd3->tree);
Gif_DeleteArray(kd3->xradius);
kd3->tree = NULL;
kd3->xradius = NULL;
}
}
void kd3_add8g(kd3_tree* kd3, int a0, int a1, int a2) {
kcolor k;
kc_set8g(&k, a0, a1, a2);
if (kd3->transform)
kd3->transform(&k);
kd3_add_transformed(kd3, &k);
}
static kd3_tree* kd3_sorter;
static int kd3_item_compar_0(const void* a, const void* b) {
const int* aa = (const int*) a, *bb = (const int*) b;
return kd3_sorter->ks[*aa].a[0] - kd3_sorter->ks[*bb].a[0];
}
static int kd3_item_compar_1(const void* a, const void* b) {
const int* aa = (const int*) a, *bb = (const int*) b;
return kd3_sorter->ks[*aa].a[1] - kd3_sorter->ks[*bb].a[1];
}
static int kd3_item_compar_2(const void* a, const void* b) {
const int* aa = (const int*) a, *bb = (const int*) b;
return kd3_sorter->ks[*aa].a[2] - kd3_sorter->ks[*bb].a[2];
}
static int (*kd3_item_compars[])(const void*, const void*) = {
&kd3_item_compar_0, &kd3_item_compar_1, &kd3_item_compar_2
};
static int kd3_item_all_compar(const void* a, const void* b) {
const int* aa = (const int*) a, *bb = (const int*) b;
return memcmp(&kd3_sorter->ks[*aa], &kd3_sorter->ks[*bb], sizeof(kcolor));
}
static int kd3_build_range(int* perm, int nperm, int n, int depth) {
kd3_tree* kd3 = kd3_sorter;
int m, nl, nr, aindex = depth % 3;
if (depth > kd3->maxdepth)
kd3->maxdepth = depth;
while (n >= kd3->ntree) {
kd3->ntree *= 2;
Gif_ReArray(kd3->tree, kd3_treepos, kd3->ntree);
}
if (nperm <= 1) {
kd3->tree[n].pivot = (nperm == 0 ? -1 : perm[0]);
kd3->tree[n].offset = -1;
return 2;
}
qsort(perm, nperm, sizeof(int), kd3_item_compars[aindex]);
/* pick pivot: a color component to split */
m = nperm >> 1;
while (m > 0
&& kd3->ks[perm[m]].a[aindex] == kd3->ks[perm[m-1]].a[aindex])
--m;
if (m == 0) { /* don't split entirely to the right (infinite loop) */
m = nperm >> 1;
while (m < nperm - 1 /* also, don't split entirely to the left */
&& kd3->ks[perm[m]].a[aindex] == kd3->ks[perm[m-1]].a[aindex])
++m;
}
if (m == 0)
kd3->tree[n].pivot = kd3->ks[perm[m]].a[aindex];
else
kd3->tree[n].pivot = kd3->ks[perm[m-1]].a[aindex]
+ ((kd3->ks[perm[m]].a[aindex] - kd3->ks[perm[m-1]].a[aindex]) >> 1);
/* recurse */
nl = kd3_build_range(perm, m, n+1, depth+1);
kd3->tree[n].offset = 1+nl;
nr = kd3_build_range(&perm[m], nperm - m, n+1+nl, depth+1);
return 1+nl+nr;
}
#if 0
static void kd3_print_depth(kd3_tree* kd3, int depth, kd3_treepos* p,
int* a, int* b) {
int i;
char x[6][10];
for (i = 0; i != 3; ++i) {
if (a[i] == INT_MIN)
sprintf(x[2*i], "*");
else
sprintf(x[2*i], "%d", a[i]);
if (b[i] == INT_MAX)
sprintf(x[2*i+1], "*");
else
sprintf(x[2*i+1], "%d", b[i]);
}
printf("%*s<%s:%s,%s:%s,%s:%s>", depth*3, "",
x[0], x[1], x[2], x[3], x[4], x[5]);
if (p->offset < 0) {
if (p->pivot >= 0) {
assert(kd3->ks[p->pivot].a[0] >= a[0]);
assert(kd3->ks[p->pivot].a[1] >= a[1]);
assert(kd3->ks[p->pivot].a[2] >= a[2]);
assert(kd3->ks[p->pivot].a[0] < b[0]);
assert(kd3->ks[p->pivot].a[1] < b[1]);
assert(kd3->ks[p->pivot].a[2] < b[2]);
printf(" ** @%d: <%d,%d,%d>\n", p->pivot, kd3->ks[p->pivot].a[0], kd3->ks[p->pivot].a[1], kd3->ks[p->pivot].a[2]);
}
} else {
int aindex = depth % 3, x[3];
assert(p->pivot >= a[aindex]);
assert(p->pivot < b[aindex]);
printf((aindex == 0 ? " | <%d,_,_>\n" :
aindex == 1 ? " | <_,%d,_>\n" : " | <_,_,%d>\n"), p->pivot);
memcpy(x, b, sizeof(int) * 3);
x[aindex] = p->pivot;
kd3_print_depth(kd3, depth + 1, p + 1, a, x);
memcpy(x, a, sizeof(int) * 3);
x[aindex] = p->pivot;
kd3_print_depth(kd3, depth + 1, p + p->offset, x, b);
}
}
static void kd3_print(kd3_tree* kd3) {
int a[3], b[3];
a[0] = a[1] = a[2] = INT_MIN;
b[0] = b[1] = b[2] = INT_MAX;
kd3_print_depth(kd3, 0, kd3->tree, a, b);
}
#endif
void kd3_build_xradius(kd3_tree* kd3) {
int i, j;
/* create xradius */
if (kd3->xradius)
return;
kd3->xradius = Gif_NewArray(unsigned, kd3->nitems);
for (i = 0; i != kd3->nitems; ++i)
kd3->xradius[i] = (unsigned) -1;
for (i = 0; i != kd3->nitems; ++i)
for (j = i + 1; j != kd3->nitems; ++j) {
unsigned dist = kc_distance(&kd3->ks[i], &kd3->ks[j]);
unsigned radius = dist / 4;
if (radius < kd3->xradius[i])
kd3->xradius[i] = radius;
if (radius < kd3->xradius[j])
kd3->xradius[j] = radius;
}
}
void kd3_build(kd3_tree* kd3) {
int i, delta, *perm;
assert(!kd3->tree);
/* create tree */
kd3->tree = Gif_NewArray(kd3_treepos, 256);
kd3->ntree = 256;
kd3->maxdepth = 0;
/* create copy of items; remove duplicates */
perm = Gif_NewArray(int, kd3->nitems);
for (i = 0; i != kd3->nitems; ++i)
perm[i] = i;
#if ENABLE_THREADS
/*
* Because kd3_sorter is a static global used in some
* sorting comparators, put a mutex around this
* code block to avoid an utter catastrophe.
*/
pthread_mutex_lock(&kd3_sort_lock);
#endif
kd3_sorter = kd3;
qsort(perm, kd3->nitems, sizeof(int), kd3_item_all_compar);
for (i = 0, delta = 1; i + delta < kd3->nitems; ++i)
if (memcmp(&kd3->ks[perm[i]], &kd3->ks[perm[i+delta]],
sizeof(kcolor)) == 0)
++delta, --i;
else if (delta > 1)
perm[i+1] = perm[i+delta];
kd3_build_range(perm, kd3->nitems - (delta - 1), 0, 0);
assert(kd3->maxdepth < 32);
#if ENABLE_THREADS
pthread_mutex_unlock(&kd3_sort_lock);
#endif
Gif_DeleteArray(perm);
}
void kd3_init_build(kd3_tree* kd3, void (*transform)(kcolor*),
const Gif_Colormap* gfcm) {
int i;
kd3_init(kd3, transform);
for (i = 0; i < gfcm->ncol; ++i)
kd3_add8g(kd3, gfcm->col[i].gfc_red, gfcm->col[i].gfc_green,
gfcm->col[i].gfc_blue);
kd3_build(kd3);
}
int kd3_closest_transformed(kd3_tree* kd3, const kcolor* k,
unsigned* dist_store) {
const kd3_treepos* stack[32];
uint8_t state[32];
int stackpos = 0;
int result = -1;
unsigned mindist = (unsigned) -1;
if (!kd3->tree)
kd3_build(kd3);
stack[0] = kd3->tree;
state[0] = 0;
while (stackpos >= 0) {
const kd3_treepos* p;
assert(stackpos < 32);
p = stack[stackpos];
if (p->offset < 0) {
if (p->pivot >= 0 && kd3->disabled != p->pivot) {
unsigned dist = kc_distance(&kd3->ks[p->pivot], k);
if (dist < mindist) {
mindist = dist;
result = p->pivot;
}
}
if (--stackpos >= 0)
++state[stackpos];
} else if (state[stackpos] == 0) {
if (k->a[stackpos % 3] < p->pivot)
stack[stackpos + 1] = p + 1;
else
stack[stackpos + 1] = p + p->offset;
++stackpos;
state[stackpos] = 0;
} else {
int delta = k->a[stackpos % 3] - p->pivot;
if (state[stackpos] == 1
&& (unsigned) delta * (unsigned) delta < mindist) {
if (delta < 0)
stack[stackpos + 1] = p + p->offset;
else
stack[stackpos + 1] = p + 1;
++stackpos;
state[stackpos] = 0;
} else if (--stackpos >= 0)
++state[stackpos];
}
}
if (dist_store)
*dist_store = mindist;
return result;
}
int kd3_closest8g(kd3_tree* kd3, int a0, int a1, int a2) {
kcolor k;
kc_set8g(&k, a0, a1, a2);
if (kd3->transform)
kd3->transform(&k);
return kd3_closest_transformed(kd3, &k, NULL);
}
void
colormap_image_posterize(Gif_Image *gfi, uint8_t *new_data,
Gif_Colormap *old_cm, kd3_tree* kd3,
uint32_t *histogram)
{
int ncol = old_cm->ncol;
Gif_Color *col = old_cm->col;
int map[256];
int i, j;
int transparent = gfi->transparent;
/* find closest colors in new colormap */
for (i = 0; i < ncol; i++) {
map[i] = col[i].pixel = kd3_closest8g(kd3, col[i].gfc_red, col[i].gfc_green, col[i].gfc_blue);
col[i].haspixel = 1;
}
/* map image */
for (j = 0; j < gfi->height; j++) {
uint8_t *data = gfi->img[j];
for (i = 0; i < gfi->width; i++, data++, new_data++)
if (*data != transparent) {
*new_data = map[*data];
histogram[*new_data]++;
}
}
}
#define DITHER_SCALE 1024
#define DITHER_SHIFT 10
#define DITHER_SCALE_M1 (DITHER_SCALE-1)
#define DITHER_ITEM2ERR (1<<(DITHER_SHIFT-7))
#define N_RANDOM_VALUES 512
void
colormap_image_floyd_steinberg(Gif_Image *gfi, uint8_t *all_new_data,
Gif_Colormap *old_cm, kd3_tree* kd3,
uint32_t *histogram)
{
static int32_t *random_values = 0;
int width = gfi->width;
int dither_direction = 0;
int transparent = gfi->transparent;
int i, j, k;
wkcolor *err, *err1;
/* Initialize distances */
for (i = 0; i < old_cm->ncol; ++i) {
Gif_Color* c = &old_cm->col[i];
c->pixel = kd3_closest8g(kd3, c->gfc_red, c->gfc_green, c->gfc_blue);
c->haspixel = 1;
}
/* This code was written with reference to ppmquant by Jef Poskanzer, part
of the pbmplus package. */
/* Initialize Floyd-Steinberg error vectors to small random values, so we
don't get artifacts on the top row */
err = Gif_NewArray(wkcolor, width + 2);
err1 = Gif_NewArray(wkcolor, width + 2);
/* Use the same random values on each call in an attempt to minimize
"jumping dithering" effects on animations */
if (!random_values) {
random_values = Gif_NewArray(int32_t, N_RANDOM_VALUES);
for (i = 0; i < N_RANDOM_VALUES; i++)
random_values[i] = RANDOM() % (DITHER_SCALE_M1 * 2) - DITHER_SCALE_M1;
}
for (i = 0; i < gfi->width + 2; i++) {
j = (i + gfi->left) * 3;
for (k = 0; k < 3; ++k)
err[i].a[k] = random_values[ (j + k) % N_RANDOM_VALUES ];
}
/* err1 initialized below */
kd3_build_xradius(kd3);
/* Do the image! */
for (j = 0; j < gfi->height; j++) {
int d0, d1, d2, d3; /* used for error diffusion */
uint8_t *data, *new_data;
int x;
if (dither_direction) {
x = width - 1;
d0 = 0, d1 = 2, d2 = 1, d3 = 0;
} else {
x = 0;
d0 = 2, d1 = 0, d2 = 1, d3 = 2;
}
data = &gfi->img[j][x];
new_data = all_new_data + j * (unsigned) width + x;
for (i = 0; i < width + 2; i++)
err1[i].a[0] = err1[i].a[1] = err1[i].a[2] = 0;
/* Do a single row */
while (x >= 0 && x < width) {
int e;
kcolor use;
/* the transparent color never gets adjusted */
if (*data == transparent)
goto next;
/* find desired new color */
kc_set8g(&use, old_cm->col[*data].gfc_red, old_cm->col[*data].gfc_green,
old_cm->col[*data].gfc_blue);
if (kd3->transform)
kd3->transform(&use);
/* use Floyd-Steinberg errors to adjust */
for (k = 0; k < 3; ++k) {
int v = use.a[k]
+ (err[x+1].a[k] & ~(DITHER_ITEM2ERR-1)) / DITHER_ITEM2ERR;
use.a[k] = KC_CLAMPV(v);
}
e = old_cm->col[*data].pixel;
if (kc_distance(&kd3->ks[e], &use) < kd3->xradius[e])
*new_data = e;
else
*new_data = kd3_closest_transformed(kd3, &use, NULL);
histogram[*new_data]++;
/* calculate and propagate the error between desired and selected color.
Assume that, with a large scale (1024), we don't need to worry about
image artifacts caused by error accumulation (the fact that the
error terms might not sum to the error). */
for (k = 0; k < 3; ++k) {
e = (use.a[k] - kd3->ks[*new_data].a[k]) * DITHER_ITEM2ERR;
if (e) {
err [x+d0].a[k] += ((e * 7) & ~15) / 16;
err1[x+d1].a[k] += ((e * 3) & ~15) / 16;
err1[x+d2].a[k] += ((e * 5) & ~15) / 16;
err1[x+d3].a[k] += ( e & ~15) / 16;
}
}
next:
if (dither_direction)
x--, data--, new_data--;
else
x++, data++, new_data++;
}
/* Did a single row */
/* change dithering directions */
{
wkcolor *temp = err1;
err1 = err;
err = temp;
dither_direction = !dither_direction;
}
}
/* delete temporary storage */
Gif_DeleteArray(err);
Gif_DeleteArray(err1);
}
typedef struct odselect_planitem {
uint8_t plan;
uint16_t frac;
} odselect_planitem;
static int* ordered_dither_lum;
static void plan_from_cplan(uint8_t* plan, int nplan,
const odselect_planitem* cp, int ncp, int whole) {
int i, cfrac_subt = 0, planpos = 0, end_planpos;
for (i = 0; i != ncp; ++i) {
cfrac_subt += cp[i].frac;
end_planpos = cfrac_subt * nplan / whole;
while (planpos != end_planpos)
plan[planpos++] = cp[i].plan;
}
assert(planpos == nplan);
}
static int ordered_dither_plan_compare(const void* xa, const void* xb) {
const uint8_t* a = (const uint8_t*) xa;
const uint8_t* b = (const uint8_t*) xb;
if (ordered_dither_lum[*a] != ordered_dither_lum[*b])
return ordered_dither_lum[*a] - ordered_dither_lum[*b];
else
return *a - *b;
}
static int kc_line_closest(const kcolor* p0, const kcolor* p1,
const kcolor* ref, double* t, unsigned* dist) {
wkcolor p01, p0ref;
kcolor online;
unsigned den;
int d;
for (d = 0; d != 3; ++d) {
p01.a[d] = p1->a[d] - p0->a[d];
p0ref.a[d] = ref->a[d] - p0->a[d];
}
den = (unsigned)
(p01.a[0]*p01.a[0] + p01.a[1]*p01.a[1] + p01.a[2]*p01.a[2]);
if (den == 0)
return 0;
/* NB: We've run out of bits of precision. We can calculate the
denominator in unsigned arithmetic, but the numerator might
be negative, or it might be so large that it is unsigned.
Calculate the numerator as a double. */
*t = ((double) p01.a[0]*p0ref.a[0] + p01.a[1]*p0ref.a[1]
+ p01.a[2]*p0ref.a[2]) / den;
if (*t < 0 || *t > 1)
return 0;
for (d = 0; d != 3; ++d) {
int v = (int) (p01.a[d] * *t) + p0->a[d];
online.a[d] = KC_CLAMPV(v);
}
*dist = kc_distance(&online, ref);
return 1;
}
static int kc_plane_closest(const kcolor* p0, const kcolor* p1,
const kcolor* p2, const kcolor* ref,
double* t, unsigned* dist) {
wkcolor p0ref, p01, p02;
double n[3], pvec[3], det, qvec[3], u, v;
int d;
/* Calculate the non-unit normal of the plane determined by the input
colors (p0-p2) */
for (d = 0; d != 3; ++d) {
p0ref.a[d] = ref->a[d] - p0->a[d];
p01.a[d] = p1->a[d] - p0->a[d];
p02.a[d] = p2->a[d] - p0->a[d];
}
n[0] = p01.a[1]*p02.a[2] - p01.a[2]*p02.a[1];
n[1] = p01.a[2]*p02.a[0] - p01.a[0]*p02.a[2];
n[2] = p01.a[0]*p02.a[1] - p01.a[1]*p02.a[0];
/* Moeller-Trumbore ray tracing algorithm: trace a ray from `ref` along
normal `n`; convert to barycentric coordinates to see if the ray
intersects with the triangle. */
pvec[0] = n[1]*p02.a[2] - n[2]*p02.a[1];
pvec[1] = n[2]*p02.a[0] - n[0]*p02.a[2];
pvec[2] = n[0]*p02.a[1] - n[1]*p02.a[0];
det = pvec[0]*p01.a[0] + pvec[1]*p01.a[1] + pvec[2]*p01.a[2];
if (fabs(det) <= 0.0001220703125) /* optimizer will take care of that */
return 0;
det = 1 / det;
u = (p0ref.a[0]*pvec[0] + p0ref.a[1]*pvec[1] + p0ref.a[2]*pvec[2]) * det;
if (u < 0 || u > 1)
return 0;
qvec[0] = p0ref.a[1]*p01.a[2] - p0ref.a[2]*p01.a[1];
qvec[1] = p0ref.a[2]*p01.a[0] - p0ref.a[0]*p01.a[2];
qvec[2] = p0ref.a[0]*p01.a[1] - p0ref.a[1]*p01.a[0];
v = (n[0]*qvec[0] + n[1]*qvec[1] + n[2]*qvec[2]) * det;
if (v < 0 || v > 1 || u + v > 1)
return 0;
/* Now we know at there is a point in the triangle that is closer to
`ref` than any point along its edges. Return the barycentric
coordinates for that point and the distance to that point. */
t[0] = u;
t[1] = v;
v = (p02.a[0]*qvec[0] + p02.a[1]*qvec[1] + p02.a[2]*qvec[2]) * det;
*dist = (unsigned) (v * v * (n[0]*n[0] + n[1]*n[1] + n[2]*n[2]) + 0.5);
return 1;
}
static void limit_ordered_dither_plan(uint8_t* plan, int nplan, int nc,
const kcolor* want, kd3_tree* kd3) {
unsigned mindist, dist;
int ncp = 0, nbestcp = 0, i, j, k;
double t[2];
odselect_planitem cp[256], bestcp[16];
nc = nc <= 16 ? nc : 16;
/* sort colors */
cp[0].plan = plan[0];
cp[0].frac = 1;
for (ncp = i = 1; i != nplan; ++i)
if (plan[i - 1] == plan[i])
++cp[ncp - 1].frac;
else {
cp[ncp].plan = plan[i];
cp[ncp].frac = 1;
++ncp;
}
/* calculate plan */
mindist = (unsigned) -1;
for (i = 0; i != ncp; ++i) {
/* check for closest single color */
dist = kc_distance(&kd3->ks[cp[i].plan], want);
if (dist < mindist) {
bestcp[0].plan = cp[i].plan;
bestcp[0].frac = KC_WHOLE;
nbestcp = 1;
mindist = dist;
}
for (j = i + 1; nc >= 2 && j < ncp; ++j) {
/* check for closest blend of two colors */
if (kc_line_closest(&kd3->ks[cp[i].plan],
&kd3->ks[cp[j].plan],
want, &t[0], &dist)
&& dist < mindist) {
bestcp[0].plan = cp[i].plan;
bestcp[1].plan = cp[j].plan;
bestcp[1].frac = (int) (KC_WHOLE * t[0]);
bestcp[0].frac = KC_WHOLE - bestcp[1].frac;
nbestcp = 2;
mindist = dist;
}
for (k = j + 1; nc >= 3 && k < ncp; ++k)
/* check for closest blend of three colors */
if (kc_plane_closest(&kd3->ks[cp[i].plan],
&kd3->ks[cp[j].plan],
&kd3->ks[cp[k].plan],
want, &t[0], &dist)
&& dist < mindist) {
bestcp[0].plan = cp[i].plan;
bestcp[1].plan = cp[j].plan;
bestcp[1].frac = (int) (KC_WHOLE * t[0]);
bestcp[2].plan = cp[k].plan;
bestcp[2].frac = (int) (KC_WHOLE * t[1]);
bestcp[0].frac = KC_WHOLE - bestcp[1].frac - bestcp[2].frac;
nbestcp = 3;
mindist = dist;
}
}
}
plan_from_cplan(plan, nplan, bestcp, nbestcp, KC_WHOLE);
}
static void set_ordered_dither_plan(uint8_t* plan, int nplan, int nc,
Gif_Color* gfc, kd3_tree* kd3) {
kcolor want, cur;
wkcolor err;
int i, d;
kc_set8g(&want, gfc->gfc_red, gfc->gfc_green, gfc->gfc_blue);
if (kd3->transform)
kd3->transform(&want);
wkc_clear(&err);
for (i = 0; i != nplan; ++i) {
for (d = 0; d != 3; ++d) {
int v = want.a[d] + err.a[d];
cur.a[d] = KC_CLAMPV(v);
}
plan[i] = kd3_closest_transformed(kd3, &cur, NULL);
for (d = 0; d != 3; ++d)
err.a[d] += want.a[d] - kd3->ks[plan[i]].a[d];
}
qsort(plan, nplan, 1, ordered_dither_plan_compare);
if (nc < nplan && plan[0] != plan[nplan-1]) {
int ncp = 1;
for (i = 1; i != nplan; ++i)
ncp += plan[i-1] != plan[i];
if (ncp > nc)
limit_ordered_dither_plan(plan, nplan, nc, &want, kd3);
}
gfc->haspixel = 1;
}
static void pow2_ordered_dither(Gif_Image* gfi, uint8_t* all_new_data,
Gif_Colormap* old_cm, kd3_tree* kd3,
uint32_t* histogram, const uint8_t* matrix,
uint8_t* plan) {
int mws, nplans, i, x, y;
for (mws = 0; (1 << mws) != matrix[0]; ++mws)
/* nada */;
for (nplans = 0; (1 << nplans) != matrix[2]; ++nplans)
/* nada */;
for (y = 0; y != gfi->height; ++y) {
uint8_t *data, *new_data, *thisplan;
data = gfi->img[y];
new_data = all_new_data + y * (unsigned) gfi->width;
for (x = 0; x != gfi->width; ++x)
/* the transparent color never gets adjusted */
if (data[x] != gfi->transparent) {
thisplan = &plan[data[x] << nplans];
if (!old_cm->col[data[x]].haspixel)
set_ordered_dither_plan(thisplan, 1 << nplans, matrix[3],
&old_cm->col[data[x]], kd3);
i = matrix[4 + ((x + gfi->left) & (matrix[0] - 1))
+ (((y + gfi->top) & (matrix[1] - 1)) << mws)];
new_data[x] = thisplan[i];
histogram[new_data[x]]++;
}
}
}
static void colormap_image_ordered(Gif_Image* gfi, uint8_t* all_new_data,
Gif_Colormap* old_cm, kd3_tree* kd3,
uint32_t* histogram,
const uint8_t* matrix) {
int mw = matrix[0], mh = matrix[1], nplan = matrix[2];
uint8_t* plan = Gif_NewArray(uint8_t, nplan * old_cm->ncol);
int i, x, y;
/* Written with reference to Joel Ylilouma's versions. */
/* Initialize colors */
for (i = 0; i != old_cm->ncol; ++i)
old_cm->col[i].haspixel = 0;
/* Initialize luminances, create luminance sorter */
ordered_dither_lum = Gif_NewArray(int, kd3->nitems);
for (i = 0; i != kd3->nitems; ++i)
ordered_dither_lum[i] = kc_luminance(&kd3->ks[i]);
/* Do the image! */
if ((mw & (mw - 1)) == 0 && (mh & (mh - 1)) == 0
&& (nplan & (nplan - 1)) == 0)
pow2_ordered_dither(gfi, all_new_data, old_cm, kd3, histogram,
matrix, plan);
else
for (y = 0; y != gfi->height; ++y) {
uint8_t *data, *new_data, *thisplan;
data = gfi->img[y];
new_data = all_new_data + y * (unsigned) gfi->width;
for (x = 0; x != gfi->width; ++x)
/* the transparent color never gets adjusted */
if (data[x] != gfi->transparent) {
thisplan = &plan[nplan * data[x]];
if (!old_cm->col[data[x]].haspixel)
set_ordered_dither_plan(thisplan, nplan, matrix[3],
&old_cm->col[data[x]], kd3);
i = matrix[4 + (x + gfi->left) % mw
+ ((y + gfi->top) % mh) * mw];
new_data[x] = thisplan[i];
histogram[new_data[x]]++;
}
}
/* delete temporary storage */
Gif_DeleteArray(ordered_dither_lum);
Gif_DeleteArray(plan);
}
static void dither(Gif_Image* gfi, uint8_t* new_data, Gif_Colormap* old_cm,
kd3_tree* kd3, uint32_t* histogram, Gt_OutputData* od) {
if (od->dither_type == dither_default
|| od->dither_type == dither_floyd_steinberg)
colormap_image_floyd_steinberg(gfi, new_data, old_cm, kd3, histogram);
else if (od->dither_type == dither_ordered
|| od->dither_type == dither_ordered_new)
colormap_image_ordered(gfi, new_data, old_cm, kd3, histogram,
od->dither_data);
else
colormap_image_posterize(gfi, new_data, old_cm, kd3, histogram);
}
/* return value 1 means run the dither again */
static int
try_assign_transparency(Gif_Image *gfi, Gif_Colormap *old_cm, uint8_t *new_data,
Gif_Colormap *new_cm, int *new_ncol,
kd3_tree* kd3, uint32_t *histogram)
{
uint32_t min_used;
int i, j;
int transparent = gfi->transparent;
int new_transparent = -1;
Gif_Color transp_value;
if (transparent < 0)
return 0;
if (old_cm)
transp_value = old_cm->col[transparent];
else
GIF_SETCOLOR(&transp_value, 0, 0, 0);
/* look for an unused pixel in the existing colormap; prefer the same color
we had */
for (i = 0; i < *new_ncol; i++)
if (histogram[i] == 0 && GIF_COLOREQ(&transp_value, &new_cm->col[i])) {
new_transparent = i;
goto found;
}
for (i = 0; i < *new_ncol; i++)
if (histogram[i] == 0) {
new_transparent = i;
goto found;
}
/* try to expand the colormap */
if (*new_ncol < 256) {
assert(*new_ncol < new_cm->capacity);
new_transparent = *new_ncol;
new_cm->col[new_transparent] = transp_value;
(*new_ncol)++;
goto found;
}
/* not found: mark the least-frequently-used color as the new transparent
color and return 1 (meaning 'dither again') */
assert(*new_ncol == 256);
min_used = 0xFFFFFFFFU;
for (i = 0; i < 256; i++)
if (histogram[i] < min_used) {
new_transparent = i;
min_used = histogram[i];
}
kd3_disable(kd3, new_transparent); /* mark it as unusable */
return 1;
found:
for (j = 0; j < gfi->height; j++) {
uint8_t *data = gfi->img[j];
for (i = 0; i < gfi->width; i++, data++, new_data++)
if (*data == transparent)
*new_data = new_transparent;
}
gfi->transparent = new_transparent;
return 0;
}
void
colormap_stream(Gif_Stream* gfs, Gif_Colormap* new_cm, Gt_OutputData* od)
{
kd3_tree kd3;
Gif_Color *new_col = new_cm->col;
int new_ncol = new_cm->ncol, new_gray;
int imagei, j;
int compress_new_cm = 1;
/* make sure colormap has enough space */
if (new_cm->capacity < 256) {
Gif_Color *x = Gif_NewArray(Gif_Color, 256);
memcpy(x, new_col, sizeof(Gif_Color) * new_ncol);
Gif_DeleteArray(new_col);
new_cm->col = new_col = x;
new_cm->capacity = 256;
}
assert(new_cm->capacity >= 256);
/* new_col[j].pixel == number of pixels with color j in the new image. */
for (j = 0; j < 256; j++)
new_col[j].pixel = 0;
/* initialize kd3 tree */
new_gray = 1;
for (j = 0; new_gray && j < new_cm->ncol; ++j)
if (new_col[j].gfc_red != new_col[j].gfc_green
|| new_col[j].gfc_red != new_col[j].gfc_blue)
new_gray = 0;
kd3_init_build(&kd3, new_gray ? kc_luminance_transform : NULL, new_cm);
for (imagei = 0; imagei < gfs->nimages; imagei++) {
Gif_Image *gfi = gfs->images[imagei];
Gif_Colormap *gfcm = gfi->local ? gfi->local : gfs->global;
int only_compressed = (gfi->img == 0);
if (gfcm) {
/* If there was an old colormap, change the image data */
uint8_t *new_data = Gif_NewArray(uint8_t, (unsigned) gfi->width * (unsigned) gfi->height);
uint32_t histogram[256];
unmark_colors(new_cm);
unmark_colors(gfcm);
if (only_compressed)
Gif_UncompressImage(gfs, gfi);
kd3_enable_all(&kd3);
do {
for (j = 0; j < 256; j++)
histogram[j] = 0;
dither(gfi, new_data, gfcm, &kd3, histogram, od);
} while (try_assign_transparency(gfi, gfcm, new_data, new_cm, &new_ncol,
&kd3, histogram));
Gif_ReleaseUncompressedImage(gfi);
/* version 1.28 bug fix: release any compressed version or it'll cause
bad images */
Gif_ReleaseCompressedImage(gfi);
Gif_SetUncompressedImage(gfi, new_data, Gif_Free, 0);
/* update count of used colors */
for (j = 0; j < 256; j++)
new_col[j].pixel += histogram[j];
if (gfi->transparent >= 0)
/* we don't have data on the number of used colors for transparency
so fudge it. */
new_col[gfi->transparent].pixel += (unsigned) gfi->width * (unsigned) gfi->height / 8;
} else {
/* Can't compress new_cm afterwards if we didn't actively change colors
over */
compress_new_cm = 0;
}
if (gfi->local) {
Gif_DeleteColormap(gfi->local);
gfi->local = 0;
}
/* 1.92: recompress *after* deleting the local colormap */
if (gfcm && only_compressed) {
Gif_FullCompressImage(gfs, gfi, &gif_write_info);
Gif_ReleaseUncompressedImage(gfi);
}
}
/* Set new_cm->ncol from new_ncol. We didn't update new_cm->ncol before so
the closest-color algorithms wouldn't see any new transparent colors.
That way added transparent colors were only used for transparency. */
new_cm->ncol = new_ncol;
/* change the background. I hate the background by now */
if ((gfs->nimages == 0 || gfs->images[0]->transparent < 0)
&& gfs->global && gfs->background < gfs->global->ncol) {
Gif_Color *c = &gfs->global->col[gfs->background];
gfs->background = kd3_closest8g(&kd3, c->gfc_red, c->gfc_green, c->gfc_blue);
new_col[gfs->background].pixel++;
} else if (gfs->nimages > 0 && gfs->images[0]->transparent >= 0)
gfs->background = gfs->images[0]->transparent;
else
gfs->background = 0;
Gif_DeleteColormap(gfs->global);
kd3_cleanup(&kd3);
/* We may have used only a subset of the colors in new_cm. We try to store
only that subset, just as if we'd piped the output of 'gifsicle
--use-colormap=X' through 'gifsicle' another time. */
gfs->global = Gif_CopyColormap(new_cm);
for (j = 0; j < new_cm->ncol; ++j)
gfs->global->col[j].haspixel = 0;
if (compress_new_cm) {
/* only bother to recompress if we'll get anything out of it */
compress_new_cm = 0;
for (j = 0; j < new_cm->ncol - 1; j++)
if (new_col[j].pixel == 0 || new_col[j].pixel < new_col[j+1].pixel) {
compress_new_cm = 1;
break;
}
}
if (compress_new_cm) {
int map[256];
/* Gif_CopyColormap copies the 'pixel' values as well */
new_col = gfs->global->col;
for (j = 0; j < new_cm->ncol; j++)
new_col[j].haspixel = j;
/* sort based on popularity */
qsort(new_col, new_cm->ncol, sizeof(Gif_Color), popularity_sort_compare);
/* set up the map and reduce the number of colors */
for (j = 0; j < new_cm->ncol; j++)
map[ new_col[j].haspixel ] = j;
for (j = 0; j < new_cm->ncol; j++)
if (!new_col[j].pixel) {
gfs->global->ncol = j;
break;
}
/* map the image data, transparencies, and background */
if (gfs->background < gfs->global->ncol)
gfs->background = map[gfs->background];
for (imagei = 0; imagei < gfs->nimages; imagei++) {
Gif_Image *gfi = gfs->images[imagei];
int only_compressed = (gfi->img == 0);
uint32_t size;
uint8_t *data;
if (only_compressed)
Gif_UncompressImage(gfs, gfi);
data = gfi->image_data;
for (size = (unsigned) gfi->width * (unsigned) gfi->height; size > 0; size--, data++)
*data = map[*data];
if (gfi->transparent >= 0)
gfi->transparent = map[gfi->transparent];
if (only_compressed) {
Gif_FullCompressImage(gfs, gfi, &gif_write_info);
Gif_ReleaseUncompressedImage(gfi);
}
}
}
}
/* Halftone algorithms */
static const uint8_t dither_matrix_o3x3[4 + 3*3] = {
3, 3, 9, 9,
2, 6, 3,
5, 0, 8,
1, 7, 4
};
static const uint8_t dither_matrix_o4x4[4 + 4*4] = {
4, 4, 16, 16,
0, 8, 3, 10,
12, 4, 14, 6,
2, 11, 1, 9,
15, 7, 13, 5
};
static const uint8_t dither_matrix_o8x8[4 + 8*8] = {
8, 8, 64, 64,
0, 48, 12, 60, 3, 51, 15, 63,
32, 16, 44, 28, 35, 19, 47, 31,
8, 56, 4, 52, 11, 59, 7, 55,
40, 24, 36, 20, 43, 27, 39, 23,
2, 50, 14, 62, 1, 49, 13, 61,
34, 18, 46, 30, 33, 17, 45, 29,
10, 58, 6, 54, 9, 57, 5, 53,
42, 26, 38, 22, 41, 25, 37, 21
};
static const uint8_t dither_matrix_ro64x64[4 + 64*64] = {
64, 64, 16, 16,
6, 15, 2, 15, 2, 14, 1, 13, 2, 14, 5, 13, 0, 14, 0, 9, 6, 10, 7, 13, 6, 13, 3, 10, 5, 15, 4, 11, 0, 11, 6, 10, 7, 12, 7, 13, 0, 9, 6, 15, 6, 10, 0, 15, 1, 15, 0, 8, 0, 15, 6, 15, 7, 15, 7, 9, 1, 15, 3, 8, 1, 8, 0, 14,
9, 3, 10, 5, 10, 6, 10, 5, 9, 6, 9, 2, 9, 4, 13, 4, 13, 3, 8, 3, 10, 1, 13, 6, 11, 1, 12, 3, 14, 5, 15, 3, 8, 3, 8, 3, 12, 4, 11, 3, 13, 3, 8, 4, 9, 6, 12, 4, 11, 6, 11, 3, 10, 0, 12, 1, 11, 7, 12, 4, 12, 4, 11, 5,
1, 14, 0, 10, 2, 9, 2, 11, 1, 8, 1, 8, 3, 9, 4, 15, 7, 13, 7, 14, 7, 14, 0, 10, 0, 14, 7, 9, 0, 11, 1, 15, 0, 11, 0, 11, 3, 15, 7, 14, 6, 10, 5, 8, 0, 11, 0, 8, 7, 11, 0, 15, 0, 12, 1, 13, 6, 9, 0, 15, 4, 9, 1, 8,
10, 5, 15, 6, 13, 6, 14, 7, 14, 4, 12, 5, 15, 6, 10, 2, 11, 3, 10, 3, 11, 3, 13, 6, 11, 5, 14, 3, 14, 6, 8, 5, 14, 5, 14, 7, 10, 7, 11, 3, 13, 3, 13, 2, 14, 4, 15, 5, 15, 3, 8, 4, 11, 4, 9, 5, 12, 3, 8, 5, 15, 2, 13, 5,
3, 10, 2, 9, 5, 15, 4, 9, 0, 11, 7, 11, 0, 14, 5, 11, 5, 14, 7, 15, 6, 9, 0, 9, 0, 8, 4, 14, 6, 12, 0, 11, 4, 15, 5, 8, 6, 10, 6, 11, 6, 10, 3, 12, 5, 9, 6, 9, 5, 12, 6, 12, 7, 14, 0, 14, 2, 15, 5, 8, 2, 10, 3, 9,
14, 7, 14, 7, 8, 1, 12, 2, 14, 4, 15, 3, 11, 5, 12, 2, 8, 0, 10, 3, 12, 1, 13, 5, 14, 5, 11, 0, 11, 3, 13, 7, 8, 1, 12, 3, 15, 3, 14, 2, 15, 3, 11, 6, 15, 1, 12, 1, 9, 3, 9, 3, 11, 3, 11, 7, 11, 5, 12, 0, 14, 6, 13, 6,
5, 10, 6, 12, 3, 15, 3, 8, 7, 10, 0, 15, 7, 10, 5, 8, 1, 14, 5, 10, 7, 14, 2, 14, 0, 14, 1, 8, 3, 8, 5, 10, 5, 15, 0, 8, 6, 14, 0, 8, 2, 15, 4, 11, 6, 10, 0, 8, 5, 9, 4, 14, 1, 15, 3, 10, 1, 15, 0, 15, 5, 8, 7, 13,
15, 3, 8, 0, 9, 6, 12, 6, 15, 0, 11, 4, 14, 3, 15, 3, 10, 5, 12, 3, 10, 3, 9, 6, 9, 5, 13, 5, 15, 6, 14, 0, 9, 0, 12, 4, 11, 3, 15, 4, 11, 6, 15, 2, 15, 3, 14, 4, 13, 2, 11, 1, 8, 5, 12, 7, 9, 4, 8, 5, 12, 2, 11, 0,
0, 13, 5, 11, 5, 14, 5, 15, 7, 9, 5, 8, 2, 10, 3, 15, 6, 9, 3, 12, 5, 11, 6, 14, 3, 13, 6, 13, 0, 9, 1, 11, 3, 8, 3, 9, 4, 9, 6, 14, 7, 8, 6, 12, 7, 13, 6, 9, 5, 13, 3, 15, 5, 14, 3, 15, 4, 12, 4, 12, 2, 13, 0, 15,
10, 7, 14, 1, 8, 2, 10, 2, 12, 0, 13, 1, 13, 5, 11, 6, 12, 3, 9, 6, 15, 1, 9, 1, 10, 6, 10, 3, 15, 6, 15, 5, 15, 7, 12, 6, 12, 0, 9, 3, 12, 3, 11, 3, 8, 3, 13, 2, 9, 3, 9, 6, 10, 2, 11, 6, 9, 0, 9, 1, 9, 6, 10, 4,
3, 10, 4, 9, 4, 9, 6, 13, 3, 15, 0, 8, 4, 10, 0, 14, 5, 15, 7, 15, 2, 12, 7, 10, 5, 15, 7, 8, 0, 9, 0, 8, 6, 14, 4, 15, 2, 15, 1, 15, 0, 9, 5, 14, 0, 12, 7, 10, 6, 8, 6, 11, 0, 13, 7, 14, 1, 13, 2, 10, 5, 9, 0, 14,
14, 6, 13, 1, 12, 3, 8, 3, 9, 6, 12, 4, 15, 2, 8, 5, 9, 1, 10, 1, 8, 5, 15, 0, 8, 2, 12, 3, 12, 5, 12, 5, 11, 2, 10, 2, 8, 5, 10, 5, 12, 4, 9, 3, 8, 4, 13, 1, 15, 0, 12, 3, 8, 4, 10, 3, 9, 5, 13, 5, 13, 3, 11, 4,
4, 12, 3, 10, 6, 9, 0, 14, 0, 8, 1, 9, 1, 9, 6, 15, 0, 10, 2, 9, 6, 10, 7, 10, 2, 14, 4, 8, 0, 13, 4, 8, 1, 11, 6, 14, 7, 14, 0, 8, 4, 14, 7, 14, 4, 9, 2, 12, 0, 12, 3, 8, 5, 9, 6, 14, 0, 9, 2, 14, 5, 10, 1, 15,
10, 2, 15, 6, 14, 3, 11, 6, 15, 4, 15, 4, 13, 5, 11, 3, 12, 4, 14, 5, 12, 0, 13, 3, 8, 6, 15, 2, 10, 6, 13, 2, 12, 6, 8, 3, 10, 3, 14, 5, 8, 0, 10, 3, 13, 2, 9, 6, 10, 6, 15, 4, 13, 2, 8, 3, 14, 6, 11, 7, 13, 0, 10, 5,
2, 13, 1, 9, 5, 10, 3, 15, 6, 10, 0, 15, 4, 15, 4, 15, 6, 9, 0, 14, 1, 9, 6, 12, 0, 11, 5, 9, 0, 14, 5, 14, 6, 9, 3, 11, 7, 11, 1, 15, 1, 9, 3, 13, 5, 12, 0, 9, 2, 9, 6, 13, 2, 9, 6, 13, 7, 11, 7, 8, 0, 13, 3, 9,
9, 6, 13, 6, 13, 0, 8, 5, 14, 2, 11, 7, 11, 2, 11, 2, 12, 3, 11, 4, 13, 4, 10, 3, 15, 5, 13, 0, 11, 6, 10, 0, 13, 3, 15, 7, 14, 3, 8, 4, 12, 6, 9, 6, 10, 3, 14, 5, 13, 5, 11, 3, 13, 6, 8, 2, 14, 3, 15, 3, 11, 4, 12, 6,
4, 10, 7, 11, 1, 10, 2, 14, 7, 14, 0, 14, 4, 15, 0, 8, 0, 15, 5, 15, 7, 11, 7, 14, 6, 12, 0, 8, 1, 15, 1, 14, 2, 8, 0, 11, 4, 8, 5, 11, 1, 15, 0, 12, 7, 14, 0, 11, 4, 8, 2, 8, 0, 14, 2, 14, 4, 9, 4, 10, 7, 15, 5, 14,
14, 0, 13, 2, 14, 5, 11, 5, 10, 2, 10, 6, 11, 3, 12, 5, 11, 7, 11, 1, 12, 3, 11, 3, 9, 3, 12, 4, 11, 6, 9, 5, 14, 5, 12, 7, 14, 2, 12, 1, 8, 4, 11, 7, 10, 3, 14, 4, 14, 0, 14, 5, 11, 7, 11, 5, 15, 1, 14, 0, 10, 3, 10, 0,
5, 12, 7, 10, 7, 11, 0, 14, 5, 14, 1, 14, 3, 8, 0, 15, 0, 9, 5, 9, 1, 8, 6, 15, 6, 15, 7, 13, 7, 9, 4, 11, 0, 10, 6, 10, 7, 12, 7, 15, 0, 9, 7, 14, 2, 11, 0, 12, 7, 11, 7, 13, 0, 9, 6, 14, 2, 11, 1, 15, 0, 8, 0, 10,
10, 3, 15, 3, 15, 3, 8, 4, 11, 3, 11, 6, 15, 6, 11, 5, 12, 5, 13, 0, 15, 4, 8, 1, 11, 3, 10, 3, 15, 3, 14, 1, 14, 6, 13, 3, 11, 3, 11, 3, 13, 6, 8, 3, 12, 5, 8, 4, 13, 3, 8, 2, 13, 4, 8, 3, 14, 7, 8, 5, 14, 4, 15, 5,
3, 9, 0, 10, 0, 12, 3, 11, 7, 10, 6, 8, 7, 12, 0, 11, 1, 8, 5, 12, 5, 12, 7, 11, 2, 14, 0, 10, 0, 12, 0, 15, 2, 9, 5, 9, 0, 15, 4, 14, 6, 9, 7, 11, 6, 10, 0, 9, 1, 9, 0, 14, 4, 12, 5, 9, 6, 10, 4, 11, 6, 12, 5, 12,
12, 6, 15, 4, 8, 4, 15, 7, 15, 3, 14, 0, 9, 3, 13, 5, 14, 5, 11, 1, 9, 0, 15, 3, 8, 7, 12, 7, 8, 5, 9, 4, 12, 6, 12, 1, 10, 6, 9, 0, 15, 3, 14, 0, 15, 3, 13, 5, 15, 5, 9, 6, 10, 0, 14, 0, 13, 1, 15, 1, 8, 3, 8, 1,
2, 8, 7, 15, 0, 11, 1, 12, 1, 12, 0, 15, 0, 11, 2, 13, 1, 10, 5, 8, 7, 13, 6, 10, 0, 11, 4, 12, 7, 10, 1, 9, 1, 9, 0, 12, 2, 11, 7, 15, 1, 11, 0, 9, 2, 8, 4, 12, 2, 12, 6, 14, 4, 14, 3, 13, 3, 15, 1, 14, 4, 15, 6, 12,
13, 6, 11, 3, 12, 4, 8, 4, 9, 4, 9, 5, 12, 6, 10, 5, 14, 7, 14, 3, 10, 2, 13, 3, 14, 5, 8, 2, 13, 1, 15, 6, 15, 4, 8, 4, 15, 5, 10, 1, 14, 5, 12, 4, 13, 5, 11, 1, 9, 5, 9, 3, 9, 0, 10, 7, 10, 7, 11, 6, 10, 3, 9, 0,
3, 15, 5, 8, 1, 9, 5, 8, 4, 13, 6, 8, 4, 15, 6, 10, 6, 14, 7, 11, 0, 9, 1, 12, 0, 8, 6, 12, 6, 10, 3, 12, 7, 13, 7, 11, 3, 8, 0, 13, 7, 12, 0, 15, 4, 12, 5, 8, 4, 15, 5, 10, 0, 15, 3, 15, 1, 8, 1, 15, 4, 14, 6, 15,
10, 6, 14, 0, 13, 4, 13, 1, 9, 1, 13, 3, 11, 2, 12, 1, 8, 3, 12, 3, 14, 6, 8, 4, 15, 4, 8, 3, 15, 1, 9, 6, 11, 2, 14, 3, 13, 7, 10, 4, 10, 3, 8, 7, 11, 2, 12, 1, 11, 1, 14, 3, 9, 6, 9, 7, 13, 5, 11, 7, 10, 2, 9, 3,
1, 9, 0, 14, 7, 12, 7, 14, 5, 9, 6, 10, 6, 14, 6, 15, 1, 14, 7, 10, 3, 12, 0, 14, 5, 9, 6, 8, 1, 12, 0, 13, 2, 8, 4, 9, 6, 15, 0, 14, 4, 10, 7, 11, 5, 14, 2, 8, 4, 15, 3, 8, 7, 13, 1, 9, 0, 15, 0, 14, 5, 14, 0, 14,
15, 4, 10, 6, 11, 1, 10, 2, 14, 3, 15, 1, 10, 3, 10, 3, 8, 4, 12, 3, 10, 6, 9, 6, 14, 2, 12, 3, 11, 4, 9, 6, 12, 5, 15, 0, 10, 3, 8, 4, 14, 1, 14, 3, 11, 2, 12, 7, 11, 2, 12, 6, 10, 1, 13, 4, 11, 4, 10, 5, 11, 2, 11, 7,
0, 8, 1, 11, 4, 8, 4, 10, 6, 11, 3, 10, 6, 10, 6, 8, 1, 11, 1, 15, 7, 15, 6, 9, 1, 9, 7, 8, 0, 14, 5, 12, 3, 13, 4, 12, 0, 15, 5, 12, 1, 12, 7, 9, 6, 8, 3, 15, 0, 13, 6, 15, 7, 15, 7, 13, 2, 15, 1, 14, 2, 15, 0, 8,
12, 5, 13, 5, 15, 1, 12, 1, 15, 1, 14, 6, 14, 2, 14, 2, 14, 6, 11, 6, 11, 3, 12, 2, 13, 6, 15, 3, 9, 5, 8, 2, 8, 5, 9, 1, 9, 4, 9, 2, 8, 4, 13, 1, 13, 0, 11, 6, 11, 6, 9, 2, 11, 3, 10, 1, 10, 6, 9, 6, 11, 7, 15, 5,
5, 12, 0, 9, 5, 8, 5, 9, 0, 10, 2, 13, 4, 8, 5, 14, 2, 9, 2, 15, 4, 8, 2, 8, 0, 12, 6, 12, 0, 10, 5, 15, 4, 9, 3, 13, 0, 9, 4, 15, 1, 14, 1, 9, 0, 9, 2, 14, 6, 12, 0, 15, 7, 9, 2, 9, 0, 15, 6, 10, 3, 15, 3, 13,
9, 1, 15, 5, 12, 3, 14, 0, 15, 7, 8, 5, 14, 1, 11, 1, 13, 6, 10, 7, 13, 0, 14, 5, 10, 7, 11, 3, 15, 6, 11, 1, 12, 2, 8, 4, 13, 5, 10, 2, 10, 6, 13, 5, 13, 4, 10, 5, 9, 3, 8, 4, 12, 1, 12, 5, 11, 6, 14, 3, 11, 7, 11, 7,
2, 11, 4, 12, 7, 8, 3, 15, 3, 11, 4, 11, 7, 10, 1, 10, 2, 10, 0, 11, 4, 12, 0, 10, 1, 8, 7, 11, 1, 10, 1, 15, 7, 10, 2, 11, 1, 9, 6, 14, 2, 11, 1, 14, 4, 12, 2, 13, 1, 9, 5, 8, 7, 11, 7, 10, 7, 15, 4, 13, 3, 10, 1, 11,
13, 5, 8, 0, 15, 3, 11, 6, 12, 7, 15, 3, 15, 1, 15, 4, 14, 5, 13, 6, 8, 1, 15, 6, 13, 5, 12, 2, 15, 4, 9, 4, 15, 3, 14, 6, 14, 5, 9, 3, 12, 6, 11, 5, 8, 2, 9, 5, 12, 5, 15, 1, 13, 3, 14, 2, 8, 0, 8, 0, 12, 7, 15, 5,
0, 14, 1, 8, 2, 8, 2, 15, 2, 9, 6, 12, 0, 12, 7, 12, 7, 13, 0, 15, 6, 14, 5, 11, 1, 12, 5, 8, 5, 8, 1, 14, 0, 10, 4, 12, 6, 9, 6, 8, 0, 9, 0, 15, 4, 15, 5, 13, 1, 15, 5, 12, 7, 10, 6, 14, 4, 9, 6, 15, 0, 15, 7, 13,
10, 4, 13, 5, 13, 5, 11, 5, 12, 5, 9, 3, 9, 4, 8, 3, 9, 3, 10, 6, 11, 1, 15, 2, 8, 5, 15, 1, 13, 2, 11, 6, 14, 6, 8, 2, 15, 3, 14, 3, 13, 6, 9, 6, 9, 0, 10, 2, 10, 7, 11, 1, 15, 3, 9, 3, 13, 3, 10, 3, 9, 4, 10, 1,
4, 11, 7, 10, 2, 14, 4, 15, 3, 15, 2, 15, 7, 10, 2, 14, 1, 8, 0, 15, 2, 8, 1, 12, 2, 13, 1, 8, 7, 12, 6, 11, 1, 10, 4, 11, 2, 15, 0, 13, 0, 12, 7, 11, 5, 12, 7, 8, 6, 15, 4, 12, 7, 10, 6, 10, 0, 10, 0, 11, 4, 12, 7, 10,
13, 2, 14, 2, 10, 7, 11, 1, 11, 7, 11, 7, 12, 3, 11, 7, 13, 4, 11, 6, 12, 5, 11, 6, 10, 7, 13, 4, 11, 3, 15, 3, 14, 4, 15, 3, 8, 5, 10, 7, 10, 6, 15, 3, 9, 3, 15, 1, 11, 3, 9, 0, 15, 1, 15, 3, 15, 4, 13, 5, 8, 3, 15, 3,
3, 9, 1, 12, 4, 14, 0, 11, 7, 15, 1, 11, 3, 14, 0, 11, 5, 10, 2, 10, 2, 8, 6, 14, 7, 11, 0, 10, 7, 14, 7, 15, 6, 9, 6, 9, 1, 12, 7, 9, 4, 8, 7, 13, 0, 13, 6, 12, 6, 8, 1, 9, 1, 15, 4, 12, 0, 12, 4, 10, 0, 13, 0, 12,
13, 5, 10, 6, 9, 1, 13, 6, 11, 0, 14, 7, 11, 7, 14, 5, 15, 2, 13, 5, 15, 4, 9, 2, 13, 3, 14, 7, 10, 3, 10, 3, 12, 3, 12, 2, 8, 5, 15, 3, 13, 3, 11, 3, 10, 4, 9, 3, 15, 1, 14, 4, 11, 6, 10, 3, 8, 4, 13, 0, 10, 4, 8, 5,
5, 8, 3, 13, 4, 14, 1, 13, 7, 9, 2, 14, 4, 14, 4, 12, 7, 10, 6, 10, 5, 12, 2, 11, 6, 12, 7, 13, 4, 11, 2, 11, 3, 8, 5, 15, 2, 10, 1, 9, 2, 12, 0, 12, 0, 10, 1, 12, 0, 9, 7, 10, 0, 15, 4, 9, 0, 8, 1, 14, 4, 14, 4, 13,
12, 2, 8, 6, 10, 0, 8, 5, 13, 3, 8, 5, 10, 3, 11, 2, 15, 0, 13, 3, 8, 2, 15, 6, 9, 1, 8, 3, 14, 1, 15, 5, 14, 7, 8, 0, 12, 6, 15, 5, 8, 5, 9, 4, 15, 5, 8, 5, 15, 4, 12, 3, 9, 6, 12, 3, 13, 5, 11, 7, 10, 1, 8, 3,
4, 15, 2, 11, 2, 10, 6, 11, 3, 14, 7, 15, 0, 10, 0, 14, 3, 12, 4, 8, 7, 9, 3, 11, 0, 13, 2, 12, 2, 13, 5, 8, 5, 8, 2, 11, 4, 12, 2, 10, 7, 8, 6, 10, 7, 12, 7, 11, 0, 15, 7, 8, 7, 15, 0, 9, 2, 12, 6, 13, 0, 9, 4, 9,
8, 3, 12, 5, 15, 5, 13, 1, 8, 7, 8, 3, 12, 5, 9, 5, 9, 6, 14, 1, 12, 3, 15, 7, 10, 7, 8, 5, 8, 5, 15, 0, 13, 1, 14, 7, 9, 1, 14, 7, 13, 2, 12, 3, 8, 1, 13, 3, 8, 4, 12, 0, 11, 3, 12, 5, 11, 5, 9, 3, 12, 6, 14, 2,
5, 13, 2, 8, 6, 12, 7, 10, 5, 14, 4, 11, 2, 11, 2, 13, 2, 13, 5, 10, 5, 9, 0, 10, 7, 13, 4, 15, 2, 9, 1, 9, 5, 9, 6, 10, 4, 12, 5, 12, 4, 10, 3, 14, 3, 15, 1, 8, 4, 12, 5, 8, 5, 14, 7, 11, 7, 15, 5, 11, 2, 13, 1, 9,
10, 0, 13, 6, 10, 2, 15, 3, 8, 1, 12, 2, 14, 6, 8, 5, 10, 7, 13, 1, 13, 1, 12, 7, 9, 1, 9, 2, 12, 5, 12, 4, 12, 3, 12, 2, 9, 0, 8, 1, 15, 1, 10, 7, 10, 6, 12, 4, 11, 1, 14, 2, 11, 0, 14, 1, 9, 2, 12, 2, 8, 5, 13, 5,
6, 10, 7, 11, 0, 9, 3, 9, 5, 11, 0, 8, 0, 13, 2, 13, 4, 13, 5, 9, 4, 8, 2, 8, 0, 10, 0, 14, 6, 9, 6, 9, 4, 14, 7, 9, 0, 11, 7, 10, 7, 11, 7, 14, 4, 14, 5, 15, 4, 8, 4, 11, 5, 14, 0, 8, 1, 14, 7, 14, 2, 11, 7, 13,
12, 3, 13, 3, 14, 5, 15, 6, 12, 0, 15, 4, 11, 5, 9, 5, 9, 2, 14, 1, 12, 1, 13, 5, 15, 4, 11, 7, 12, 1, 13, 2, 8, 1, 12, 0, 15, 6, 14, 2, 14, 3, 10, 1, 11, 3, 11, 0, 12, 1, 15, 2, 11, 1, 12, 4, 9, 4, 10, 2, 13, 6, 10, 2,
2, 8, 4, 8, 4, 9, 0, 9, 2, 15, 5, 9, 6, 11, 7, 14, 0, 9, 2, 12, 2, 8, 0, 10, 1, 9, 7, 8, 2, 9, 1, 11, 2, 11, 2, 8, 1, 9, 1, 11, 7, 13, 6, 11, 1, 11, 0, 9, 2, 13, 4, 14, 1, 15, 2, 8, 7, 15, 0, 13, 6, 9, 4, 13,
13, 5, 13, 1, 14, 0, 12, 6, 9, 6, 12, 0, 13, 0, 11, 3, 13, 6, 11, 7, 12, 5, 14, 6, 14, 5, 15, 3, 13, 6, 14, 7, 15, 6, 15, 5, 13, 4, 14, 5, 8, 2, 14, 3, 14, 6, 14, 5, 10, 6, 10, 2, 9, 5, 15, 5, 11, 1, 8, 5, 13, 3, 11, 2,
2, 8, 6, 8, 0, 9, 1, 15, 0, 11, 4, 15, 7, 8, 4, 8, 1, 13, 7, 11, 1, 13, 5, 15, 1, 15, 2, 9, 0, 13, 5, 12, 3, 12, 2, 8, 1, 10, 1, 13, 5, 15, 3, 9, 3, 9, 2, 12, 5, 14, 6, 13, 1, 9, 6, 9, 1, 8, 4, 15, 7, 10, 7, 15,
14, 5, 14, 3, 12, 4, 10, 7, 12, 7, 8, 2, 12, 1, 13, 2, 11, 4, 13, 3, 8, 5, 8, 1, 10, 7, 12, 6, 9, 5, 8, 0, 8, 7, 14, 5, 13, 6, 8, 4, 8, 2, 12, 6, 13, 5, 8, 7, 8, 3, 10, 3, 13, 4, 12, 1, 13, 4, 11, 1, 14, 3, 8, 1,
2, 13, 6, 10, 0, 9, 1, 15, 0, 12, 4, 11, 2, 9, 0, 9, 0, 13, 1, 8, 0, 11, 5, 9, 6, 13, 2, 15, 2, 12, 7, 12, 6, 15, 2, 14, 1, 13, 1, 14, 4, 11, 2, 14, 1, 9, 0, 15, 1, 12, 5, 14, 6, 13, 2, 15, 3, 9, 1, 15, 7, 8, 1, 14,
11, 7, 13, 3, 15, 6, 8, 4, 8, 4, 14, 2, 14, 6, 13, 6, 11, 4, 14, 4, 15, 4, 14, 3, 10, 2, 10, 5, 9, 6, 9, 3, 9, 1, 11, 6, 9, 4, 8, 4, 15, 0, 8, 4, 13, 4, 9, 4, 9, 5, 9, 3, 10, 2, 9, 5, 12, 6, 8, 4, 12, 0, 11, 4,
4, 10, 4, 13, 1, 12, 7, 8, 0, 13, 4, 12, 2, 13, 1, 14, 7, 15, 3, 8, 7, 12, 3, 10, 4, 9, 4, 11, 7, 8, 2, 11, 2, 10, 0, 12, 1, 14, 6, 14, 7, 13, 7, 11, 3, 10, 0, 10, 4, 9, 3, 13, 0, 13, 7, 8, 7, 9, 7, 11, 2, 8, 1, 14,
15, 0, 11, 1, 9, 6, 15, 3, 10, 7, 9, 1, 9, 7, 10, 7, 10, 1, 12, 5, 8, 1, 15, 7, 13, 3, 12, 2, 13, 2, 14, 7, 14, 5, 10, 4, 8, 4, 11, 1, 10, 3, 14, 0, 14, 6, 14, 5, 13, 2, 8, 7, 10, 7, 13, 2, 14, 2, 13, 2, 14, 5, 11, 6,
7, 11, 5, 13, 1, 11, 7, 8, 5, 14, 4, 13, 1, 14, 5, 10, 2, 15, 4, 13, 7, 11, 7, 10, 1, 8, 5, 9, 4, 12, 7, 10, 1, 13, 7, 13, 7, 11, 0, 14, 5, 14, 2, 14, 4, 12, 4, 13, 7, 13, 7, 8, 2, 14, 2, 13, 5, 9, 5, 9, 2, 8, 1, 10,
12, 0, 8, 2, 13, 4, 12, 1, 11, 1, 10, 1, 10, 4, 12, 2, 11, 5, 8, 1, 15, 3, 14, 1, 13, 4, 14, 2, 9, 2, 12, 2, 8, 4, 8, 2, 12, 3, 10, 6, 11, 0, 11, 7, 10, 1, 9, 2, 10, 0, 13, 1, 11, 7, 10, 6, 13, 1, 12, 1, 12, 6, 14, 7,
2, 14, 4, 15, 7, 14, 5, 8, 4, 13, 2, 10, 4, 13, 0, 13, 1, 11, 1, 12, 7, 12, 6, 13, 4, 13, 4, 13, 2, 12, 2, 13, 1, 13, 7, 10, 2, 11, 2, 10, 7, 15, 7, 11, 5, 13, 2, 8, 2, 14, 4, 9, 2, 14, 0, 8, 1, 8, 7, 10, 5, 15, 6, 14,
11, 7, 10, 2, 11, 1, 13, 0, 11, 1, 15, 7, 8, 1, 9, 4, 13, 4, 8, 4, 8, 3, 10, 0, 9, 0, 9, 2, 9, 7, 9, 6, 10, 7, 13, 1, 13, 7, 14, 6, 11, 3, 12, 2, 8, 2, 12, 5, 11, 5, 12, 2, 10, 5, 14, 4, 12, 4, 13, 2, 9, 1, 10, 0,
2, 12, 0, 13, 7, 13, 2, 12, 4, 8, 1, 12, 4, 13, 6, 11, 7, 13, 7, 13, 1, 9, 7, 10, 2, 10, 1, 9, 2, 10, 1, 11, 6, 9, 4, 13, 2, 10, 0, 10, 2, 14, 0, 13, 7, 10, 7, 10, 0, 12, 0, 9, 0, 13, 2, 13, 1, 9, 0, 15, 2, 14, 2, 13,
11, 7, 8, 4, 10, 2, 10, 7, 12, 1, 11, 7, 8, 2, 13, 1, 10, 0, 10, 2, 13, 6, 14, 0, 14, 7, 13, 6, 14, 5, 13, 4, 15, 1, 10, 2, 13, 7, 13, 7, 9, 4, 9, 6, 13, 3, 13, 3, 8, 4, 13, 4, 10, 6, 10, 5, 12, 4, 10, 7, 11, 6, 9, 6,
4, 14, 6, 11, 7, 13, 6, 10, 4, 8, 4, 11, 6, 8, 5, 13, 7, 14, 7, 14, 1, 9, 0, 12, 1, 9, 1, 12, 4, 14, 7, 10, 4, 13, 7, 13, 7, 11, 4, 10, 1, 11, 7, 13, 4, 12, 1, 10, 4, 12, 2, 8, 2, 12, 2, 10, 2, 12, 1, 12, 4, 12, 2, 12,
8, 2, 13, 2, 8, 1, 13, 1, 12, 1, 12, 2, 12, 2, 11, 1, 9, 2, 11, 3, 12, 4, 8, 4, 12, 4, 10, 6, 10, 1, 13, 2, 11, 2, 10, 1, 12, 0, 14, 2, 14, 4, 9, 2, 8, 1, 13, 4, 8, 0, 12, 4, 11, 6, 12, 6, 11, 7, 10, 7, 11, 2, 10, 7
};
/*static const uint8_t dither_matrix_halftone8[4 + 8*8] = {
8, 8, 64, 3,
60, 53, 42, 26, 27, 43, 54, 61,
52, 41, 25, 13, 14, 28, 44, 55,
40, 24, 12, 5, 6, 15, 29, 45,
39, 23, 4, 0, 1, 7, 16, 30,
38, 22, 11, 3, 2, 8, 17, 31,
51, 37, 21, 10, 9, 18, 32, 46,
59, 50, 36, 20, 19, 33, 47, 56,
63, 58, 49, 35, 34, 48, 57, 62
}; */
static const uint8_t dither_matrix_diagonal45_8[4 + 8*8] = {
8, 8, 64, 2,
16, 32, 48, 56, 40, 24, 8, 0,
36, 52, 60, 44, 28, 12, 4, 20,
49, 57, 41, 25, 9, 1, 17, 33,
61, 45, 29, 13, 5, 21, 37, 53,
42, 26, 10, 2, 18, 34, 50, 58,
30, 14, 6, 22, 38, 54, 62, 46,
11, 3, 19, 35, 51, 59, 43, 27,
7, 23, 39, 55, 63, 47, 31, 15
};
typedef struct halftone_pixelinfo {
int x;
int y;
double distance;
double angle;
} halftone_pixelinfo;
static inline halftone_pixelinfo* halftone_pixel_make(int w, int h) {
int x, y, k;
halftone_pixelinfo* hp = Gif_NewArray(halftone_pixelinfo, w * h);
for (y = k = 0; y != h; ++y)
for (x = 0; x != w; ++x, ++k) {
hp[k].x = x;
hp[k].y = y;
hp[k].distance = -1;
}
return hp;
}
static inline void halftone_pixel_combine(halftone_pixelinfo* hp,
double cx, double cy) {
double d = (hp->x - cx) * (hp->x - cx) + (hp->y - cy) * (hp->y - cy);
if (hp->distance < 0 || d < hp->distance) {
hp->distance = d;
hp->angle = atan2(hp->y - cy, hp->x - cx);
}
}
static inline int halftone_pixel_compare(const void* va, const void* vb) {
const halftone_pixelinfo* a = (const halftone_pixelinfo*) va;
const halftone_pixelinfo* b = (const halftone_pixelinfo*) vb;
if (fabs(a->distance - b->distance) > 0.01)
return a->distance < b->distance ? -1 : 1;
else
return a->angle < b->angle ? -1 : 1;
}
static uint8_t* halftone_pixel_matrix(halftone_pixelinfo* hp,
int w, int h, int nc) {
int i;
uint8_t* m = Gif_NewArray(uint8_t, 4 + w * h);
m[0] = w;
m[1] = h;
m[3] = nc;
if (w * h > 255) {
double s = 255. / (w * h);
m[2] = 255;
for (i = 0; i != w * h; ++i)
m[4 + hp[i].x + hp[i].y*w] = (int) (i * s);
} else {
m[2] = w * h;
for (i = 0; i != w * h; ++i)
m[4 + hp[i].x + hp[i].y*w] = i;
}
Gif_DeleteArray(hp);
return m;
}
static uint8_t* make_halftone_matrix_square(int w, int h, int nc) {
halftone_pixelinfo* hp = halftone_pixel_make(w, h);
int i;
for (i = 0; i != w * h; ++i)
halftone_pixel_combine(&hp[i], (w-1)/2.0, (h-1)/2.0);
qsort(hp, w * h, sizeof(*hp), halftone_pixel_compare);
return halftone_pixel_matrix(hp, w, h, nc);
}
static uint8_t* make_halftone_matrix_triangular(int w, int h, int nc) {
halftone_pixelinfo* hp = halftone_pixel_make(w, h);
int i;
for (i = 0; i != w * h; ++i) {
halftone_pixel_combine(&hp[i], (w-1)/2.0, (h-1)/2.0);
halftone_pixel_combine(&hp[i], -0.5, -0.5);
halftone_pixel_combine(&hp[i], w-0.5, -0.5);
halftone_pixel_combine(&hp[i], -0.5, h-0.5);
halftone_pixel_combine(&hp[i], w-0.5, h-0.5);
}
qsort(hp, w * h, sizeof(*hp), halftone_pixel_compare);
return halftone_pixel_matrix(hp, w, h, nc);
}
int set_dither_type(Gt_OutputData* od, const char* name) {
int parm[4], nparm = 0;
const char* comma = strchr(name, ',');
char buf[256];
/* separate arguments from dither name */
if (comma && (size_t) (comma - name) < sizeof(buf)) {
memcpy(buf, name, comma - name);
buf[comma - name] = 0;
name = buf;
}
for (nparm = 0;
comma && *comma && isdigit((unsigned char) comma[1]);
++nparm)
parm[nparm] = strtol(&comma[1], (char**) &comma, 10);
/* parse dither name */
if (od->dither_type == dither_ordered_new)
Gif_DeleteArray(od->dither_data);
od->dither_type = dither_none;
if (strcmp(name, "none") == 0 || strcmp(name, "posterize") == 0)
/* ok */;
else if (strcmp(name, "default") == 0)
od->dither_type = dither_default;
else if (strcmp(name, "floyd-steinberg") == 0
|| strcmp(name, "fs") == 0)
od->dither_type = dither_floyd_steinberg;
else if (strcmp(name, "o3") == 0 || strcmp(name, "o3x3") == 0
|| (strcmp(name, "o") == 0 && nparm >= 1 && parm[0] == 3)) {
od->dither_type = dither_ordered;
od->dither_data = dither_matrix_o3x3;
} else if (strcmp(name, "o4") == 0 || strcmp(name, "o4x4") == 0
|| (strcmp(name, "o") == 0 && nparm >= 1 && parm[0] == 4)) {
od->dither_type = dither_ordered;
od->dither_data = dither_matrix_o4x4;
} else if (strcmp(name, "o8") == 0 || strcmp(name, "o8x8") == 0
|| (strcmp(name, "o") == 0 && nparm >= 1 && parm[0] == 8)) {
od->dither_type = dither_ordered;
od->dither_data = dither_matrix_o8x8;
} else if (strcmp(name, "ro64") == 0 || strcmp(name, "ro64x64") == 0
|| strcmp(name, "o") == 0 || strcmp(name, "ordered") == 0) {
od->dither_type = dither_ordered;
od->dither_data = dither_matrix_ro64x64;
} else if (strcmp(name, "diag45") == 0 || strcmp(name, "diagonal") == 0) {
od->dither_type = dither_ordered;
od->dither_data = dither_matrix_diagonal45_8;
} else if (strcmp(name, "halftone") == 0 || strcmp(name, "half") == 0
|| strcmp(name, "trihalftone") == 0
|| strcmp(name, "trihalf") == 0) {
int size = nparm >= 1 && parm[0] > 0 ? parm[0] : 6;
int ncol = nparm >= 2 && parm[1] > 1 ? parm[1] : 2;
od->dither_type = dither_ordered_new;
od->dither_data = make_halftone_matrix_triangular(size, (int) (size * sqrt(3) + 0.5), ncol);
} else if (strcmp(name, "sqhalftone") == 0 || strcmp(name, "sqhalf") == 0
|| strcmp(name, "squarehalftone") == 0) {
int size = nparm >= 1 && parm[0] > 0 ? parm[0] : 6;
int ncol = nparm >= 2 && parm[1] > 1 ? parm[1] : 2;
od->dither_type = dither_ordered_new;
od->dither_data = make_halftone_matrix_square(size, size, ncol);
} else
return -1;
if (od->dither_type == dither_ordered
&& nparm >= 2 && parm[1] > 1 && parm[1] != od->dither_data[3]) {
int size = od->dither_data[0] * od->dither_data[1];
uint8_t* dd = Gif_NewArray(uint8_t, 4 + size);
memcpy(dd, od->dither_data, 4 + size);
dd[3] = parm[1];
od->dither_data = dd;
od->dither_type = dither_ordered_new;
}
return 0;
}
| 41.386148 | 259 | 0.498916 |
8374cd43086c894f20f84d5e6856e00abebfeeaf | 22,447 | c | C | orte/util/session_dir.c | abouteiller/ulfm-legacy | 720dfbd7d522b67b8ff0b3e1321676a1870c7fc8 | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | orte/util/session_dir.c | abouteiller/ulfm-legacy | 720dfbd7d522b67b8ff0b3e1321676a1870c7fc8 | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | orte/util/session_dir.c | abouteiller/ulfm-legacy | 720dfbd7d522b67b8ff0b3e1321676a1870c7fc8 | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | /*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#include "orte_config.h"
#include "orte/constants.h"
#include <stdio.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <errno.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif /* HAVE_DIRENT_H */
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif /* HAVE_PWD_H */
#include "opal/util/argv.h"
#include "opal/util/output.h"
#include "opal/util/os_path.h"
#include "opal/util/os_dirpath.h"
#include "opal/util/basename.h"
#include "opal/util/opal_environ.h"
#include "orte/util/proc_info.h"
#include "orte/util/name_fns.h"
#include "orte/util/show_help.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/runtime/runtime.h"
#include "orte/runtime/orte_globals.h"
#include "orte/util/session_dir.h"
/*******************************
* Local function Declarations
*******************************/
static int orte_create_dir(char *directory);
static bool orte_dir_check_file(const char *root, const char *path);
static bool orte_dir_check_file_output(const char *root, const char *path);
static char *orte_build_job_session_dir(char *top_dir,
orte_process_name_t *proc,
orte_jobid_t jobid);
#define OMPI_PRINTF_FIX_STRING(a) ((NULL == a) ? "(null)" : a)
/****************************
* Funcationality
****************************/
/*
* Check and create the directory requested
*/
static int orte_create_dir(char *directory)
{
mode_t my_mode = S_IRWXU; /* I'm looking for full rights */
int ret;
/* Sanity check before creating the directory with the proper mode,
* Make sure it doesn't exist already */
if( ORTE_ERR_NOT_FOUND !=
(ret = opal_os_dirpath_access(directory, my_mode)) ) {
/* Failure because opal_os_dirpath_access() indicated that either:
* - The directory exists and we can access it (no need to create it again),
* return OPAL_SUCCESS, or
* - don't have access rights, return OPAL_ERROR
*/
if (ORTE_SUCCESS != ret) {
ORTE_ERROR_LOG(ret);
}
return(ret);
}
/* Get here if the directory doesn't exist, so create it */
if (ORTE_SUCCESS != (ret = opal_os_dirpath_create(directory, my_mode))) {
ORTE_ERROR_LOG(ret);
}
return ret;
}
/*
* Construct the fullpath to the session directory
*/
int
orte_session_dir_get_name(char **fulldirpath,
char **return_prefix, /* This will come back as the valid tmp dir */
char **return_frontend,
char *hostid,
char *batchid,
orte_process_name_t *proc) {
char *hostname = NULL,
*batchname = NULL,
*sessions = NULL,
*user = NULL,
*prefix = NULL,
*frontend = NULL,
*jobfam = NULL,
*job = NULL,
*vpidstr = NULL;
bool prefix_provided = false;
int exit_status = ORTE_SUCCESS;
size_t len;
#ifndef __WINDOWS__
int uid;
#else
#define INFO_BUF_SIZE 256
TCHAR info_buf[INFO_BUF_SIZE];
DWORD info_buf_length = INFO_BUF_SIZE;
#endif
/* Ensure that system info is set */
orte_proc_info();
#ifndef __WINDOWS__
uid = getuid();
#if OPAL_ENABLE_GETPWUID
{
struct passwd *pwdent;
/* get the name of the user */
#ifdef HAVE_GETPWUID
pwdent = getpwuid(uid);
#else
pwdent = NULL;
#endif
if (NULL != pwdent) {
user = strdup(pwdent->pw_name);
}
}
#endif
if (NULL == user) {
if (0 > asprintf(&user, "%d", uid)) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
}
#else
if (!GetUserName(info_buf, &info_buf_length)) {
user = strdup("unknown");
} else {
user = strdup(info_buf);
}
#endif
/*
* set the 'hostname'
*/
if( NULL != hostid) { /* User specified version */
hostname = strdup(hostid);
}
else { /* check if it is set elsewhere */
if( NULL != orte_process_info.nodename)
hostname = strdup(orte_process_info.nodename);
else {
/* Couldn't find it, so fail */
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
exit_status = ORTE_ERR_BAD_PARAM;
goto cleanup;
}
}
/*
* set the 'batchid'
*/
if (NULL != batchid)
batchname = strdup(batchid);
else
batchname = strdup("0");
/*
* get the front part of the session directory
* Will look something like:
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID
*/
if (NULL != orte_process_info.top_session_dir) {
frontend = strdup(orte_process_info.top_session_dir);
}
else { /* If not set then construct it */
if (0 > asprintf(&frontend, "openmpi-sessions-%s@%s_%s", user, hostname, batchname)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
}
/*
* Construct the session directory
*/
/* If we were given a valid vpid then we can construct it fully into:
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/JOB-FAMILY/JOBID/VPID
*/
if( NULL != proc) {
if (ORTE_VPID_INVALID != proc->vpid) {
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(proc->jobid))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
if (ORTE_SUCCESS != orte_util_convert_vpid_to_string(&vpidstr, proc->vpid)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
sessions = opal_os_path( false, frontend, jobfam, job, vpidstr, NULL );
if( NULL == sessions ) {
ORTE_ERROR_LOG(ORTE_ERROR);
exit_status = ORTE_ERROR;
goto cleanup;
}
}
/* If we were given a valid jobid then we can construct it partially into:
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/JOB-FAMILY/JOBID
*/
else if (ORTE_JOBID_INVALID != proc->jobid) {
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(proc->jobid))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
sessions = opal_os_path( false, frontend, jobfam, job, NULL );
if( NULL == sessions ) {
ORTE_ERROR_LOG(ORTE_ERROR);
exit_status = ORTE_ERROR;
goto cleanup;
}
} /* if both are invalid */
else {
sessions = strdup(frontend); /* must dup this to avoid double-free later */
}
} /* If we were not given a proc at all, then we just set it to frontend
*/
else {
sessions = strdup(frontend); /* must dup this to avoid double-free later */
}
/*
* If the user specified an invalid prefix, or no prefix at all
* we need to keep looking
*/
if( NULL != fulldirpath && NULL != *fulldirpath) {
free(*fulldirpath);
*fulldirpath = NULL;
}
if( NULL != return_prefix && NULL != *return_prefix) { /* use the user specified one, if available */
prefix = strdup(*return_prefix);
prefix_provided = true;
}
/* Try to find a proper alternative prefix */
else if (NULL != orte_process_info.tmpdir_base) { /* stored value */
prefix = strdup(orte_process_info.tmpdir_base);
}
else { /* General Environment var */
prefix = strdup(opal_tmp_directory());
}
len = strlen(prefix);
/* check for a trailing path separator */
if (OPAL_PATH_SEP[0] == prefix[len-1]) {
prefix[len-1] = '\0';
}
/* BEFORE doing anything else, check to see if this prefix is
* allowed by the system
*/
if (NULL != orte_prohibited_session_dirs) {
char **list;
int i, len;
/* break the string into tokens - it should be
* separated by ','
*/
list = opal_argv_split(orte_prohibited_session_dirs, ',');
len = opal_argv_count(list);
/* cycle through the list */
for (i=0; i < len; i++) {
/* check if prefix matches */
if (0 == strncmp(prefix, list[i], strlen(list[i]))) {
/* this is a prohibited location */
orte_show_help("help-orte-runtime.txt",
"orte:session:dir:prohibited",
true, prefix, orte_prohibited_session_dirs);
return ORTE_ERR_FATAL;
}
}
opal_argv_free(list); /* done with this */
}
/*
* Construct the absolute final path, if requested
*/
if (NULL != fulldirpath) {
*fulldirpath = opal_os_path(false, prefix, sessions, NULL);
}
/*
* Return the frontend and prefix, if user requested we do so
*/
if (NULL != return_frontend) {
*return_frontend = strdup(frontend);
}
if (!prefix_provided && NULL != return_prefix) {
*return_prefix = strdup(prefix);
}
cleanup:
if(NULL != hostname)
free(hostname);
if(NULL != batchname)
free(batchname);
if(NULL != sessions)
free(sessions);
if(NULL != user)
free(user);
if (NULL != prefix) free(prefix);
if (NULL != frontend) free(frontend);
if (NULL != jobfam) free(jobfam);
if (NULL != job) free(job);
if (NULL != vpidstr) free(vpidstr);
return exit_status;
}
/*
* Construct the session directory and create it if necessary
*/
int orte_session_dir(bool create,
char *prefix, char *hostid,
char *batchid, orte_process_name_t *proc)
{
char *fulldirpath = NULL,
*frontend = NULL,
*sav = NULL;
int rc = ORTE_SUCCESS;
char *local_prefix = NULL;
/* use the specified prefix, if one was given */
if (NULL != prefix) {
local_prefix = strdup(prefix);
}
/*
* Get the session directory full name
*/
if( ORTE_SUCCESS != ( rc = orte_session_dir_get_name(&fulldirpath,
&local_prefix,
&frontend,
hostid,
batchid, proc) ) ) {
if (ORTE_ERR_FATAL == rc) {
/* this indicates we should abort quietly */
rc = ORTE_ERR_SILENT;
goto cleanup;
}
/* otherwise, bark a little first */
ORTE_ERROR_LOG(rc);
goto cleanup;
}
/*
* Now that we have the full path, go ahead and create it if necessary
*/
if( create ) {
if( ORTE_SUCCESS != (rc = orte_create_dir(fulldirpath) ) ) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
}
/*
* if we are not creating, then just verify that the path is OK
*/
else {
if( ORTE_SUCCESS != (rc = opal_os_dirpath_access(fulldirpath, 0) )) {
/* it is okay for the path not to be found - don't error
* log that case, but do error log others
*/
if (ORTE_ERR_NOT_FOUND != rc) {
ORTE_ERROR_LOG(rc);
}
goto cleanup;
}
}
/*
* If we are creating the directory tree, then force overwrite of the
* global structure fields
*/
if (create) {
if (NULL != orte_process_info.tmpdir_base) {
free(orte_process_info.tmpdir_base);
orte_process_info.tmpdir_base = NULL;
}
if (NULL != orte_process_info.top_session_dir) {
free(orte_process_info.top_session_dir);
orte_process_info.top_session_dir = NULL;
}
}
/*
* Update some of the global structures if they are empty
*/
if (NULL == orte_process_info.tmpdir_base) {
orte_process_info.tmpdir_base = strdup(local_prefix);
}
if (NULL == orte_process_info.top_session_dir &&
NULL != frontend) {
orte_process_info.top_session_dir = strdup(frontend);
}
/*
* Set the process session directory
*/
if (ORTE_VPID_INVALID != proc->vpid) {
if (create) { /* overwrite if creating */
if (NULL != orte_process_info.proc_session_dir) {
free(orte_process_info.proc_session_dir);
orte_process_info.proc_session_dir = NULL;
}
}
if (NULL == orte_process_info.proc_session_dir) {
orte_process_info.proc_session_dir = strdup(fulldirpath);
}
/* Strip off last part of directory structure */
sav = opal_dirname(fulldirpath);
free(fulldirpath);
fulldirpath = sav;
sav = NULL;
}
/*
* Set the job session directory
*/
if (ORTE_JOBID_INVALID != proc->jobid) {
if (create) { /* overwrite if creating */
if (NULL != orte_process_info.job_session_dir) {
free(orte_process_info.job_session_dir);
orte_process_info.job_session_dir = NULL;
}
}
if (NULL == orte_process_info.job_session_dir) {
orte_process_info.job_session_dir = strdup(fulldirpath);
}
}
if (orte_debug_flag) {
opal_output(0, "procdir: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.proc_session_dir));
opal_output(0, "jobdir: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.job_session_dir));
opal_output(0, "top: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.top_session_dir));
opal_output(0, "tmp: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.tmpdir_base));
}
cleanup:
if (NULL != local_prefix) {
free(local_prefix);
}
if(NULL != fulldirpath) {
free(fulldirpath);
}
if(NULL != frontend) {
free(frontend);
}
return rc;
}
/*
* A job has aborted - so force cleanup of the session directory
*/
int
orte_session_dir_cleanup(orte_jobid_t jobid)
{
int rc = ORTE_SUCCESS;
char *tmp;
char *job_session_dir=NULL;
if (!orte_create_session_dirs) {
/* didn't create them */
return ORTE_SUCCESS;
}
/* need to setup the top_session_dir with the prefix */
tmp = opal_os_path(false,
orte_process_info.tmpdir_base,
orte_process_info.top_session_dir, NULL);
/* we can only blow away session directories for our job family */
job_session_dir = orte_build_job_session_dir(tmp, ORTE_PROC_MY_NAME, jobid);
if (NULL == job_session_dir) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
if (ORTE_JOBID_WILDCARD != jobid) {
opal_os_dirpath_destroy(job_session_dir, true, orte_dir_check_file);
} else {
/* if we want the session_dir removed for ALL jobids, then
* just recursively blow the whole session away for our job family,
* saving only output files
*/
opal_os_dirpath_destroy(job_session_dir, true, orte_dir_check_file_output);
}
/* now attempt to eliminate the top level directory itself - this
* will fail if anything is present, but ensures we cleanup if
* we are the last one out
*/
opal_os_dirpath_destroy(tmp, false, orte_dir_check_file);
if (NULL != job_session_dir && opal_os_dirpath_is_empty(job_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
}
rmdir(job_session_dir);
} else {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");
}
goto CLEANUP;
}
if (opal_os_dirpath_is_empty(tmp)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
}
rmdir(tmp);
} else {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");
}
}
CLEANUP:
free(tmp);
if (NULL != job_session_dir) free(job_session_dir);
return rc;
}
int
orte_session_dir_finalize(orte_process_name_t *proc)
{
int rc;
char *tmp;
char *job_session_dir, *vpid, *proc_session_dir;
if (!orte_create_session_dirs) {
/* didn't create them */
return ORTE_SUCCESS;
}
/* need to setup the top_session_dir with the prefix */
tmp = opal_os_path(false,
orte_process_info.tmpdir_base,
orte_process_info.top_session_dir, NULL);
/* define the proc and job session directories for this process */
if (ORTE_SUCCESS != (rc = orte_util_convert_vpid_to_string(&vpid, proc->vpid))) {
ORTE_ERROR_LOG(rc);
free(tmp);
return rc;
}
job_session_dir = orte_build_job_session_dir(tmp, proc, proc->jobid);
if( NULL == job_session_dir) {
free(tmp);
free(vpid);
return ORTE_ERR_OUT_OF_RESOURCE;
}
proc_session_dir = opal_os_path( false, job_session_dir, vpid, NULL );
if( NULL == proc_session_dir ) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
free(tmp);
free(vpid);
free(job_session_dir);
return ORTE_ERR_OUT_OF_RESOURCE;
}
opal_os_dirpath_destroy(proc_session_dir,
false, orte_dir_check_file);
opal_os_dirpath_destroy(job_session_dir,
false, orte_dir_check_file);
opal_os_dirpath_destroy(tmp,
false, orte_dir_check_file);
if (opal_os_dirpath_is_empty(proc_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found proc session dir empty - deleting");
}
rmdir(proc_session_dir);
} else {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: proc session dir not empty - leaving");
}
goto CLEANUP;
}
if (opal_os_dirpath_is_empty(job_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
}
rmdir(job_session_dir);
} else {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");
}
goto CLEANUP;
}
if (opal_os_dirpath_is_empty(tmp)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
}
rmdir(tmp);
} else {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");
}
}
CLEANUP:
free(tmp);
free(vpid);
free(job_session_dir);
free(proc_session_dir);
return ORTE_SUCCESS;
}
static bool
orte_dir_check_file(const char *root, const char *path)
{
/*
* Keep:
* - files starting with "output-"
* - files that indicate abort
*/
if( (0 == strncmp(path, "output-", strlen("output-"))) ||
(0 == strcmp(path, "abort"))) {
return false;
}
return true;
}
static bool
orte_dir_check_file_output(const char *root, const char *path)
{
/*
* Keep:
* - files starting with "output-"
*/
if( 0 == strncmp(path, "output-", strlen("output-"))) {
return false;
}
return true;
}
static char *orte_build_job_session_dir(char *top_dir,
orte_process_name_t *proc,
orte_jobid_t jobid)
{
char *jobfam = NULL;
char *job_session_dir;
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return NULL;
}
if (ORTE_JOBID_WILDCARD != jobid) {
char *job = NULL;
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(jobid))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
job_session_dir = NULL;
goto out;
}
job_session_dir = opal_os_path(false, top_dir, jobfam, job, NULL);
free(job);
if (NULL == job_session_dir) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
}
} else {
job_session_dir = opal_os_path(false, top_dir, jobfam, NULL);
if( NULL == job_session_dir) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
}
}
out:
free(jobfam);
return job_session_dir;
}
| 30.252022 | 106 | 0.575088 |
83763e0a170f936d69917ca86a5bcce266c60ab8 | 5,254 | h | C | ios/Pods/Google-Mobile-Ads-SDK/GoogleMobileAdsSdkiOS-7.7.1/Mediation Adapters/GADMAdNetworkAdapterProtocol.h | qwe11345/hk.ncloud.emotion1 | 8b755585ccbafd5c65f68af1a956743d784ee173 | [
"MIT"
] | null | null | null | ios/Pods/Google-Mobile-Ads-SDK/GoogleMobileAdsSdkiOS-7.7.1/Mediation Adapters/GADMAdNetworkAdapterProtocol.h | qwe11345/hk.ncloud.emotion1 | 8b755585ccbafd5c65f68af1a956743d784ee173 | [
"MIT"
] | null | null | null | ios/Pods/Google-Mobile-Ads-SDK/GoogleMobileAdsSdkiOS-7.7.1/Mediation Adapters/GADMAdNetworkAdapterProtocol.h | qwe11345/hk.ncloud.emotion1 | 8b755585ccbafd5c65f68af1a956743d784ee173 | [
"MIT"
] | null | null | null | //
// GADMAdNetworkAdapterProtocol.h
// Google Mobile Ads SDK
//
// Copyright 2011 Google. All rights reserved.
//
#import <GoogleMobileAds/GoogleMobileAds.h>
#import "GADMAdNetworkConnectorProtocol.h"
#import "GADMEnums.h"
/// Subclasses should prefix their name with "GADMAdapter" example: GADMAdapterGoogleAdMobAds
#define kGADMAdapterClassNamePrefix @"GADMAdapter"
@protocol GADMAdNetworkConnector;
@protocol GADMAdNetworkAdapter<NSObject>
/// Returns a version string for the adapter. It can be any string that uniquely identifies the
/// version of your adapter. For example, "1.0", or simply a date such as "20110915".
+ (NSString *)adapterVersion;
/// The extras class that is used to specify additional parameters for a request to this ad network.
/// Returns Nil if the network does not have extra settings for publishers to send.
+ (Class<GADAdNetworkExtras>)networkExtrasClass;
/// Designated initializer. Implementing classes can and should keep the connector in an instance
/// variable. However you must never retain the connector, as doing so will create a circular
/// reference and cause memory leaks.
- (instancetype)initWithGADMAdNetworkConnector:(id<GADMAdNetworkConnector>)connector;
/// Asks the adapter to initiate a banner ad request. The adapter does not need to return anything.
/// The assumption is that the adapter will start an asynchronous ad fetch over the network. Your
/// adapter may act as a delegate to your SDK to listen to callbacks. If your SDK does not support
/// the given ad size, or does not support banner ads, call back to the adapter:didFailAd: method of
/// the connector.
- (void)getBannerWithSize:(GADAdSize)adSize;
/// Asks the adapter to initiate an interstitial ad request. The adapter does not need to return
/// anything. The assumption is that the adapter will start an asynchronous ad fetch over the
/// network. Your adapter may act as a delegate to your SDK to listen to callbacks. If your SDK does
/// not support interstitials, call back to the adapter:didFailInterstitial: method of the
/// connector.
- (void)getInterstitial;
/// When called, the adapter must remove itself as a delegate or notification observer from the
/// underlying ad network SDK. You should also call this method in your adapter dealloc, so when
/// your adapter goes away, your SDK will not call a freed object. This function should be
/// idempotent and should not crash regardless of when or how many times the method is called.
- (void)stopBeingDelegate;
/// Some ad transition types may cause issues with particular Ad SDKs. The adapter may decide
/// whether the given animation type is OK. Defaults to YES.
- (BOOL)isBannerAnimationOK:(GADMBannerAnimationType)animType;
/// Present an interstitial using the supplied UIViewController, by calling
/// presentViewController:animated:completion:.
///
/// Your interstitial should not immediately present itself when it is received. Instead, you should
/// wait until this method is called on your adapter to present the interstitial.
///
/// Make sure to call adapterWillPresentInterstitial: on the connector when the interstitial is
/// about to be presented, and adapterWillDismissInterstitial: and adapterDidDismissInterstitial:
/// when the interstitial is being dismissed.
- (void)presentInterstitialFromRootViewController:(UIViewController *)rootViewController;
@optional
/// Starts request for a native ad. |adTypes| contains the list of native ad types requested. See
/// GADAdLoaderAdTypes.h for available ad types. |options| are any additional options configured by
/// the publisher for requesting a native ad. See GADNativeAdImageAdLoaderOptions.h for available
/// image options. When this method is called the receiver may start native ad request
/// asynchronously. On completion the receiver should notify the Google Mobile Ads SDK with a native
/// ad object using the receiver's connector method
/// adapter:didReceiveNativeAdDataSource:mediationDelegate or adapter:didFailAd: if the ad request
/// encountered an error.
- (void)getNativeAdWithAdTypes:(NSArray *)adTypes options:(NSArray *)options;
/// Indicates if the adapter handles user clicks. Return YES if the adapter should handle user
/// clicks. In this case Google Mobile Ads SDK doesn't track user click and the adapter should
/// notify the click to Google Mobile Ads SDK using method
/// + [GADMediatedNativeAdNotificationSource mediatedNativeAdDidRecordClick:]. Return NO if the
/// adapter doesn't handles user clicks. In this case Google Mobile Ads SDK will track user clicks
/// and the adapter is notified about the user clicks using method - [GADMediatedNativeAdDelegate
/// mediatedNativeAd:didRecordClickOnAssetWithName:view:viewController:].
- (BOOL)handlesUserClicks;
/// If your ad network handles multiple ad sizes for the same banner ad, implement this method to
/// know when the user changes the banner size. This is typically changing from
/// kGADAdSizeSmartBannerPortrait to kGADAdSizeSmartBannerLandscape, or vice versa. If this method
/// is not implemented, every time the user changes the ad size, a new ad will be requested with the
/// new size by calling your getBannerWithSize: method.
- (void)changeAdSizeTo:(GADAdSize)adSize;
@end
| 54.164948 | 100 | 0.786639 |
837c8faa979f6a6a6882a333f518f1eab6e9a920 | 494 | h | C | libgdsup/include/gd/bits/types/gid_t.h | matt-gretton-dann/gd-posix-apps | 3abf398269203883c8e13511d811c7d6f0cb1cf8 | [
"Apache-2.0"
] | null | null | null | libgdsup/include/gd/bits/types/gid_t.h | matt-gretton-dann/gd-posix-apps | 3abf398269203883c8e13511d811c7d6f0cb1cf8 | [
"Apache-2.0"
] | 164 | 2020-12-30T11:35:34.000Z | 2021-05-24T12:58:26.000Z | libgdsup/include/gd/bits/types/gid_t.h | matt-gretton-dann/gd-posix-apps | 3abf398269203883c8e13511d811c7d6f0cb1cf8 | [
"Apache-2.0"
] | null | null | null | /** \file libgdsup/include/bits/types/uid_t.h
* \brief Define the pid_t type.
* \author Copyright 2021, Matthew Gretton-Dann
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef LIBGDSUP_INCLUDE_BITS_TYPES_GID_T_H_INCLUDED
#define LIBGDSUP_INCLUDE_BITS_TYPES_GID_T_H_INCLUDED
#ifdef _WIN32
# include <stdint.h>
/** On Windows we map group IDs to intptrs so we can handle them as Pointers too. */
typedef intptr_t gid_t;
#endif
#endif // LIBGDSUP_INCLUDE_BITS_TYPES_UID_T_H_INCLUDED
| 29.058824 | 85 | 0.775304 |
837d30f06bf079635678de60cf780c3a883b5f5c | 544 | h | C | Classes/TLMonthYearPicker.h | galihmdev/TLMonthYearPicker | 3c03a6deac535e57280abf856e415fce262664bd | [
"MIT"
] | 6 | 2017-11-19T14:42:47.000Z | 2021-07-05T02:51:13.000Z | Classes/TLMonthYearPicker.h | galihmdev/TLMonthYearPicker | 3c03a6deac535e57280abf856e415fce262664bd | [
"MIT"
] | 1 | 2017-11-02T17:04:59.000Z | 2018-09-12T04:49:04.000Z | Classes/TLMonthYearPicker.h | galihmdev/TLMonthYearPicker | 3c03a6deac535e57280abf856e415fce262664bd | [
"MIT"
] | 3 | 2018-01-02T05:33:11.000Z | 2021-01-19T02:58:29.000Z | //
// TLMonthYearPicker.h
// TLMonthYearPicker
//
// Created by lee5783 on 12/22/16.
// Copyright © 2016 lee5783. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for TLMonthYearPicker.
FOUNDATION_EXPORT double TLMonthYearPickerVersionNumber;
//! Project version string for TLMonthYearPicker.
FOUNDATION_EXPORT const unsigned char TLMonthYearPickerVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <TLMonthYearPicker/PublicHeader.h>
| 27.2 | 142 | 0.783088 |
837f10968a3e1a143fddf680a6eccdad19ddde78 | 501 | h | C | EiRas/Framework/EiRas/PlatformDependency/OnDX/Mesh/MeshDX12.h | MonsterENT/EiRas | b29592da60b1a9085f5a2d8fa4ed01b43660f712 | [
"MIT"
] | 1 | 2019-12-24T10:12:16.000Z | 2019-12-24T10:12:16.000Z | EiRas/Framework/EiRas/PlatformDependency/OnDX/Mesh/MeshDX12.h | MonsterENT/EiRas | b29592da60b1a9085f5a2d8fa4ed01b43660f712 | [
"MIT"
] | null | null | null | EiRas/Framework/EiRas/PlatformDependency/OnDX/Mesh/MeshDX12.h | MonsterENT/EiRas | b29592da60b1a9085f5a2d8fa4ed01b43660f712 | [
"MIT"
] | null | null | null | #pragma once
#include <PlatformDependency/OnDX/Material/GraphicsResourceDX12.h>
#include <vector>
#include <Global/GlobalDefine.h>
namespace MeshSys
{
class MeshDX12
{
public:
MeshDX12();
std::vector<D3D12_VERTEX_BUFFER_VIEW> VertexBufferViews;
std::vector<D3D12_INDEX_BUFFER_VIEW> IndexBufferViews;
void BuildBufferView(void* rawVertexResObj, _uint vertexBufferSize, _uint vertexCount,
void* rawIndexResObj, _uint indexBufferSize);
};
} | 25.05 | 94 | 0.720559 |
8381dcd4f27b65c26864270b19cdc129acd09000 | 167,422 | h | C | openpilot/uavobjects.h | multigcs/multigcs | bd37e2a81411474c6adc5a51bfaef64656920fa3 | [
"libpng-2.0"
] | 25 | 2015-03-30T20:19:23.000Z | 2021-12-10T06:18:10.000Z | openpilot/uavobjects.h | multigcs/multigcs | bd37e2a81411474c6adc5a51bfaef64656920fa3 | [
"libpng-2.0"
] | null | null | null | openpilot/uavobjects.h | multigcs/multigcs | bd37e2a81411474c6adc5a51bfaef64656920fa3 | [
"libpng-2.0"
] | 16 | 2015-01-02T22:43:29.000Z | 2020-04-22T08:44:36.000Z |
/*************************************************************************************************
Filename: acceldesired.xml
Object: AccelDesired
Comment: The desired acceleration from navigation
*************************************************************************************************/
#define ACCELDESIRED_OBJID 0x3b7c5b62
typedef struct {
float North;
float East;
float Down;
} UAVT_AccelDesiredData;
extern UAVT_AccelDesiredData uavtalk_AccelDesiredData;
/*************************************************************************************************
Filename: accels.xml
Object: Accels
Comment: The accelerometer sensor data, rotated into body frame.
*************************************************************************************************/
#define ACCELS_OBJID 0xdd9d5fc0
typedef struct {
float x;
float y;
float z;
float temperature;
} UAVT_AccelsData;
extern UAVT_AccelsData uavtalk_AccelsData;
/*************************************************************************************************
Filename: accessorydesired.xml
Object: AccessoryDesired
Comment: Desired Auxillary actuator settings. Comes from @ref ManualControlModule.
*************************************************************************************************/
#define ACCESSORYDESIRED_OBJID 0xc409985a
typedef struct {
float AccessoryVal;
} UAVT_AccessoryDesiredData;
extern UAVT_AccessoryDesiredData uavtalk_AccessoryDesiredData;
/*************************************************************************************************
Filename: actuatorcommand.xml
Object: ActuatorCommand
Comment: Contains the pulse duration sent to each of the channels. Set by @ref ActuatorModule
*************************************************************************************************/
#define ACTUATORCOMMAND_OBJID 0x5324cb8
typedef struct {
int16_t Channel[10];
uint16_t MaxUpdateTime;
uint8_t UpdateTime;
uint8_t NumFailedUpdates;
} UAVT_ActuatorCommandData;
extern UAVT_ActuatorCommandData uavtalk_ActuatorCommandData;
/*************************************************************************************************
Filename: actuatordesired.xml
Object: ActuatorDesired
Comment: Desired raw, pitch and yaw actuator settings. Comes from either @ref StabilizationModule or @ref ManualControlModule depending on FlightMode.
*************************************************************************************************/
#define ACTUATORDESIRED_OBJID 0xca4bc4a4
typedef struct {
float Roll;
float Pitch;
float Yaw;
float Throttle;
float UpdateTime;
float NumLongUpdates;
} UAVT_ActuatorDesiredData;
extern UAVT_ActuatorDesiredData uavtalk_ActuatorDesiredData;
/*************************************************************************************************
Filename: actuatorsettings.xml
Object: ActuatorSettings
Comment: Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType
*************************************************************************************************/
#define ACTUATORSETTINGS_OBJID 0xa3c64272
enum {
ACTUATORSETTINGS_CHANNELTYPE_PWM = 0,
ACTUATORSETTINGS_CHANNELTYPE_MK = 1,
ACTUATORSETTINGS_CHANNELTYPE_ASTEC4 = 2,
ACTUATORSETTINGS_CHANNELTYPE_PWM_ALARM_BUZZER = 3,
ACTUATORSETTINGS_CHANNELTYPE_ARMING_LED = 4,
ACTUATORSETTINGS_CHANNELTYPE_INFO_LED = 5,
ACTUATORSETTINGS_CHANNELTYPE_LASTITEM = 6
};
enum {
ACTUATORSETTINGS_MOTORSSPINWHILEARMED_FALSE = 0,
ACTUATORSETTINGS_MOTORSSPINWHILEARMED_TRUE = 1,
ACTUATORSETTINGS_MOTORSSPINWHILEARMED_LASTITEM = 2
};
extern char UAVT_ActuatorSettingsChannelTypeOption[][42];
extern char UAVT_ActuatorSettingsMotorsSpinWhileArmedOption[][42];
typedef struct {
uint16_t ChannelUpdateFreq[6];
int16_t ChannelMax[10];
int16_t ChannelNeutral[10];
int16_t ChannelMin[10];
uint8_t ChannelType[10]; // enum
uint8_t ChannelAddr[10];
uint8_t MotorsSpinWhileArmed; // enum
} UAVT_ActuatorSettingsData;
extern UAVT_ActuatorSettingsData uavtalk_ActuatorSettingsData;
/*************************************************************************************************
Filename: airspeedactual.xml
Object: AirspeedActual
Comment: UAVO for true airspeed, calibrated airspeed, angle of attack, and angle of slip
*************************************************************************************************/
#define AIRSPEEDACTUAL_OBJID 0x133a3280
typedef struct {
float TrueAirspeed;
float CalibratedAirspeed;
float alpha;
float beta;
} UAVT_AirspeedActualData;
extern UAVT_AirspeedActualData uavtalk_AirspeedActualData;
/*************************************************************************************************
Filename: airspeedsettings.xml
Object: AirspeedSettings
Comment: Settings for the @ref BaroAirspeed module used on CopterControl or Revolution
*************************************************************************************************/
#define AIRSPEEDSETTINGS_OBJID 0x63f679c
enum {
AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_EAGLETREEAIRSPEEDV3 = 0,
AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_DIYDRONESMPXV5004 = 1,
AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_DIYDRONESMPXV7002 = 2,
AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_GPSONLY = 3,
AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_LASTITEM = 4
};
enum {
AIRSPEEDSETTINGS_ANALOGPIN_ADC0 = 0,
AIRSPEEDSETTINGS_ANALOGPIN_ADC1 = 1,
AIRSPEEDSETTINGS_ANALOGPIN_ADC2 = 2,
AIRSPEEDSETTINGS_ANALOGPIN_ADC3 = 3,
AIRSPEEDSETTINGS_ANALOGPIN_ADC4 = 4,
AIRSPEEDSETTINGS_ANALOGPIN_ADC5 = 5,
AIRSPEEDSETTINGS_ANALOGPIN_ADC6 = 6,
AIRSPEEDSETTINGS_ANALOGPIN_ADC7 = 7,
AIRSPEEDSETTINGS_ANALOGPIN_ADC8 = 8,
AIRSPEEDSETTINGS_ANALOGPIN_NONE = 9,
AIRSPEEDSETTINGS_ANALOGPIN_LASTITEM = 10
};
extern char UAVT_AirspeedSettingsAirspeedSensorTypeOption[][42];
extern char UAVT_AirspeedSettingsAnalogPinOption[][42];
typedef struct {
float Scale;
uint16_t ZeroPoint;
uint8_t GPSSamplePeriod_ms;
uint8_t AirspeedSensorType; // enum
uint8_t AnalogPin; // enum
} UAVT_AirspeedSettingsData;
extern UAVT_AirspeedSettingsData uavtalk_AirspeedSettingsData;
/*************************************************************************************************
Filename: altitudeholddesired.xml
Object: AltitudeHoldDesired
Comment: Holds the desired altitude (from manual control) as well as the desired attitude to pass through
*************************************************************************************************/
#define ALTITUDEHOLDDESIRED_OBJID 0xe7b9c87a
enum {
ALTITUDEHOLDDESIRED_LAND_FALSE = 0,
ALTITUDEHOLDDESIRED_LAND_TRUE = 1,
ALTITUDEHOLDDESIRED_LAND_LASTITEM = 2
};
extern char UAVT_AltitudeHoldDesiredLandOption[][42];
typedef struct {
float Altitude;
float ClimbRate;
float Roll;
float Pitch;
float Yaw;
uint8_t Land; // enum
} UAVT_AltitudeHoldDesiredData;
extern UAVT_AltitudeHoldDesiredData uavtalk_AltitudeHoldDesiredData;
/*************************************************************************************************
Filename: altitudeholdsettings.xml
Object: AltitudeHoldSettings
Comment: Settings for the @ref AltitudeHold module
*************************************************************************************************/
#define ALTITUDEHOLDSETTINGS_OBJID 0x93e52e4c
typedef struct {
float PositionKp;
float VelocityKp;
float VelocityKi;
uint16_t AttitudeComp;
uint8_t MaxRate;
uint8_t Expo;
uint8_t Deadband;
} UAVT_AltitudeHoldSettingsData;
extern UAVT_AltitudeHoldSettingsData uavtalk_AltitudeHoldSettingsData;
/*************************************************************************************************
Filename: attitudeactual.xml
Object: AttitudeActual
Comment: The updated Attitude estimation from @ref AHRSCommsModule.
*************************************************************************************************/
#define ATTITUDEACTUAL_OBJID 0x33dad5e6
typedef struct {
float q1;
float q2;
float q3;
float q4;
float Roll;
float Pitch;
float Yaw;
} UAVT_AttitudeActualData;
extern UAVT_AttitudeActualData uavtalk_AttitudeActualData;
/*************************************************************************************************
Filename: attitudesettings.xml
Object: AttitudeSettings
Comment: Settings for the @ref Attitude module used on CopterControl
*************************************************************************************************/
#define ATTITUDESETTINGS_OBJID 0x2257cf36
enum {
ATTITUDESETTINGS_ZERODURINGARMING_FALSE = 0,
ATTITUDESETTINGS_ZERODURINGARMING_TRUE = 1,
ATTITUDESETTINGS_ZERODURINGARMING_LASTITEM = 2
};
enum {
ATTITUDESETTINGS_BIASCORRECTGYRO_FALSE = 0,
ATTITUDESETTINGS_BIASCORRECTGYRO_TRUE = 1,
ATTITUDESETTINGS_BIASCORRECTGYRO_LASTITEM = 2
};
enum {
ATTITUDESETTINGS_FILTERCHOICE_CCC = 0,
ATTITUDESETTINGS_FILTERCHOICE_PREMERLANI = 1,
ATTITUDESETTINGS_FILTERCHOICE_PREMERLANI_GPS = 2,
ATTITUDESETTINGS_FILTERCHOICE_LASTITEM = 3
};
enum {
ATTITUDESETTINGS_TRIMFLIGHT_NORMAL = 0,
ATTITUDESETTINGS_TRIMFLIGHT_START = 1,
ATTITUDESETTINGS_TRIMFLIGHT_LOAD = 2,
ATTITUDESETTINGS_TRIMFLIGHT_LASTITEM = 3
};
extern char UAVT_AttitudeSettingsZeroDuringArmingOption[][42];
extern char UAVT_AttitudeSettingsBiasCorrectGyroOption[][42];
extern char UAVT_AttitudeSettingsFilterChoiceOption[][42];
extern char UAVT_AttitudeSettingsTrimFlightOption[][42];
typedef struct {
int16_t Roll;
int16_t Pitch;
int16_t Yaw;
} UAVT_AttitudeSettingsBoardRotationType;
typedef struct {
float MagKp;
float MagKi;
float AccelKp;
float AccelKi;
float AccelTau;
float VertPositionTau;
float YawBiasRate;
UAVT_AttitudeSettingsBoardRotationType BoardRotation; // int16[3]
uint8_t ZeroDuringArming; // enum
uint8_t BiasCorrectGyro; // enum
uint8_t FilterChoice; // enum
uint8_t TrimFlight; // enum
} UAVT_AttitudeSettingsData;
extern UAVT_AttitudeSettingsData uavtalk_AttitudeSettingsData;
/*************************************************************************************************
Filename: attitudesimulated.xml
Object: AttitudeSimulated
Comment: The simulated Attitude estimation from @ref Sensors.
*************************************************************************************************/
#define ATTITUDESIMULATED_OBJID 0x9266ce74
typedef struct {
float North;
float East;
float Down;
} UAVT_AttitudeSimulatedVelocityType;
typedef struct {
float North;
float East;
float Down;
} UAVT_AttitudeSimulatedPositionType;
typedef struct {
float q1;
float q2;
float q3;
float q4;
float Roll;
float Pitch;
float Yaw;
UAVT_AttitudeSimulatedVelocityType Velocity; // float[3]
UAVT_AttitudeSimulatedPositionType Position; // float[3]
} UAVT_AttitudeSimulatedData;
extern UAVT_AttitudeSimulatedData uavtalk_AttitudeSimulatedData;
/*************************************************************************************************
Filename: baroairspeed.xml
Object: BaroAirspeed
Comment: The raw data from the dynamic pressure sensor with pressure, temperature and airspeed.
*************************************************************************************************/
#define BAROAIRSPEED_OBJID 0x10d6bd7c
enum {
BAROAIRSPEED_BAROCONNECTED_FALSE = 0,
BAROAIRSPEED_BAROCONNECTED_TRUE = 1,
BAROAIRSPEED_BAROCONNECTED_LASTITEM = 2
};
extern char UAVT_BaroAirspeedBaroConnectedOption[][42];
typedef struct {
float CalibratedAirspeed;
float GPSAirspeed;
float TrueAirspeed;
uint16_t SensorValue;
uint8_t BaroConnected; // enum
} UAVT_BaroAirspeedData;
extern UAVT_BaroAirspeedData uavtalk_BaroAirspeedData;
/*************************************************************************************************
Filename: baroaltitude.xml
Object: BaroAltitude
Comment: The raw data from the barometric sensor with pressure, temperature and altitude estimate.
*************************************************************************************************/
#define BAROALTITUDE_OBJID 0x99622e6a
typedef struct {
float Altitude;
float Temperature;
float Pressure;
} UAVT_BaroAltitudeData;
extern UAVT_BaroAltitudeData uavtalk_BaroAltitudeData;
/*************************************************************************************************
Filename: brushlessgimbalsettings.xml
Object: BrushlessGimbalSettings
Comment: Settings for the @ref BrushlessGimbal module
*************************************************************************************************/
#define BRUSHLESSGIMBALSETTINGS_OBJID 0xb50ddc74
enum {
BRUSHLESSGIMBALSETTINGS_POWERUPSEQUENCE_FALSE = 0,
BRUSHLESSGIMBALSETTINGS_POWERUPSEQUENCE_TRUE = 1,
BRUSHLESSGIMBALSETTINGS_POWERUPSEQUENCE_LASTITEM = 2
};
extern char UAVT_BrushlessGimbalSettingsPowerupSequenceOption[][42];
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_BrushlessGimbalSettingsDampingType;
typedef struct {
uint16_t Roll;
uint16_t Pitch;
uint16_t Yaw;
} UAVT_BrushlessGimbalSettingsMaxDPSType;
typedef struct {
uint16_t Roll;
uint16_t Pitch;
uint16_t Yaw;
} UAVT_BrushlessGimbalSettingsSlewLimitType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_BrushlessGimbalSettingsPowerScaleType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_BrushlessGimbalSettingsMaxAngleType;
typedef struct {
UAVT_BrushlessGimbalSettingsDampingType Damping; // float[3]
UAVT_BrushlessGimbalSettingsMaxDPSType MaxDPS; // uint16[3]
UAVT_BrushlessGimbalSettingsSlewLimitType SlewLimit; // uint16[3]
UAVT_BrushlessGimbalSettingsPowerScaleType PowerScale; // uint8[3]
UAVT_BrushlessGimbalSettingsMaxAngleType MaxAngle; // uint8[3]
uint8_t RollFraction;
uint8_t PowerupSequence; // enum
} UAVT_BrushlessGimbalSettingsData;
extern UAVT_BrushlessGimbalSettingsData uavtalk_BrushlessGimbalSettingsData;
/*************************************************************************************************
Filename: cameradesired.xml
Object: CameraDesired
Comment: Desired camera outputs. Comes from @ref CameraStabilization module.
*************************************************************************************************/
#define CAMERADESIRED_OBJID 0x4622ec88
typedef struct {
float Roll;
float Pitch;
float Yaw;
float Bearing;
float Declination;
} UAVT_CameraDesiredData;
extern UAVT_CameraDesiredData uavtalk_CameraDesiredData;
/*************************************************************************************************
Filename: camerastabsettings.xml
Object: CameraStabSettings
Comment: Settings for the @ref CameraStab mmodule
*************************************************************************************************/
#define CAMERASTABSETTINGS_OBJID 0xfa09a51a
enum {
CAMERASTABSETTINGS_INPUT_ACCESSORY0 = 0,
CAMERASTABSETTINGS_INPUT_ACCESSORY1 = 1,
CAMERASTABSETTINGS_INPUT_ACCESSORY2 = 2,
CAMERASTABSETTINGS_INPUT_ACCESSORY3 = 3,
CAMERASTABSETTINGS_INPUT_ACCESSORY4 = 4,
CAMERASTABSETTINGS_INPUT_ACCESSORY5 = 5,
CAMERASTABSETTINGS_INPUT_POI = 6,
CAMERASTABSETTINGS_INPUT_NONE = 7,
CAMERASTABSETTINGS_INPUT_LASTITEM = 8
};
enum {
CAMERASTABSETTINGS_STABILIZATIONMODE_ATTITUDE = 0,
CAMERASTABSETTINGS_STABILIZATIONMODE_AXISLOCK = 1,
CAMERASTABSETTINGS_STABILIZATIONMODE_LASTITEM = 2
};
extern char UAVT_CameraStabSettingsInputOption[][42];
extern char UAVT_CameraStabSettingsStabilizationModeOption[][42];
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_CameraStabSettingsInputType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_CameraStabSettingsInputRangeType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_CameraStabSettingsInputRateType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_CameraStabSettingsOutputRangeType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_CameraStabSettingsFeedForwardType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_CameraStabSettingsStabilizationModeType;
typedef struct {
float MaxAxisLockRate;
float MaxAccel;
UAVT_CameraStabSettingsInputType Input; // enum[3]
UAVT_CameraStabSettingsInputRangeType InputRange; // uint8[3]
UAVT_CameraStabSettingsInputRateType InputRate; // uint8[3]
UAVT_CameraStabSettingsOutputRangeType OutputRange; // uint8[3]
UAVT_CameraStabSettingsFeedForwardType FeedForward; // uint8[3]
UAVT_CameraStabSettingsStabilizationModeType StabilizationMode; // enum[3]
uint8_t AttitudeFilter;
uint8_t InputFilter;
uint8_t FeedForwardTime;
} UAVT_CameraStabSettingsData;
extern UAVT_CameraStabSettingsData uavtalk_CameraStabSettingsData;
/*************************************************************************************************
Filename: faultsettings.xml
Object: FaultSettings
Comment: Allows testers to simulate various fault scenarios.
*************************************************************************************************/
#define FAULTSETTINGS_OBJID 0x2778ba3c
enum {
FAULTSETTINGS_ACTIVATEFAULT_NOFAULT = 0,
FAULTSETTINGS_ACTIVATEFAULT_MODULEINITASSERT = 1,
FAULTSETTINGS_ACTIVATEFAULT_INITOUTOFMEMORY = 2,
FAULTSETTINGS_ACTIVATEFAULT_INITBUSERROR = 3,
FAULTSETTINGS_ACTIVATEFAULT_RUNAWAYTASK = 4,
FAULTSETTINGS_ACTIVATEFAULT_TASKOUTOFMEMORY = 5,
FAULTSETTINGS_ACTIVATEFAULT_LASTITEM = 6
};
extern char UAVT_FaultSettingsActivateFaultOption[][42];
typedef struct {
uint8_t ActivateFault; // enum
} UAVT_FaultSettingsData;
extern UAVT_FaultSettingsData uavtalk_FaultSettingsData;
/*************************************************************************************************
Filename: firmwareiapobj.xml
Object: FirmwareIAPObj
Comment: Queries board for SN, model, revision, and sends reset command
*************************************************************************************************/
#define FIRMWAREIAPOBJ_OBJID 0x5e6e8fdc
typedef struct {
uint32_t crc;
uint16_t Command;
uint16_t BoardRevision;
uint8_t Description[100];
uint8_t CPUSerial[12];
uint8_t BoardType;
uint8_t ArmReset;
} UAVT_FirmwareIAPObjData;
extern UAVT_FirmwareIAPObjData uavtalk_FirmwareIAPObjData;
/*************************************************************************************************
Filename: fixedwingairspeeds.xml
Object: FixedWingAirspeeds
Comment: Settings for the @ref FixedWingPathFollowerModule
*************************************************************************************************/
#define FIXEDWINGAIRSPEEDS_OBJID 0x3fcf7f6
typedef struct {
float AirSpeedMax;
float CruiseSpeed;
float BestClimbRateSpeed;
float StallSpeedClean;
float StallSpeedDirty;
float VerticalVelMax;
} UAVT_FixedWingAirspeedsData;
extern UAVT_FixedWingAirspeedsData uavtalk_FixedWingAirspeedsData;
/*************************************************************************************************
Filename: fixedwingpathfollowersettingscc.xml
Object: FixedWingPathFollowerSettingsCC
Comment: Settings for the @ref FixedWingPathFollowerModule
*************************************************************************************************/
#define FIXEDWINGPATHFOLLOWERSETTINGSCC_OBJID 0xc4623504
typedef struct {
float Kp;
float Max;
} UAVT_FixedWingPathFollowerSettingsCCVerticalToPitchCrossFeedType;
typedef struct {
float Kp;
float Max;
} UAVT_FixedWingPathFollowerSettingsCCAirspeedToVerticalCrossFeedType;
typedef struct {
float VerticalVelMax;
float VectorFollowingGain;
float OrbitFollowingGain;
float FollowerIntegralGain;
float VerticalPosP;
float HeadingPI[3];
float AirspeedPI[3];
UAVT_FixedWingPathFollowerSettingsCCVerticalToPitchCrossFeedType VerticalToPitchCrossFeed; // float[2]
UAVT_FixedWingPathFollowerSettingsCCAirspeedToVerticalCrossFeedType AirspeedToVerticalCrossFeed; // float[2]
float ThrottlePI[3];
float RollLimit[3];
float PitchLimit[3];
float ThrottleLimit[3];
int16_t UpdatePeriod;
} UAVT_FixedWingPathFollowerSettingsCCData;
extern UAVT_FixedWingPathFollowerSettingsCCData uavtalk_FixedWingPathFollowerSettingsCCData;
/*************************************************************************************************
Filename: fixedwingpathfollowersettings.xml
Object: FixedWingPathFollowerSettings
Comment: Settings for the @ref FixedWingPathFollowerModule
*************************************************************************************************/
#define FIXEDWINGPATHFOLLOWERSETTINGS_OBJID 0x56c316da
typedef struct {
float Kp;
float Max;
} UAVT_FixedWingPathFollowerSettingsVerticalToPitchCrossFeedType;
typedef struct {
float Kp;
float Max;
} UAVT_FixedWingPathFollowerSettingsAirspeedToVerticalCrossFeedType;
typedef struct {
float HorizontalPosP;
float VerticalPosP;
float BearingPI[3];
float PowerPI[3];
UAVT_FixedWingPathFollowerSettingsVerticalToPitchCrossFeedType VerticalToPitchCrossFeed; // float[2]
UAVT_FixedWingPathFollowerSettingsAirspeedToVerticalCrossFeedType AirspeedToVerticalCrossFeed; // float[2]
float SpeedPI[3];
float RollLimit[3];
float PitchLimit[3];
float ThrottleLimit[3];
float OrbitRadius;
int16_t UpdatePeriod;
} UAVT_FixedWingPathFollowerSettingsData;
extern UAVT_FixedWingPathFollowerSettingsData uavtalk_FixedWingPathFollowerSettingsData;
/*************************************************************************************************
Filename: fixedwingpathfollowerstatus.xml
Object: FixedWingPathFollowerStatus
Comment: Object Storing Debugging Information on PID internals
*************************************************************************************************/
#define FIXEDWINGPATHFOLLOWERSTATUS_OBJID 0xaca80808
typedef struct {
float Bearing;
float Speed;
float Accel;
float Power;
} UAVT_FixedWingPathFollowerStatusErrorType;
typedef struct {
float Bearing;
float Speed;
float Accel;
float Power;
} UAVT_FixedWingPathFollowerStatusErrorIntType;
typedef struct {
float Bearing;
float Speed;
float Accel;
float Power;
} UAVT_FixedWingPathFollowerStatusCommandType;
typedef struct {
uint8_t Wind;
uint8_t Stallspeed;
uint8_t Lowspeed;
uint8_t Highspeed;
uint8_t Overspeed;
uint8_t Lowpower;
uint8_t Highpower;
uint8_t Pitchcontrol;
} UAVT_FixedWingPathFollowerStatusErrorsType;
typedef struct {
UAVT_FixedWingPathFollowerStatusErrorType Error; // float[4]
UAVT_FixedWingPathFollowerStatusErrorIntType ErrorInt; // float[4]
UAVT_FixedWingPathFollowerStatusCommandType Command; // float[4]
UAVT_FixedWingPathFollowerStatusErrorsType Errors; // uint8[8]
} UAVT_FixedWingPathFollowerStatusData;
extern UAVT_FixedWingPathFollowerStatusData uavtalk_FixedWingPathFollowerStatusData;
/*************************************************************************************************
Filename: flightbatterysettings.xml
Object: FlightBatterySettings
Comment: Flight Battery configuration.
*************************************************************************************************/
#define FLIGHTBATTERYSETTINGS_OBJID 0x94474ece
enum {
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC0 = 0,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC1 = 1,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC2 = 2,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC3 = 3,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC4 = 4,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC5 = 5,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC6 = 6,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC7 = 7,
FLIGHTBATTERYSETTINGS_CURRENTPIN_ADC8 = 8,
FLIGHTBATTERYSETTINGS_CURRENTPIN_NONE = 9,
FLIGHTBATTERYSETTINGS_CURRENTPIN_LASTITEM = 10
};
enum {
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC0 = 0,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC1 = 1,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC2 = 2,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC3 = 3,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC4 = 4,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC5 = 5,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC6 = 6,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC7 = 7,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_ADC8 = 8,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_NONE = 9,
FLIGHTBATTERYSETTINGS_VOLTAGEPIN_LASTITEM = 10
};
enum {
FLIGHTBATTERYSETTINGS_TYPE_LIPO = 0,
FLIGHTBATTERYSETTINGS_TYPE_A123 = 1,
FLIGHTBATTERYSETTINGS_TYPE_LICO = 2,
FLIGHTBATTERYSETTINGS_TYPE_LIFESO4 = 3,
FLIGHTBATTERYSETTINGS_TYPE_NONE = 4,
FLIGHTBATTERYSETTINGS_TYPE_LASTITEM = 5
};
enum {
FLIGHTBATTERYSETTINGS_SENSORTYPE_DISABLED = 0,
FLIGHTBATTERYSETTINGS_SENSORTYPE_ENABLED = 1,
FLIGHTBATTERYSETTINGS_SENSORTYPE_LASTITEM = 2
};
extern char UAVT_FlightBatterySettingsCurrentPinOption[][42];
extern char UAVT_FlightBatterySettingsVoltagePinOption[][42];
extern char UAVT_FlightBatterySettingsTypeOption[][42];
extern char UAVT_FlightBatterySettingsSensorTypeOption[][42];
typedef struct {
float Warning;
float Alarm;
} UAVT_FlightBatterySettingsVoltageThresholdsType;
typedef struct {
float Voltage;
float Current;
} UAVT_FlightBatterySettingsSensorCalibrationFactorType;
typedef struct {
float Voltage;
float Current;
} UAVT_FlightBatterySettingsSensorCalibrationOffsetType;
typedef struct {
uint8_t BatteryCurrent;
uint8_t BatteryVoltage;
} UAVT_FlightBatterySettingsSensorTypeType;
typedef struct {
uint32_t Capacity;
UAVT_FlightBatterySettingsVoltageThresholdsType VoltageThresholds; // float[2]
UAVT_FlightBatterySettingsSensorCalibrationFactorType SensorCalibrationFactor; // float[2]
UAVT_FlightBatterySettingsSensorCalibrationOffsetType SensorCalibrationOffset; // float[2]
uint8_t CurrentPin; // enum
uint8_t VoltagePin; // enum
uint8_t Type; // enum
uint8_t NbCells;
UAVT_FlightBatterySettingsSensorTypeType SensorType; // enum[2]
} UAVT_FlightBatterySettingsData;
extern UAVT_FlightBatterySettingsData uavtalk_FlightBatterySettingsData;
/*************************************************************************************************
Filename: flightbatterystate.xml
Object: FlightBatteryState
Comment: Battery status information.
*************************************************************************************************/
#define FLIGHTBATTERYSTATE_OBJID 0xd2083596
typedef struct {
float Voltage;
float Current;
float BoardSupplyVoltage;
float PeakCurrent;
float AvgCurrent;
float ConsumedEnergy;
float EstimatedFlightTime;
} UAVT_FlightBatteryStateData;
extern UAVT_FlightBatteryStateData uavtalk_FlightBatteryStateData;
/*************************************************************************************************
Filename: flightplancontrol.xml
Object: FlightPlanControl
Comment: Control the flight plan script
*************************************************************************************************/
#define FLIGHTPLANCONTROL_OBJID 0x53e3f180
enum {
FLIGHTPLANCONTROL_COMMAND_START = 0,
FLIGHTPLANCONTROL_COMMAND_STOP = 1,
FLIGHTPLANCONTROL_COMMAND_KILL = 2,
FLIGHTPLANCONTROL_COMMAND_LASTITEM = 3
};
extern char UAVT_FlightPlanControlCommandOption[][42];
typedef struct {
uint8_t Command; // enum
} UAVT_FlightPlanControlData;
extern UAVT_FlightPlanControlData uavtalk_FlightPlanControlData;
/*************************************************************************************************
Filename: flightplansettings.xml
Object: FlightPlanSettings
Comment: Settings for the flight plan module, control the execution of the script
*************************************************************************************************/
#define FLIGHTPLANSETTINGS_OBJID 0x92e9ff76
typedef struct {
float Test;
} UAVT_FlightPlanSettingsData;
extern UAVT_FlightPlanSettingsData uavtalk_FlightPlanSettingsData;
/*************************************************************************************************
Filename: flightplanstatus.xml
Object: FlightPlanStatus
Comment: Status of the flight plan script
*************************************************************************************************/
#define FLIGHTPLANSTATUS_OBJID 0x3391ec96
enum {
FLIGHTPLANSTATUS_STATE_STOPPED = 0,
FLIGHTPLANSTATUS_STATE_RUNNING = 1,
FLIGHTPLANSTATUS_STATE_ERROR = 2,
FLIGHTPLANSTATUS_STATE_LASTITEM = 3
};
enum {
FLIGHTPLANSTATUS_ERRORTYPE_NONE = 0,
FLIGHTPLANSTATUS_ERRORTYPE_VMINITERROR = 1,
FLIGHTPLANSTATUS_ERRORTYPE_EXCEPTION = 2,
FLIGHTPLANSTATUS_ERRORTYPE_IOERROR = 3,
FLIGHTPLANSTATUS_ERRORTYPE_DIVBYZERO = 4,
FLIGHTPLANSTATUS_ERRORTYPE_ASSERTERROR = 5,
FLIGHTPLANSTATUS_ERRORTYPE_ATTRIBUTEERROR = 6,
FLIGHTPLANSTATUS_ERRORTYPE_IMPORTERROR = 7,
FLIGHTPLANSTATUS_ERRORTYPE_INDEXERROR = 8,
FLIGHTPLANSTATUS_ERRORTYPE_KEYERROR = 9,
FLIGHTPLANSTATUS_ERRORTYPE_MEMORYERROR = 10,
FLIGHTPLANSTATUS_ERRORTYPE_NAMEERROR = 11,
FLIGHTPLANSTATUS_ERRORTYPE_SYNTAXERROR = 12,
FLIGHTPLANSTATUS_ERRORTYPE_SYSTEMERROR = 13,
FLIGHTPLANSTATUS_ERRORTYPE_TYPEERROR = 14,
FLIGHTPLANSTATUS_ERRORTYPE_VALUEERROR = 15,
FLIGHTPLANSTATUS_ERRORTYPE_STOPITERATION = 16,
FLIGHTPLANSTATUS_ERRORTYPE_WARNING = 17,
FLIGHTPLANSTATUS_ERRORTYPE_UNKNOWNERROR = 18,
FLIGHTPLANSTATUS_ERRORTYPE_LASTITEM = 19
};
extern char UAVT_FlightPlanStatusStateOption[][42];
extern char UAVT_FlightPlanStatusErrorTypeOption[][42];
typedef struct {
uint32_t ErrorFileID;
uint32_t ErrorLineNum;
float Debug[2];
uint8_t State; // enum
uint8_t ErrorType; // enum
} UAVT_FlightPlanStatusData;
extern UAVT_FlightPlanStatusData uavtalk_FlightPlanStatusData;
/*************************************************************************************************
Filename: flightstatus.xml
Object: FlightStatus
Comment: Contains major flight status information for other modules.
*************************************************************************************************/
#define FLIGHTSTATUS_OBJID 0xc2e431ba
enum {
FLIGHTSTATUS_ARMED_DISARMED = 0,
FLIGHTSTATUS_ARMED_ARMING = 1,
FLIGHTSTATUS_ARMED_ARMED = 2,
FLIGHTSTATUS_ARMED_LASTITEM = 3
};
enum {
FLIGHTSTATUS_FLIGHTMODE_MANUAL = 0,
FLIGHTSTATUS_FLIGHTMODE_ACRO = 1,
FLIGHTSTATUS_FLIGHTMODE_LEVELING = 2,
FLIGHTSTATUS_FLIGHTMODE_VIRTUALBAR = 3,
FLIGHTSTATUS_FLIGHTMODE_STABILIZED1 = 4,
FLIGHTSTATUS_FLIGHTMODE_STABILIZED2 = 5,
FLIGHTSTATUS_FLIGHTMODE_STABILIZED3 = 6,
FLIGHTSTATUS_FLIGHTMODE_AUTOTUNE = 7,
FLIGHTSTATUS_FLIGHTMODE_ALTITUDEHOLD = 8,
FLIGHTSTATUS_FLIGHTMODE_VELOCITYCONTROL = 9,
FLIGHTSTATUS_FLIGHTMODE_POSITIONHOLD = 10,
FLIGHTSTATUS_FLIGHTMODE_RETURNTOHOME = 11,
FLIGHTSTATUS_FLIGHTMODE_PATHPLANNER = 12,
FLIGHTSTATUS_FLIGHTMODE_TABLETCONTROL = 13,
FLIGHTSTATUS_FLIGHTMODE_LASTITEM = 14
};
enum {
FLIGHTSTATUS_CONTROLSOURCE_GEOFENCE = 0,
FLIGHTSTATUS_CONTROLSOURCE_FAILSAFE = 1,
FLIGHTSTATUS_CONTROLSOURCE_TRANSMITTER = 2,
FLIGHTSTATUS_CONTROLSOURCE_TABLET = 3,
FLIGHTSTATUS_CONTROLSOURCE_LASTITEM = 4
};
extern char UAVT_FlightStatusArmedOption[][42];
extern char UAVT_FlightStatusFlightModeOption[][42];
extern char UAVT_FlightStatusControlSourceOption[][42];
typedef struct {
uint8_t Armed; // enum
uint8_t FlightMode; // enum
uint8_t ControlSource; // enum
} UAVT_FlightStatusData;
extern UAVT_FlightStatusData uavtalk_FlightStatusData;
/*************************************************************************************************
Filename: flighttelemetrystats.xml
Object: FlightTelemetryStats
Comment: Maintains the telemetry statistics from the OpenPilot flight computer.
*************************************************************************************************/
#define FLIGHTTELEMETRYSTATS_OBJID 0x9e5ba136
enum {
FLIGHTTELEMETRYSTATS_STATE_DISCONNECTED = 0,
FLIGHTTELEMETRYSTATS_STATE_HANDSHAKEREQ = 1,
FLIGHTTELEMETRYSTATS_STATE_HANDSHAKEACK = 2,
FLIGHTTELEMETRYSTATS_STATE_CONNECTED = 3,
FLIGHTTELEMETRYSTATS_STATE_LASTITEM = 4
};
extern char UAVT_FlightTelemetryStatsStateOption[][42];
typedef struct {
float TxDataRate;
float RxDataRate;
uint32_t TxFailures;
uint32_t RxFailures;
uint32_t TxRetries;
uint8_t State; // enum
} UAVT_FlightTelemetryStatsData;
extern UAVT_FlightTelemetryStatsData uavtalk_FlightTelemetryStatsData;
/*************************************************************************************************
Filename: gcsreceiver.xml
Object: GCSReceiver
Comment: A receiver channel group carried over the telemetry link.
*************************************************************************************************/
#define GCSRECEIVER_OBJID 0xcc7e1470
typedef struct {
uint16_t Channel[8];
} UAVT_GCSReceiverData;
extern UAVT_GCSReceiverData uavtalk_GCSReceiverData;
/*************************************************************************************************
Filename: gcstelemetrystats.xml
Object: GCSTelemetryStats
Comment: The telemetry statistics from the ground computer
*************************************************************************************************/
#define GCSTELEMETRYSTATS_OBJID 0x708d0a90
enum {
GCSTELEMETRYSTATS_STATE_DISCONNECTED = 0,
GCSTELEMETRYSTATS_STATE_HANDSHAKEREQ = 1,
GCSTELEMETRYSTATS_STATE_HANDSHAKEACK = 2,
GCSTELEMETRYSTATS_STATE_CONNECTED = 3,
GCSTELEMETRYSTATS_STATE_LASTITEM = 4
};
extern char UAVT_GCSTelemetryStatsStateOption[][42];
typedef struct {
float TxDataRate;
float RxDataRate;
uint32_t TxFailures;
uint32_t RxFailures;
uint32_t TxRetries;
uint8_t State; // enum
} UAVT_GCSTelemetryStatsData;
extern UAVT_GCSTelemetryStatsData uavtalk_GCSTelemetryStatsData;
/*************************************************************************************************
Filename: geofencesettings.xml
Object: GeoFenceSettings
Comment: Radius for simple geofence boundaries
*************************************************************************************************/
#define GEOFENCESETTINGS_OBJID 0xdf5ea7fe
typedef struct {
uint16_t WarningRadius;
uint16_t ErrorRadius;
} UAVT_GeoFenceSettingsData;
extern UAVT_GeoFenceSettingsData uavtalk_GeoFenceSettingsData;
/*************************************************************************************************
Filename: gpsposition.xml
Object: GPSPosition
Comment: Raw GPS data from @ref GPSModule. Should only be used by @ref AHRSCommsModule.
*************************************************************************************************/
#define GPSPOSITION_OBJID 0x628ba538
enum {
GPSPOSITION_STATE_NOGPS = 0,
GPSPOSITION_STATE_NOFIX = 1,
GPSPOSITION_STATE_FIX2D = 2,
GPSPOSITION_STATE_FIX3D = 3,
GPSPOSITION_STATE_DIFF3D = 4,
GPSPOSITION_STATE_LASTITEM = 5
};
extern char UAVT_GPSPositionStateOption[][42];
typedef struct {
int32_t Latitude;
int32_t Longitude;
float Altitude;
float GeoidSeparation;
float Heading;
float Groundspeed;
float PDOP;
float HDOP;
float VDOP;
uint8_t State; // enum
int8_t Satellites;
} UAVT_GPSPositionData;
extern UAVT_GPSPositionData uavtalk_GPSPositionData;
/*************************************************************************************************
Filename: gpssatellites.xml
Object: GPSSatellites
Comment: Contains information about the GPS satellites in view from @ref GPSModule.
*************************************************************************************************/
#define GPSSATELLITES_OBJID 0x920d998
typedef struct {
float Elevation[16];
float Azimuth[16];
int8_t SatsInView;
int8_t PRN[16];
int8_t SNR[16];
} UAVT_GPSSatellitesData;
extern UAVT_GPSSatellitesData uavtalk_GPSSatellitesData;
/*************************************************************************************************
Filename: gpstime.xml
Object: GPSTime
Comment: Contains the GPS time from @ref GPSModule. Required to compute the world magnetic model correctly when setting the home location.
*************************************************************************************************/
#define GPSTIME_OBJID 0xd4478084
typedef struct {
int16_t Year;
int8_t Month;
int8_t Day;
int8_t Hour;
int8_t Minute;
int8_t Second;
} UAVT_GPSTimeData;
extern UAVT_GPSTimeData uavtalk_GPSTimeData;
/*************************************************************************************************
Filename: gpsvelocity.xml
Object: GPSVelocity
Comment: Raw GPS data from @ref GPSModule.
*************************************************************************************************/
#define GPSVELOCITY_OBJID 0x8245dc80
typedef struct {
float North;
float East;
float Down;
} UAVT_GPSVelocityData;
extern UAVT_GPSVelocityData uavtalk_GPSVelocityData;
/*************************************************************************************************
Filename: groundpathfollowersettings.xml
Object: GroundPathFollowerSettings
Comment: Settings for the @ref GroundPathFollowerModule
*************************************************************************************************/
#define GROUNDPATHFOLLOWERSETTINGS_OBJID 0x9090c16
enum {
GROUNDPATHFOLLOWERSETTINGS_MANUALOVERRIDE_FALSE = 0,
GROUNDPATHFOLLOWERSETTINGS_MANUALOVERRIDE_TRUE = 1,
GROUNDPATHFOLLOWERSETTINGS_MANUALOVERRIDE_LASTITEM = 2
};
enum {
GROUNDPATHFOLLOWERSETTINGS_THROTTLECONTROL_MANUAL = 0,
GROUNDPATHFOLLOWERSETTINGS_THROTTLECONTROL_PROPORTIONAL = 1,
GROUNDPATHFOLLOWERSETTINGS_THROTTLECONTROL_AUTO = 2,
GROUNDPATHFOLLOWERSETTINGS_THROTTLECONTROL_LASTITEM = 3
};
enum {
GROUNDPATHFOLLOWERSETTINGS_VELOCITYSOURCE_EKF = 0,
GROUNDPATHFOLLOWERSETTINGS_VELOCITYSOURCE_NEDVEL = 1,
GROUNDPATHFOLLOWERSETTINGS_VELOCITYSOURCE_GPSPOS = 2,
GROUNDPATHFOLLOWERSETTINGS_VELOCITYSOURCE_LASTITEM = 3
};
enum {
GROUNDPATHFOLLOWERSETTINGS_POSITIONSOURCE_EKF = 0,
GROUNDPATHFOLLOWERSETTINGS_POSITIONSOURCE_GPSPOS = 1,
GROUNDPATHFOLLOWERSETTINGS_POSITIONSOURCE_LASTITEM = 2
};
extern char UAVT_GroundPathFollowerSettingsManualOverrideOption[][42];
extern char UAVT_GroundPathFollowerSettingsThrottleControlOption[][42];
extern char UAVT_GroundPathFollowerSettingsVelocitySourceOption[][42];
extern char UAVT_GroundPathFollowerSettingsPositionSourceOption[][42];
typedef struct {
float Kp;
float Ki;
float ILimit;
} UAVT_GroundPathFollowerSettingsHorizontalPosPIType;
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_GroundPathFollowerSettingsHorizontalVelPIDType;
typedef struct {
UAVT_GroundPathFollowerSettingsHorizontalPosPIType HorizontalPosPI; // float[3]
UAVT_GroundPathFollowerSettingsHorizontalVelPIDType HorizontalVelPID; // float[4]
float VelocityFeedforward;
float MaxThrottle;
int32_t UpdatePeriod;
uint16_t HorizontalVelMax;
uint8_t ManualOverride; // enum
uint8_t ThrottleControl; // enum
uint8_t VelocitySource; // enum
uint8_t PositionSource; // enum
uint8_t EndpointRadius;
} UAVT_GroundPathFollowerSettingsData;
extern UAVT_GroundPathFollowerSettingsData uavtalk_GroundPathFollowerSettingsData;
/*************************************************************************************************
Filename: groundtruth.xml
Object: GroundTruth
Comment: Ground truth data output by a simulator.
*************************************************************************************************/
#define GROUNDTRUTH_OBJID 0xf178dca8
typedef struct {
float AccelerationXYZ[3];
float PositionNED[3];
float VelocityNED[3];
float RPY[3];
float AngularRates[3];
float TrueAirspeed;
float CalibratedAirspeed;
float AngleOfAttack;
float AngleOfSlip;
} UAVT_GroundTruthData;
extern UAVT_GroundTruthData uavtalk_GroundTruthData;
/*************************************************************************************************
Filename: gyrosbias.xml
Object: GyrosBias
Comment: The online-estimate of gyro bias.
*************************************************************************************************/
#define GYROSBIAS_OBJID 0xe4b6f980
typedef struct {
float x;
float y;
float z;
} UAVT_GyrosBiasData;
extern UAVT_GyrosBiasData uavtalk_GyrosBiasData;
/*************************************************************************************************
Filename: gyros.xml
Object: Gyros
Comment: The rate gyroscope sensor data, in body frame.
*************************************************************************************************/
#define GYROS_OBJID 0x4228af6
typedef struct {
float x;
float y;
float z;
float temperature;
} UAVT_GyrosData;
extern UAVT_GyrosData uavtalk_GyrosData;
/*************************************************************************************************
Filename: homelocation.xml
Object: HomeLocation
Comment: HomeLocation setting which contains the constants to tranlate from longitutde and latitude to NED reference frame. Automatically set by @ref GPSModule after acquiring a 3D lock. Used by @ref AHRSCommsModule.
*************************************************************************************************/
#define HOMELOCATION_OBJID 0xca32b032
enum {
HOMELOCATION_SET_FALSE = 0,
HOMELOCATION_SET_TRUE = 1,
HOMELOCATION_SET_LASTITEM = 2
};
extern char UAVT_HomeLocationSetOption[][42];
typedef struct {
int32_t Latitude;
int32_t Longitude;
float Altitude;
float Be[3];
int16_t GroundTemperature;
uint16_t SeaLevelPressure;
uint8_t Set; // enum
} UAVT_HomeLocationData;
extern UAVT_HomeLocationData uavtalk_HomeLocationData;
/*************************************************************************************************
Filename: hottsettings.xml
Object: HoTTSettings
Comment: Settings for the @ref HoTT Telemetry Module
*************************************************************************************************/
#define HOTTSETTINGS_OBJID 0x6cbc1102
enum {
HOTTSETTINGS_SENSOR_DISABLED = 0,
HOTTSETTINGS_SENSOR_ENABLED = 1,
HOTTSETTINGS_SENSOR_LASTITEM = 2
};
enum {
HOTTSETTINGS_WARNING_DISABLED = 0,
HOTTSETTINGS_WARNING_ENABLED = 1,
HOTTSETTINGS_WARNING_LASTITEM = 2
};
extern char UAVT_HoTTSettingsSensorOption[][42];
extern char UAVT_HoTTSettingsWarningOption[][42];
typedef struct {
float MinSpeed;
float MaxSpeed;
float NegDifference1;
float PosDifference1;
float NegDifference2;
float PosDifference2;
float MinHeight;
float MaxHeight;
float MaxDistance;
float MinPowerVoltage;
float MaxPowerVoltage;
float MinSensor1Voltage;
float MaxSensor1Voltage;
float MinSensor2Voltage;
float MaxSensor2Voltage;
float MinCellVoltage;
float MaxCurrent;
float MaxUsedCapacity;
float MinSensor1Temp;
float MaxSensor1Temp;
float MinSensor2Temp;
float MaxSensor2Temp;
float MaxServoTemp;
float MinRPM;
float MaxRPM;
float MinFuel;
float MaxServoDifference;
} UAVT_HoTTSettingsLimitType;
typedef struct {
uint8_t VARIO;
uint8_t GPS;
uint8_t EAM;
uint8_t GAM;
uint8_t ESC;
} UAVT_HoTTSettingsSensorType;
typedef struct {
uint8_t AltitudeBeep;
uint8_t MinSpeed;
uint8_t MaxSpeed;
uint8_t NegDifference1;
uint8_t PosDifference1;
uint8_t NegDifference2;
uint8_t PosDifference2;
uint8_t MinHeight;
uint8_t MaxHeight;
uint8_t MaxDistance;
uint8_t MinPowerVoltage;
uint8_t MaxPowerVoltage;
uint8_t MinSensor1Voltage;
uint8_t MaxSensor1Voltage;
uint8_t MinSensor2Voltage;
uint8_t MaxSensor2Voltage;
uint8_t MinCellVoltage;
uint8_t MaxCurrent;
uint8_t MaxUsedCapacity;
uint8_t MinSensor1Temp;
uint8_t MaxSensor1Temp;
uint8_t MinSensor2Temp;
uint8_t MaxSensor2Temp;
uint8_t MaxServoTemp;
uint8_t MinRPM;
uint8_t MaxRPM;
uint8_t MinFuel;
uint8_t MaxServoDifference;
} UAVT_HoTTSettingsWarningType;
typedef struct {
UAVT_HoTTSettingsLimitType Limit; // float[27]
UAVT_HoTTSettingsSensorType Sensor; // enum[5]
UAVT_HoTTSettingsWarningType Warning; // enum[28]
} UAVT_HoTTSettingsData;
extern UAVT_HoTTSettingsData uavtalk_HoTTSettingsData;
/*************************************************************************************************
Filename: hwcolibri.xml
Object: HwColibri
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWCOLIBRI_OBJID 0xa0c92448
enum {
HWCOLIBRI_FRAME_GEMINI = 0,
HWCOLIBRI_FRAME_LASTITEM = 1
};
enum {
HWCOLIBRI_RCVRPORT_DISABLED = 0,
HWCOLIBRI_RCVRPORT_PWM = 1,
HWCOLIBRI_RCVRPORT_PWM_ADC = 2,
HWCOLIBRI_RCVRPORT_PPM = 3,
HWCOLIBRI_RCVRPORT_PPM_ADC = 4,
HWCOLIBRI_RCVRPORT_PPM_PWM = 5,
HWCOLIBRI_RCVRPORT_PPM_PWM_ADC = 6,
HWCOLIBRI_RCVRPORT_PPM_OUTPUTS = 7,
HWCOLIBRI_RCVRPORT_PPM_OUTPUTS_ADC = 8,
HWCOLIBRI_RCVRPORT_OUTPUTS = 9,
HWCOLIBRI_RCVRPORT_OUTPUTS_ADC = 10,
HWCOLIBRI_RCVRPORT_LASTITEM = 11
};
enum {
HWCOLIBRI_UART1_DISABLED = 0,
HWCOLIBRI_UART1_TELEMETRY = 1,
HWCOLIBRI_UART1_GPS = 2,
HWCOLIBRI_UART1_I2C = 3,
HWCOLIBRI_UART1_DSM = 4,
HWCOLIBRI_UART1_DEBUGCONSOLE = 5,
HWCOLIBRI_UART1_COMBRIDGE = 6,
HWCOLIBRI_UART1_MAVLINKTX = 7,
HWCOLIBRI_UART1_MAVLINKTX_GPS_RX = 8,
HWCOLIBRI_UART1_HOTT_SUMD = 9,
HWCOLIBRI_UART1_HOTT_SUMH = 10,
HWCOLIBRI_UART1_HOTT_TELEMETRY = 11,
HWCOLIBRI_UART1_FRSKY_SENSOR_HUB = 12,
HWCOLIBRI_UART1_LIGHTTELEMETRYTX = 13,
HWCOLIBRI_UART1_PICOC = 14,
HWCOLIBRI_UART1_LASTITEM = 15
};
enum {
HWCOLIBRI_UART2_DISABLED = 0,
HWCOLIBRI_UART2_TELEMETRY = 1,
HWCOLIBRI_UART2_GPS = 2,
HWCOLIBRI_UART2_S_BUS = 3,
HWCOLIBRI_UART2_DSM = 4,
HWCOLIBRI_UART2_DEBUGCONSOLE = 5,
HWCOLIBRI_UART2_COMBRIDGE = 6,
HWCOLIBRI_UART2_MAVLINKTX = 7,
HWCOLIBRI_UART2_MAVLINKTX_GPS_RX = 8,
HWCOLIBRI_UART2_HOTT_SUMD = 9,
HWCOLIBRI_UART2_HOTT_SUMH = 10,
HWCOLIBRI_UART2_HOTT_TELEMETRY = 11,
HWCOLIBRI_UART2_FRSKY_SENSOR_HUB = 12,
HWCOLIBRI_UART2_LIGHTTELEMETRYTX = 13,
HWCOLIBRI_UART2_PICOC = 14,
HWCOLIBRI_UART2_LASTITEM = 15
};
enum {
HWCOLIBRI_UART3_DISABLED = 0,
HWCOLIBRI_UART3_TELEMETRY = 1,
HWCOLIBRI_UART3_GPS = 2,
HWCOLIBRI_UART3_I2C = 3,
HWCOLIBRI_UART3_DSM = 4,
HWCOLIBRI_UART3_DEBUGCONSOLE = 5,
HWCOLIBRI_UART3_COMBRIDGE = 6,
HWCOLIBRI_UART3_MAVLINKTX = 7,
HWCOLIBRI_UART3_MAVLINKTX_GPS_RX = 8,
HWCOLIBRI_UART3_HOTT_SUMD = 9,
HWCOLIBRI_UART3_HOTT_SUMH = 10,
HWCOLIBRI_UART3_HOTT_TELEMETRY = 11,
HWCOLIBRI_UART3_FRSKY_SENSOR_HUB = 12,
HWCOLIBRI_UART3_LIGHTTELEMETRYTX = 13,
HWCOLIBRI_UART3_PICOC = 14,
HWCOLIBRI_UART3_LASTITEM = 15
};
enum {
HWCOLIBRI_UART4_DISABLED = 0,
HWCOLIBRI_UART4_TELEMETRY = 1,
HWCOLIBRI_UART4_GPS = 2,
HWCOLIBRI_UART4_DSM = 3,
HWCOLIBRI_UART4_DEBUGCONSOLE = 4,
HWCOLIBRI_UART4_COMBRIDGE = 5,
HWCOLIBRI_UART4_MAVLINKTX = 6,
HWCOLIBRI_UART4_MAVLINKTX_GPS_RX = 7,
HWCOLIBRI_UART4_HOTT_SUMD = 8,
HWCOLIBRI_UART4_HOTT_SUMH = 9,
HWCOLIBRI_UART4_HOTT_TELEMETRY = 10,
HWCOLIBRI_UART4_LIGHTTELEMETRYTX = 11,
HWCOLIBRI_UART4_FRSKY_SENSOR_HUB = 12,
HWCOLIBRI_UART4_PICOC = 13,
HWCOLIBRI_UART4_LASTITEM = 14
};
enum {
HWCOLIBRI_USB_HIDPORT_USBTELEMETRY = 0,
HWCOLIBRI_USB_HIDPORT_RCTRANSMITTER = 1,
HWCOLIBRI_USB_HIDPORT_DISABLED = 2,
HWCOLIBRI_USB_HIDPORT_LASTITEM = 3
};
enum {
HWCOLIBRI_USB_VCPPORT_USBTELEMETRY = 0,
HWCOLIBRI_USB_VCPPORT_COMBRIDGE = 1,
HWCOLIBRI_USB_VCPPORT_DEBUGCONSOLE = 2,
HWCOLIBRI_USB_VCPPORT_PICOC = 3,
HWCOLIBRI_USB_VCPPORT_DISABLED = 4,
HWCOLIBRI_USB_VCPPORT_LASTITEM = 5
};
enum {
HWCOLIBRI_GYRORANGE_250 = 0,
HWCOLIBRI_GYRORANGE_500 = 1,
HWCOLIBRI_GYRORANGE_1000 = 2,
HWCOLIBRI_GYRORANGE_2000 = 3,
HWCOLIBRI_GYRORANGE_LASTITEM = 4
};
enum {
HWCOLIBRI_ACCELRANGE_2G = 0,
HWCOLIBRI_ACCELRANGE_4G = 1,
HWCOLIBRI_ACCELRANGE_8G = 2,
HWCOLIBRI_ACCELRANGE_16G = 3,
HWCOLIBRI_ACCELRANGE_LASTITEM = 4
};
enum {
HWCOLIBRI_MPU6000RATE_200 = 0,
HWCOLIBRI_MPU6000RATE_333 = 1,
HWCOLIBRI_MPU6000RATE_500 = 2,
HWCOLIBRI_MPU6000RATE_666 = 3,
HWCOLIBRI_MPU6000RATE_1000 = 4,
HWCOLIBRI_MPU6000RATE_2000 = 5,
HWCOLIBRI_MPU6000RATE_4000 = 6,
HWCOLIBRI_MPU6000RATE_8000 = 7,
HWCOLIBRI_MPU6000RATE_LASTITEM = 8
};
enum {
HWCOLIBRI_MPU6000DLPF_256 = 0,
HWCOLIBRI_MPU6000DLPF_188 = 1,
HWCOLIBRI_MPU6000DLPF_98 = 2,
HWCOLIBRI_MPU6000DLPF_42 = 3,
HWCOLIBRI_MPU6000DLPF_20 = 4,
HWCOLIBRI_MPU6000DLPF_10 = 5,
HWCOLIBRI_MPU6000DLPF_5 = 6,
HWCOLIBRI_MPU6000DLPF_LASTITEM = 7
};
enum {
HWCOLIBRI_MAGNETOMETER_DISABLED = 0,
HWCOLIBRI_MAGNETOMETER_INTERNAL = 1,
HWCOLIBRI_MAGNETOMETER_EXTERNALI2CUART1 = 2,
HWCOLIBRI_MAGNETOMETER_EXTERNALI2CUART3 = 3,
HWCOLIBRI_MAGNETOMETER_LASTITEM = 4
};
enum {
HWCOLIBRI_EXTMAGORIENTATION_TOP0DEGCW = 0,
HWCOLIBRI_EXTMAGORIENTATION_TOP90DEGCW = 1,
HWCOLIBRI_EXTMAGORIENTATION_TOP180DEGCW = 2,
HWCOLIBRI_EXTMAGORIENTATION_TOP270DEGCW = 3,
HWCOLIBRI_EXTMAGORIENTATION_BOTTOM0DEGCW = 4,
HWCOLIBRI_EXTMAGORIENTATION_BOTTOM90DEGCW = 5,
HWCOLIBRI_EXTMAGORIENTATION_BOTTOM180DEGCW = 6,
HWCOLIBRI_EXTMAGORIENTATION_BOTTOM270DEGCW = 7,
HWCOLIBRI_EXTMAGORIENTATION_LASTITEM = 8
};
extern char UAVT_HwColibriFrameOption[][42];
extern char UAVT_HwColibriRcvrPortOption[][42];
extern char UAVT_HwColibriUart1Option[][42];
extern char UAVT_HwColibriUart2Option[][42];
extern char UAVT_HwColibriUart3Option[][42];
extern char UAVT_HwColibriUart4Option[][42];
extern char UAVT_HwColibriUSB_HIDPortOption[][42];
extern char UAVT_HwColibriUSB_VCPPortOption[][42];
extern char UAVT_HwColibriGyroRangeOption[][42];
extern char UAVT_HwColibriAccelRangeOption[][42];
extern char UAVT_HwColibriMPU6000RateOption[][42];
extern char UAVT_HwColibriMPU6000DLPFOption[][42];
extern char UAVT_HwColibriMagnetometerOption[][42];
extern char UAVT_HwColibriExtMagOrientationOption[][42];
typedef struct {
uint8_t Frame; // enum
uint8_t RcvrPort; // enum
uint8_t Uart1; // enum
uint8_t Uart2; // enum
uint8_t Uart3; // enum
uint8_t Uart4; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU6000Rate; // enum
uint8_t MPU6000DLPF; // enum
uint8_t Magnetometer; // enum
uint8_t ExtMagOrientation; // enum
} UAVT_HwColibriData;
extern UAVT_HwColibriData uavtalk_HwColibriData;
/*************************************************************************************************
Filename: hwcoptercontrol.xml
Object: HwCopterControl
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWCOPTERCONTROL_OBJID 0xd599c916
enum {
HWCOPTERCONTROL_RCVRPORT_DISABLED = 0,
HWCOPTERCONTROL_RCVRPORT_PWM = 1,
HWCOPTERCONTROL_RCVRPORT_PPM = 2,
HWCOPTERCONTROL_RCVRPORT_PPM_PWM = 3,
HWCOPTERCONTROL_RCVRPORT_PPM_OUTPUTS = 4,
HWCOPTERCONTROL_RCVRPORT_OUTPUTS = 5,
HWCOPTERCONTROL_RCVRPORT_LASTITEM = 6
};
enum {
HWCOPTERCONTROL_MAINPORT_DISABLED = 0,
HWCOPTERCONTROL_MAINPORT_TELEMETRY = 1,
HWCOPTERCONTROL_MAINPORT_GPS = 2,
HWCOPTERCONTROL_MAINPORT_S_BUS = 3,
HWCOPTERCONTROL_MAINPORT_DSM = 4,
HWCOPTERCONTROL_MAINPORT_DEBUGCONSOLE = 5,
HWCOPTERCONTROL_MAINPORT_COMBRIDGE = 6,
HWCOPTERCONTROL_MAINPORT_MAVLINKTX = 7,
HWCOPTERCONTROL_MAINPORT_MAVLINKTX_GPS_RX = 8,
HWCOPTERCONTROL_MAINPORT_FRSKY_SENSOR_HUB = 9,
HWCOPTERCONTROL_MAINPORT_LIGHTTELEMETRYTX = 10,
HWCOPTERCONTROL_MAINPORT_LASTITEM = 11
};
enum {
HWCOPTERCONTROL_FLEXIPORT_DISABLED = 0,
HWCOPTERCONTROL_FLEXIPORT_TELEMETRY = 1,
HWCOPTERCONTROL_FLEXIPORT_GPS = 2,
HWCOPTERCONTROL_FLEXIPORT_I2C = 3,
HWCOPTERCONTROL_FLEXIPORT_DSM = 4,
HWCOPTERCONTROL_FLEXIPORT_DEBUGCONSOLE = 5,
HWCOPTERCONTROL_FLEXIPORT_COMBRIDGE = 6,
HWCOPTERCONTROL_FLEXIPORT_MAVLINKTX = 7,
HWCOPTERCONTROL_FLEXIPORT_FRSKY_SENSOR_HUB = 8,
HWCOPTERCONTROL_FLEXIPORT_LIGHTTELEMETRYTX = 9,
HWCOPTERCONTROL_FLEXIPORT_LASTITEM = 10
};
enum {
HWCOPTERCONTROL_USB_HIDPORT_USBTELEMETRY = 0,
HWCOPTERCONTROL_USB_HIDPORT_RCTRANSMITTER = 1,
HWCOPTERCONTROL_USB_HIDPORT_DISABLED = 2,
HWCOPTERCONTROL_USB_HIDPORT_LASTITEM = 3
};
enum {
HWCOPTERCONTROL_USB_VCPPORT_USBTELEMETRY = 0,
HWCOPTERCONTROL_USB_VCPPORT_COMBRIDGE = 1,
HWCOPTERCONTROL_USB_VCPPORT_DEBUGCONSOLE = 2,
HWCOPTERCONTROL_USB_VCPPORT_DISABLED = 3,
HWCOPTERCONTROL_USB_VCPPORT_LASTITEM = 4
};
enum {
HWCOPTERCONTROL_GYRORANGE_250 = 0,
HWCOPTERCONTROL_GYRORANGE_500 = 1,
HWCOPTERCONTROL_GYRORANGE_1000 = 2,
HWCOPTERCONTROL_GYRORANGE_2000 = 3,
HWCOPTERCONTROL_GYRORANGE_LASTITEM = 4
};
enum {
HWCOPTERCONTROL_ACCELRANGE_2G = 0,
HWCOPTERCONTROL_ACCELRANGE_4G = 1,
HWCOPTERCONTROL_ACCELRANGE_8G = 2,
HWCOPTERCONTROL_ACCELRANGE_16G = 3,
HWCOPTERCONTROL_ACCELRANGE_LASTITEM = 4
};
enum {
HWCOPTERCONTROL_MPU6000RATE_200 = 0,
HWCOPTERCONTROL_MPU6000RATE_333 = 1,
HWCOPTERCONTROL_MPU6000RATE_500 = 2,
HWCOPTERCONTROL_MPU6000RATE_666 = 3,
HWCOPTERCONTROL_MPU6000RATE_1000 = 4,
HWCOPTERCONTROL_MPU6000RATE_2000 = 5,
HWCOPTERCONTROL_MPU6000RATE_4000 = 6,
HWCOPTERCONTROL_MPU6000RATE_8000 = 7,
HWCOPTERCONTROL_MPU6000RATE_LASTITEM = 8
};
enum {
HWCOPTERCONTROL_MPU6000DLPF_256 = 0,
HWCOPTERCONTROL_MPU6000DLPF_188 = 1,
HWCOPTERCONTROL_MPU6000DLPF_98 = 2,
HWCOPTERCONTROL_MPU6000DLPF_42 = 3,
HWCOPTERCONTROL_MPU6000DLPF_20 = 4,
HWCOPTERCONTROL_MPU6000DLPF_10 = 5,
HWCOPTERCONTROL_MPU6000DLPF_5 = 6,
HWCOPTERCONTROL_MPU6000DLPF_LASTITEM = 7
};
extern char UAVT_HwCopterControlRcvrPortOption[][42];
extern char UAVT_HwCopterControlMainPortOption[][42];
extern char UAVT_HwCopterControlFlexiPortOption[][42];
extern char UAVT_HwCopterControlUSB_HIDPortOption[][42];
extern char UAVT_HwCopterControlUSB_VCPPortOption[][42];
extern char UAVT_HwCopterControlGyroRangeOption[][42];
extern char UAVT_HwCopterControlAccelRangeOption[][42];
extern char UAVT_HwCopterControlMPU6000RateOption[][42];
extern char UAVT_HwCopterControlMPU6000DLPFOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t MainPort; // enum
uint8_t FlexiPort; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU6000Rate; // enum
uint8_t MPU6000DLPF; // enum
} UAVT_HwCopterControlData;
extern UAVT_HwCopterControlData uavtalk_HwCopterControlData;
/*************************************************************************************************
Filename: hwdiscoveryf4.xml
Object: HwDiscoveryF4
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWDISCOVERYF4_OBJID 0x416d89a8
enum {
HWDISCOVERYF4_MAINPORT_DISABLED = 0,
HWDISCOVERYF4_MAINPORT_TELEMETRY = 1,
HWDISCOVERYF4_MAINPORT_DEBUGCONSOLE = 2,
HWDISCOVERYF4_MAINPORT_LASTITEM = 3
};
enum {
HWDISCOVERYF4_USB_HIDPORT_USBTELEMETRY = 0,
HWDISCOVERYF4_USB_HIDPORT_RCTRANSMITTER = 1,
HWDISCOVERYF4_USB_HIDPORT_DISABLED = 2,
HWDISCOVERYF4_USB_HIDPORT_LASTITEM = 3
};
enum {
HWDISCOVERYF4_USB_VCPPORT_USBTELEMETRY = 0,
HWDISCOVERYF4_USB_VCPPORT_COMBRIDGE = 1,
HWDISCOVERYF4_USB_VCPPORT_DEBUGCONSOLE = 2,
HWDISCOVERYF4_USB_VCPPORT_DISABLED = 3,
HWDISCOVERYF4_USB_VCPPORT_LASTITEM = 4
};
extern char UAVT_HwDiscoveryF4MainPortOption[][42];
extern char UAVT_HwDiscoveryF4USB_HIDPortOption[][42];
extern char UAVT_HwDiscoveryF4USB_VCPPortOption[][42];
typedef struct {
uint8_t MainPort; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
} UAVT_HwDiscoveryF4Data;
extern UAVT_HwDiscoveryF4Data uavtalk_HwDiscoveryF4Data;
/*************************************************************************************************
Filename: hwflyingf3.xml
Object: HwFlyingF3
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWFLYINGF3_OBJID 0x472fae5a
enum {
HWFLYINGF3_RCVRPORT_DISABLED = 0,
HWFLYINGF3_RCVRPORT_PWM = 1,
HWFLYINGF3_RCVRPORT_PPM = 2,
HWFLYINGF3_RCVRPORT_PPM_PWM = 3,
HWFLYINGF3_RCVRPORT_PPM_OUTPUTS = 4,
HWFLYINGF3_RCVRPORT_OUTPUTS = 5,
HWFLYINGF3_RCVRPORT_LASTITEM = 6
};
enum {
HWFLYINGF3_UART1_DISABLED = 0,
HWFLYINGF3_UART1_TELEMETRY = 1,
HWFLYINGF3_UART1_GPS = 2,
HWFLYINGF3_UART1_S_BUS = 3,
HWFLYINGF3_UART1_DSM = 4,
HWFLYINGF3_UART1_DEBUGCONSOLE = 5,
HWFLYINGF3_UART1_COMBRIDGE = 6,
HWFLYINGF3_UART1_MAVLINKTX = 7,
HWFLYINGF3_UART1_MAVLINKTX_GPS_RX = 8,
HWFLYINGF3_UART1_HOTT_SUMD = 9,
HWFLYINGF3_UART1_HOTT_SUMH = 10,
HWFLYINGF3_UART1_HOTT_TELEMETRY = 11,
HWFLYINGF3_UART1_FRSKY_SENSOR_HUB = 12,
HWFLYINGF3_UART1_LIGHTTELEMETRYTX = 13,
HWFLYINGF3_UART1_FRSKY_SPORT_TELEMETRY = 14,
HWFLYINGF3_UART1_LASTITEM = 15
};
enum {
HWFLYINGF3_UART2_DISABLED = 0,
HWFLYINGF3_UART2_TELEMETRY = 1,
HWFLYINGF3_UART2_GPS = 2,
HWFLYINGF3_UART2_S_BUS = 3,
HWFLYINGF3_UART2_DSM = 4,
HWFLYINGF3_UART2_DEBUGCONSOLE = 5,
HWFLYINGF3_UART2_COMBRIDGE = 6,
HWFLYINGF3_UART2_MAVLINKTX = 7,
HWFLYINGF3_UART2_MAVLINKTX_GPS_RX = 8,
HWFLYINGF3_UART2_HOTT_SUMD = 9,
HWFLYINGF3_UART2_HOTT_SUMH = 10,
HWFLYINGF3_UART2_HOTT_TELEMETRY = 11,
HWFLYINGF3_UART2_FRSKY_SENSOR_HUB = 12,
HWFLYINGF3_UART2_LIGHTTELEMETRYTX = 13,
HWFLYINGF3_UART2_FRSKY_SPORT_TELEMETRY = 14,
HWFLYINGF3_UART2_LASTITEM = 15
};
enum {
HWFLYINGF3_UART3_DISABLED = 0,
HWFLYINGF3_UART3_TELEMETRY = 1,
HWFLYINGF3_UART3_GPS = 2,
HWFLYINGF3_UART3_S_BUS = 3,
HWFLYINGF3_UART3_DSM = 4,
HWFLYINGF3_UART3_DEBUGCONSOLE = 5,
HWFLYINGF3_UART3_COMBRIDGE = 6,
HWFLYINGF3_UART3_MAVLINKTX = 7,
HWFLYINGF3_UART3_MAVLINKTX_GPS_RX = 8,
HWFLYINGF3_UART3_HOTT_SUMD = 9,
HWFLYINGF3_UART3_HOTT_SUMH = 10,
HWFLYINGF3_UART3_HOTT_TELEMETRY = 11,
HWFLYINGF3_UART3_FRSKY_SENSOR_HUB = 12,
HWFLYINGF3_UART3_LIGHTTELEMETRYTX = 13,
HWFLYINGF3_UART3_FRSKY_SPORT_TELEMETRY = 14,
HWFLYINGF3_UART3_LASTITEM = 15
};
enum {
HWFLYINGF3_UART4_DISABLED = 0,
HWFLYINGF3_UART4_TELEMETRY = 1,
HWFLYINGF3_UART4_GPS = 2,
HWFLYINGF3_UART4_S_BUS = 3,
HWFLYINGF3_UART4_DSM = 4,
HWFLYINGF3_UART4_DEBUGCONSOLE = 5,
HWFLYINGF3_UART4_COMBRIDGE = 6,
HWFLYINGF3_UART4_MAVLINKTX = 7,
HWFLYINGF3_UART4_MAVLINKTX_GPS_RX = 8,
HWFLYINGF3_UART4_HOTT_SUMD = 9,
HWFLYINGF3_UART4_HOTT_SUMH = 10,
HWFLYINGF3_UART4_HOTT_TELEMETRY = 11,
HWFLYINGF3_UART4_FRSKY_SENSOR_HUB = 12,
HWFLYINGF3_UART4_LIGHTTELEMETRYTX = 13,
HWFLYINGF3_UART4_FRSKY_SPORT_TELEMETRY = 14,
HWFLYINGF3_UART4_LASTITEM = 15
};
enum {
HWFLYINGF3_UART5_DISABLED = 0,
HWFLYINGF3_UART5_TELEMETRY = 1,
HWFLYINGF3_UART5_GPS = 2,
HWFLYINGF3_UART5_S_BUS = 3,
HWFLYINGF3_UART5_DSM = 4,
HWFLYINGF3_UART5_DEBUGCONSOLE = 5,
HWFLYINGF3_UART5_COMBRIDGE = 6,
HWFLYINGF3_UART5_MAVLINKTX = 7,
HWFLYINGF3_UART5_MAVLINKTX_GPS_RX = 8,
HWFLYINGF3_UART5_HOTT_SUMD = 9,
HWFLYINGF3_UART5_HOTT_SUMH = 10,
HWFLYINGF3_UART5_HOTT_TELEMETRY = 11,
HWFLYINGF3_UART5_FRSKY_SENSOR_HUB = 12,
HWFLYINGF3_UART5_LIGHTTELEMETRYTX = 13,
HWFLYINGF3_UART5_FRSKY_SPORT_TELEMETRY = 14,
HWFLYINGF3_UART5_LASTITEM = 15
};
enum {
HWFLYINGF3_USB_HIDPORT_USBTELEMETRY = 0,
HWFLYINGF3_USB_HIDPORT_RCTRANSMITTER = 1,
HWFLYINGF3_USB_HIDPORT_DISABLED = 2,
HWFLYINGF3_USB_HIDPORT_LASTITEM = 3
};
enum {
HWFLYINGF3_USB_VCPPORT_USBTELEMETRY = 0,
HWFLYINGF3_USB_VCPPORT_COMBRIDGE = 1,
HWFLYINGF3_USB_VCPPORT_DEBUGCONSOLE = 2,
HWFLYINGF3_USB_VCPPORT_DISABLED = 3,
HWFLYINGF3_USB_VCPPORT_LASTITEM = 4
};
enum {
HWFLYINGF3_GYRORANGE_250 = 0,
HWFLYINGF3_GYRORANGE_500 = 1,
HWFLYINGF3_GYRORANGE_1000 = 2,
HWFLYINGF3_GYRORANGE_2000 = 3,
HWFLYINGF3_GYRORANGE_LASTITEM = 4
};
enum {
HWFLYINGF3_L3GD20RATE_380 = 0,
HWFLYINGF3_L3GD20RATE_760 = 1,
HWFLYINGF3_L3GD20RATE_LASTITEM = 2
};
enum {
HWFLYINGF3_ACCELRANGE_2G = 0,
HWFLYINGF3_ACCELRANGE_4G = 1,
HWFLYINGF3_ACCELRANGE_8G = 2,
HWFLYINGF3_ACCELRANGE_16G = 3,
HWFLYINGF3_ACCELRANGE_LASTITEM = 4
};
enum {
HWFLYINGF3_SHIELD_NONE = 0,
HWFLYINGF3_SHIELD_RCFLYER = 1,
HWFLYINGF3_SHIELD_CHEBUZZ = 2,
HWFLYINGF3_SHIELD_BMP085 = 3,
HWFLYINGF3_SHIELD_LASTITEM = 4
};
extern char UAVT_HwFlyingF3RcvrPortOption[][42];
extern char UAVT_HwFlyingF3Uart1Option[][42];
extern char UAVT_HwFlyingF3Uart2Option[][42];
extern char UAVT_HwFlyingF3Uart3Option[][42];
extern char UAVT_HwFlyingF3Uart4Option[][42];
extern char UAVT_HwFlyingF3Uart5Option[][42];
extern char UAVT_HwFlyingF3USB_HIDPortOption[][42];
extern char UAVT_HwFlyingF3USB_VCPPortOption[][42];
extern char UAVT_HwFlyingF3GyroRangeOption[][42];
extern char UAVT_HwFlyingF3L3GD20RateOption[][42];
extern char UAVT_HwFlyingF3AccelRangeOption[][42];
extern char UAVT_HwFlyingF3ShieldOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t Uart1; // enum
uint8_t Uart2; // enum
uint8_t Uart3; // enum
uint8_t Uart4; // enum
uint8_t Uart5; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t L3GD20Rate; // enum
uint8_t AccelRange; // enum
uint8_t Shield; // enum
} UAVT_HwFlyingF3Data;
extern UAVT_HwFlyingF3Data uavtalk_HwFlyingF3Data;
/*************************************************************************************************
Filename: hwflyingf4.xml
Object: HwFlyingF4
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWFLYINGF4_OBJID 0x5796bcc6
enum {
HWFLYINGF4_RCVRPORT_DISABLED = 0,
HWFLYINGF4_RCVRPORT_PWM = 1,
HWFLYINGF4_RCVRPORT_PPM = 2,
HWFLYINGF4_RCVRPORT_PPM_PWM = 3,
HWFLYINGF4_RCVRPORT_PPM_OUTPUTS = 4,
HWFLYINGF4_RCVRPORT_OUTPUTS = 5,
HWFLYINGF4_RCVRPORT_LASTITEM = 6
};
enum {
HWFLYINGF4_UART1_DISABLED = 0,
HWFLYINGF4_UART1_GPS = 1,
HWFLYINGF4_UART1_S_BUS = 2,
HWFLYINGF4_UART1_DSM = 3,
HWFLYINGF4_UART1_HOTT_SUMD = 4,
HWFLYINGF4_UART1_HOTT_SUMH = 5,
HWFLYINGF4_UART1_PICOC = 6,
HWFLYINGF4_UART1_LASTITEM = 7
};
enum {
HWFLYINGF4_UART2_DISABLED = 0,
HWFLYINGF4_UART2_TELEMETRY = 1,
HWFLYINGF4_UART2_GPS = 2,
HWFLYINGF4_UART2_DSM = 3,
HWFLYINGF4_UART2_DEBUGCONSOLE = 4,
HWFLYINGF4_UART2_COMBRIDGE = 5,
HWFLYINGF4_UART2_MAVLINKTX = 6,
HWFLYINGF4_UART2_MAVLINKTX_GPS_RX = 7,
HWFLYINGF4_UART2_FRSKY_SENSOR_HUB = 8,
HWFLYINGF4_UART2_HOTT_SUMD = 9,
HWFLYINGF4_UART2_HOTT_SUMH = 10,
HWFLYINGF4_UART2_LIGHTTELEMETRYTX = 11,
HWFLYINGF4_UART2_PICOC = 12,
HWFLYINGF4_UART2_FRSKY_SPORT_TELEMETRY = 13,
HWFLYINGF4_UART2_LASTITEM = 14
};
enum {
HWFLYINGF4_UART3_DISABLED = 0,
HWFLYINGF4_UART3_TELEMETRY = 1,
HWFLYINGF4_UART3_GPS = 2,
HWFLYINGF4_UART3_DSM = 3,
HWFLYINGF4_UART3_DEBUGCONSOLE = 4,
HWFLYINGF4_UART3_COMBRIDGE = 5,
HWFLYINGF4_UART3_MAVLINKTX = 6,
HWFLYINGF4_UART3_MAVLINKTX_GPS_RX = 7,
HWFLYINGF4_UART3_FRSKY_SENSOR_HUB = 8,
HWFLYINGF4_UART3_HOTT_SUMD = 9,
HWFLYINGF4_UART3_HOTT_SUMH = 10,
HWFLYINGF4_UART3_LIGHTTELEMETRYTX = 11,
HWFLYINGF4_UART3_PICOC = 12,
HWFLYINGF4_UART3_FRSKY_SPORT_TELEMETRY = 13,
HWFLYINGF4_UART3_LASTITEM = 14
};
enum {
HWFLYINGF4_USB_HIDPORT_USBTELEMETRY = 0,
HWFLYINGF4_USB_HIDPORT_RCTRANSMITTER = 1,
HWFLYINGF4_USB_HIDPORT_DISABLED = 2,
HWFLYINGF4_USB_HIDPORT_LASTITEM = 3
};
enum {
HWFLYINGF4_USB_VCPPORT_USBTELEMETRY = 0,
HWFLYINGF4_USB_VCPPORT_COMBRIDGE = 1,
HWFLYINGF4_USB_VCPPORT_DEBUGCONSOLE = 2,
HWFLYINGF4_USB_VCPPORT_PICOC = 3,
HWFLYINGF4_USB_VCPPORT_DISABLED = 4,
HWFLYINGF4_USB_VCPPORT_LASTITEM = 5
};
enum {
HWFLYINGF4_GYRORANGE_250 = 0,
HWFLYINGF4_GYRORANGE_500 = 1,
HWFLYINGF4_GYRORANGE_1000 = 2,
HWFLYINGF4_GYRORANGE_2000 = 3,
HWFLYINGF4_GYRORANGE_LASTITEM = 4
};
enum {
HWFLYINGF4_ACCELRANGE_2G = 0,
HWFLYINGF4_ACCELRANGE_4G = 1,
HWFLYINGF4_ACCELRANGE_8G = 2,
HWFLYINGF4_ACCELRANGE_16G = 3,
HWFLYINGF4_ACCELRANGE_LASTITEM = 4
};
enum {
HWFLYINGF4_MPU6050RATE_200 = 0,
HWFLYINGF4_MPU6050RATE_333 = 1,
HWFLYINGF4_MPU6050RATE_500 = 2,
HWFLYINGF4_MPU6050RATE_666 = 3,
HWFLYINGF4_MPU6050RATE_1000 = 4,
HWFLYINGF4_MPU6050RATE_2000 = 5,
HWFLYINGF4_MPU6050RATE_4000 = 6,
HWFLYINGF4_MPU6050RATE_8000 = 7,
HWFLYINGF4_MPU6050RATE_LASTITEM = 8
};
enum {
HWFLYINGF4_MPU6050DLPF_256 = 0,
HWFLYINGF4_MPU6050DLPF_188 = 1,
HWFLYINGF4_MPU6050DLPF_98 = 2,
HWFLYINGF4_MPU6050DLPF_42 = 3,
HWFLYINGF4_MPU6050DLPF_20 = 4,
HWFLYINGF4_MPU6050DLPF_10 = 5,
HWFLYINGF4_MPU6050DLPF_5 = 6,
HWFLYINGF4_MPU6050DLPF_LASTITEM = 7
};
enum {
HWFLYINGF4_MAGNETOMETER_DISABLED = 0,
HWFLYINGF4_MAGNETOMETER_EXTERNALI2C = 1,
HWFLYINGF4_MAGNETOMETER_LASTITEM = 2
};
enum {
HWFLYINGF4_EXTMAGORIENTATION_TOP0DEGCW = 0,
HWFLYINGF4_EXTMAGORIENTATION_TOP90DEGCW = 1,
HWFLYINGF4_EXTMAGORIENTATION_TOP180DEGCW = 2,
HWFLYINGF4_EXTMAGORIENTATION_TOP270DEGCW = 3,
HWFLYINGF4_EXTMAGORIENTATION_BOTTOM0DEGCW = 4,
HWFLYINGF4_EXTMAGORIENTATION_BOTTOM90DEGCW = 5,
HWFLYINGF4_EXTMAGORIENTATION_BOTTOM180DEGCW = 6,
HWFLYINGF4_EXTMAGORIENTATION_BOTTOM270DEGCW = 7,
HWFLYINGF4_EXTMAGORIENTATION_LASTITEM = 8
};
extern char UAVT_HwFlyingF4RcvrPortOption[][42];
extern char UAVT_HwFlyingF4Uart1Option[][42];
extern char UAVT_HwFlyingF4Uart2Option[][42];
extern char UAVT_HwFlyingF4Uart3Option[][42];
extern char UAVT_HwFlyingF4USB_HIDPortOption[][42];
extern char UAVT_HwFlyingF4USB_VCPPortOption[][42];
extern char UAVT_HwFlyingF4GyroRangeOption[][42];
extern char UAVT_HwFlyingF4AccelRangeOption[][42];
extern char UAVT_HwFlyingF4MPU6050RateOption[][42];
extern char UAVT_HwFlyingF4MPU6050DLPFOption[][42];
extern char UAVT_HwFlyingF4MagnetometerOption[][42];
extern char UAVT_HwFlyingF4ExtMagOrientationOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t Uart1; // enum
uint8_t Uart2; // enum
uint8_t Uart3; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU6050Rate; // enum
uint8_t MPU6050DLPF; // enum
uint8_t Magnetometer; // enum
uint8_t ExtMagOrientation; // enum
} UAVT_HwFlyingF4Data;
extern UAVT_HwFlyingF4Data uavtalk_HwFlyingF4Data;
/*************************************************************************************************
Filename: hwfreedom.xml
Object: HwFreedom
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWFREEDOM_OBJID 0x2db9d4f0
enum {
HWFREEDOM_OUTPUT_DISABLED = 0,
HWFREEDOM_OUTPUT_PWM = 1,
HWFREEDOM_OUTPUT_LASTITEM = 2
};
enum {
HWFREEDOM_MAINPORT_DISABLED = 0,
HWFREEDOM_MAINPORT_TELEMETRY = 1,
HWFREEDOM_MAINPORT_GPS = 2,
HWFREEDOM_MAINPORT_DSM = 3,
HWFREEDOM_MAINPORT_DEBUGCONSOLE = 4,
HWFREEDOM_MAINPORT_COMBRIDGE = 5,
HWFREEDOM_MAINPORT_MAVLINKTX = 6,
HWFREEDOM_MAINPORT_MAVLINKTX_GPS_RX = 7,
HWFREEDOM_MAINPORT_HOTT_SUMD = 8,
HWFREEDOM_MAINPORT_HOTT_SUMH = 9,
HWFREEDOM_MAINPORT_HOTT_TELEMETRY = 10,
HWFREEDOM_MAINPORT_FRSKY_SENSOR_HUB = 11,
HWFREEDOM_MAINPORT_LIGHTTELEMETRYTX = 12,
HWFREEDOM_MAINPORT_PICOC = 13,
HWFREEDOM_MAINPORT_FRSKY_SPORT_TELEMETRY = 14,
HWFREEDOM_MAINPORT_LASTITEM = 15
};
enum {
HWFREEDOM_FLEXIPORT_DISABLED = 0,
HWFREEDOM_FLEXIPORT_TELEMETRY = 1,
HWFREEDOM_FLEXIPORT_GPS = 2,
HWFREEDOM_FLEXIPORT_I2C = 3,
HWFREEDOM_FLEXIPORT_DSM = 4,
HWFREEDOM_FLEXIPORT_DEBUGCONSOLE = 5,
HWFREEDOM_FLEXIPORT_COMBRIDGE = 6,
HWFREEDOM_FLEXIPORT_MAVLINKTX = 7,
HWFREEDOM_FLEXIPORT_MAVLINKTX_GPS_RX = 8,
HWFREEDOM_FLEXIPORT_HOTT_SUMD = 9,
HWFREEDOM_FLEXIPORT_HOTT_SUMH = 10,
HWFREEDOM_FLEXIPORT_HOTT_TELEMETRY = 11,
HWFREEDOM_FLEXIPORT_FRSKY_SENSOR_HUB = 12,
HWFREEDOM_FLEXIPORT_LIGHTTELEMETRYTX = 13,
HWFREEDOM_FLEXIPORT_PICOC = 14,
HWFREEDOM_FLEXIPORT_FRSKY_SPORT_TELEMETRY = 15,
HWFREEDOM_FLEXIPORT_LASTITEM = 16
};
enum {
HWFREEDOM_RCVRPORT_DISABLED = 0,
HWFREEDOM_RCVRPORT_PPM = 1,
HWFREEDOM_RCVRPORT_DSM = 2,
HWFREEDOM_RCVRPORT_S_BUS = 3,
HWFREEDOM_RCVRPORT_HOTT_SUMD = 4,
HWFREEDOM_RCVRPORT_HOTT_SUMH = 5,
HWFREEDOM_RCVRPORT_LASTITEM = 6
};
enum {
HWFREEDOM_RADIOPORT_DISABLED = 0,
HWFREEDOM_RADIOPORT_TELEMETRY = 1,
HWFREEDOM_RADIOPORT_LASTITEM = 2
};
enum {
HWFREEDOM_USB_HIDPORT_USBTELEMETRY = 0,
HWFREEDOM_USB_HIDPORT_RCTRANSMITTER = 1,
HWFREEDOM_USB_HIDPORT_DISABLED = 2,
HWFREEDOM_USB_HIDPORT_LASTITEM = 3
};
enum {
HWFREEDOM_USB_VCPPORT_USBTELEMETRY = 0,
HWFREEDOM_USB_VCPPORT_COMBRIDGE = 1,
HWFREEDOM_USB_VCPPORT_DEBUGCONSOLE = 2,
HWFREEDOM_USB_VCPPORT_PICOC = 3,
HWFREEDOM_USB_VCPPORT_DISABLED = 4,
HWFREEDOM_USB_VCPPORT_LASTITEM = 5
};
enum {
HWFREEDOM_GYRORANGE_250 = 0,
HWFREEDOM_GYRORANGE_500 = 1,
HWFREEDOM_GYRORANGE_1000 = 2,
HWFREEDOM_GYRORANGE_2000 = 3,
HWFREEDOM_GYRORANGE_LASTITEM = 4
};
enum {
HWFREEDOM_ACCELRANGE_2G = 0,
HWFREEDOM_ACCELRANGE_4G = 1,
HWFREEDOM_ACCELRANGE_8G = 2,
HWFREEDOM_ACCELRANGE_16G = 3,
HWFREEDOM_ACCELRANGE_LASTITEM = 4
};
enum {
HWFREEDOM_MPU6000RATE_200 = 0,
HWFREEDOM_MPU6000RATE_333 = 1,
HWFREEDOM_MPU6000RATE_500 = 2,
HWFREEDOM_MPU6000RATE_666 = 3,
HWFREEDOM_MPU6000RATE_1000 = 4,
HWFREEDOM_MPU6000RATE_2000 = 5,
HWFREEDOM_MPU6000RATE_4000 = 6,
HWFREEDOM_MPU6000RATE_8000 = 7,
HWFREEDOM_MPU6000RATE_LASTITEM = 8
};
enum {
HWFREEDOM_MPU6000DLPF_256 = 0,
HWFREEDOM_MPU6000DLPF_188 = 1,
HWFREEDOM_MPU6000DLPF_98 = 2,
HWFREEDOM_MPU6000DLPF_42 = 3,
HWFREEDOM_MPU6000DLPF_20 = 4,
HWFREEDOM_MPU6000DLPF_10 = 5,
HWFREEDOM_MPU6000DLPF_5 = 6,
HWFREEDOM_MPU6000DLPF_LASTITEM = 7
};
extern char UAVT_HwFreedomOutputOption[][42];
extern char UAVT_HwFreedomMainPortOption[][42];
extern char UAVT_HwFreedomFlexiPortOption[][42];
extern char UAVT_HwFreedomRcvrPortOption[][42];
extern char UAVT_HwFreedomRadioPortOption[][42];
extern char UAVT_HwFreedomUSB_HIDPortOption[][42];
extern char UAVT_HwFreedomUSB_VCPPortOption[][42];
extern char UAVT_HwFreedomGyroRangeOption[][42];
extern char UAVT_HwFreedomAccelRangeOption[][42];
extern char UAVT_HwFreedomMPU6000RateOption[][42];
extern char UAVT_HwFreedomMPU6000DLPFOption[][42];
typedef struct {
uint8_t Output; // enum
uint8_t MainPort; // enum
uint8_t FlexiPort; // enum
uint8_t RcvrPort; // enum
uint8_t RadioPort; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU6000Rate; // enum
uint8_t MPU6000DLPF; // enum
} UAVT_HwFreedomData;
extern UAVT_HwFreedomData uavtalk_HwFreedomData;
/*************************************************************************************************
Filename: hwquanton.xml
Object: HwQuanton
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWQUANTON_OBJID 0x176384a6
enum {
HWQUANTON_RCVRPORT_DISABLED = 0,
HWQUANTON_RCVRPORT_PWM = 1,
HWQUANTON_RCVRPORT_PWM_ADC = 2,
HWQUANTON_RCVRPORT_PPM = 3,
HWQUANTON_RCVRPORT_PPM_ADC = 4,
HWQUANTON_RCVRPORT_PPM_PWM = 5,
HWQUANTON_RCVRPORT_PPM_PWM_ADC = 6,
HWQUANTON_RCVRPORT_PPM_OUTPUTS = 7,
HWQUANTON_RCVRPORT_PPM_OUTPUTS_ADC = 8,
HWQUANTON_RCVRPORT_OUTPUTS = 9,
HWQUANTON_RCVRPORT_OUTPUTS_ADC = 10,
HWQUANTON_RCVRPORT_LASTITEM = 11
};
enum {
HWQUANTON_UART1_DISABLED = 0,
HWQUANTON_UART1_TELEMETRY = 1,
HWQUANTON_UART1_GPS = 2,
HWQUANTON_UART1_I2C = 3,
HWQUANTON_UART1_DSM = 4,
HWQUANTON_UART1_DEBUGCONSOLE = 5,
HWQUANTON_UART1_COMBRIDGE = 6,
HWQUANTON_UART1_MAVLINKTX = 7,
HWQUANTON_UART1_MAVLINKTX_GPS_RX = 8,
HWQUANTON_UART1_HOTT_SUMD = 9,
HWQUANTON_UART1_HOTT_SUMH = 10,
HWQUANTON_UART1_HOTT_TELEMETRY = 11,
HWQUANTON_UART1_FRSKY_SENSOR_HUB = 12,
HWQUANTON_UART1_LIGHTTELEMETRYTX = 13,
HWQUANTON_UART1_PICOC = 14,
HWQUANTON_UART1_FRSKY_SPORT_TELEMETRY = 15,
HWQUANTON_UART1_LASTITEM = 16
};
enum {
HWQUANTON_UART2_DISABLED = 0,
HWQUANTON_UART2_TELEMETRY = 1,
HWQUANTON_UART2_GPS = 2,
HWQUANTON_UART2_S_BUS = 3,
HWQUANTON_UART2_DSM = 4,
HWQUANTON_UART2_DEBUGCONSOLE = 5,
HWQUANTON_UART2_COMBRIDGE = 6,
HWQUANTON_UART2_MAVLINKTX = 7,
HWQUANTON_UART2_MAVLINKTX_GPS_RX = 8,
HWQUANTON_UART2_HOTT_SUMD = 9,
HWQUANTON_UART2_HOTT_SUMH = 10,
HWQUANTON_UART2_HOTT_TELEMETRY = 11,
HWQUANTON_UART2_FRSKY_SENSOR_HUB = 12,
HWQUANTON_UART2_LIGHTTELEMETRYTX = 13,
HWQUANTON_UART2_PICOC = 14,
HWQUANTON_UART2_FRSKY_SPORT_TELEMETRY = 15,
HWQUANTON_UART2_LASTITEM = 16
};
enum {
HWQUANTON_UART3_DISABLED = 0,
HWQUANTON_UART3_TELEMETRY = 1,
HWQUANTON_UART3_GPS = 2,
HWQUANTON_UART3_I2C = 3,
HWQUANTON_UART3_DSM = 4,
HWQUANTON_UART3_DEBUGCONSOLE = 5,
HWQUANTON_UART3_COMBRIDGE = 6,
HWQUANTON_UART3_MAVLINKTX = 7,
HWQUANTON_UART3_MAVLINKTX_GPS_RX = 8,
HWQUANTON_UART3_HOTT_SUMD = 9,
HWQUANTON_UART3_HOTT_SUMH = 10,
HWQUANTON_UART3_HOTT_TELEMETRY = 11,
HWQUANTON_UART3_FRSKY_SENSOR_HUB = 12,
HWQUANTON_UART3_LIGHTTELEMETRYTX = 13,
HWQUANTON_UART3_PICOC = 14,
HWQUANTON_UART3_FRSKY_SPORT_TELEMETRY = 15,
HWQUANTON_UART3_LASTITEM = 16
};
enum {
HWQUANTON_UART4_DISABLED = 0,
HWQUANTON_UART4_TELEMETRY = 1,
HWQUANTON_UART4_GPS = 2,
HWQUANTON_UART4_DSM = 3,
HWQUANTON_UART4_DEBUGCONSOLE = 4,
HWQUANTON_UART4_COMBRIDGE = 5,
HWQUANTON_UART4_MAVLINKTX = 6,
HWQUANTON_UART4_MAVLINKTX_GPS_RX = 7,
HWQUANTON_UART4_HOTT_SUMD = 8,
HWQUANTON_UART4_HOTT_SUMH = 9,
HWQUANTON_UART4_HOTT_TELEMETRY = 10,
HWQUANTON_UART4_LIGHTTELEMETRYTX = 11,
HWQUANTON_UART4_FRSKY_SENSOR_HUB = 12,
HWQUANTON_UART4_PICOC = 13,
HWQUANTON_UART4_FRSKY_SPORT_TELEMETRY = 14,
HWQUANTON_UART4_LASTITEM = 15
};
enum {
HWQUANTON_UART5_DISABLED = 0,
HWQUANTON_UART5_TELEMETRY = 1,
HWQUANTON_UART5_GPS = 2,
HWQUANTON_UART5_DSM = 3,
HWQUANTON_UART5_DEBUGCONSOLE = 4,
HWQUANTON_UART5_COMBRIDGE = 5,
HWQUANTON_UART5_MAVLINKTX = 6,
HWQUANTON_UART5_MAVLINKTX_GPS_RX = 7,
HWQUANTON_UART5_HOTT_SUMD = 8,
HWQUANTON_UART5_HOTT_SUMH = 9,
HWQUANTON_UART5_HOTT_TELEMETRY = 10,
HWQUANTON_UART5_FRSKY_SENSOR_HUB = 11,
HWQUANTON_UART5_LIGHTTELEMETRYTX = 12,
HWQUANTON_UART5_PICOC = 13,
HWQUANTON_UART5_FRSKY_SPORT_TELEMETRY = 14,
HWQUANTON_UART5_LASTITEM = 15
};
enum {
HWQUANTON_USB_HIDPORT_USBTELEMETRY = 0,
HWQUANTON_USB_HIDPORT_RCTRANSMITTER = 1,
HWQUANTON_USB_HIDPORT_DISABLED = 2,
HWQUANTON_USB_HIDPORT_LASTITEM = 3
};
enum {
HWQUANTON_USB_VCPPORT_USBTELEMETRY = 0,
HWQUANTON_USB_VCPPORT_COMBRIDGE = 1,
HWQUANTON_USB_VCPPORT_DEBUGCONSOLE = 2,
HWQUANTON_USB_VCPPORT_PICOC = 3,
HWQUANTON_USB_VCPPORT_DISABLED = 4,
HWQUANTON_USB_VCPPORT_LASTITEM = 5
};
enum {
HWQUANTON_GYRORANGE_250 = 0,
HWQUANTON_GYRORANGE_500 = 1,
HWQUANTON_GYRORANGE_1000 = 2,
HWQUANTON_GYRORANGE_2000 = 3,
HWQUANTON_GYRORANGE_LASTITEM = 4
};
enum {
HWQUANTON_ACCELRANGE_2G = 0,
HWQUANTON_ACCELRANGE_4G = 1,
HWQUANTON_ACCELRANGE_8G = 2,
HWQUANTON_ACCELRANGE_16G = 3,
HWQUANTON_ACCELRANGE_LASTITEM = 4
};
enum {
HWQUANTON_MPU6000RATE_200 = 0,
HWQUANTON_MPU6000RATE_333 = 1,
HWQUANTON_MPU6000RATE_500 = 2,
HWQUANTON_MPU6000RATE_666 = 3,
HWQUANTON_MPU6000RATE_1000 = 4,
HWQUANTON_MPU6000RATE_2000 = 5,
HWQUANTON_MPU6000RATE_4000 = 6,
HWQUANTON_MPU6000RATE_8000 = 7,
HWQUANTON_MPU6000RATE_LASTITEM = 8
};
enum {
HWQUANTON_MPU6000DLPF_256 = 0,
HWQUANTON_MPU6000DLPF_188 = 1,
HWQUANTON_MPU6000DLPF_98 = 2,
HWQUANTON_MPU6000DLPF_42 = 3,
HWQUANTON_MPU6000DLPF_20 = 4,
HWQUANTON_MPU6000DLPF_10 = 5,
HWQUANTON_MPU6000DLPF_5 = 6,
HWQUANTON_MPU6000DLPF_LASTITEM = 7
};
enum {
HWQUANTON_MAGNETOMETER_DISABLED = 0,
HWQUANTON_MAGNETOMETER_INTERNAL = 1,
HWQUANTON_MAGNETOMETER_EXTERNALI2CUART1 = 2,
HWQUANTON_MAGNETOMETER_EXTERNALI2CUART3 = 3,
HWQUANTON_MAGNETOMETER_LASTITEM = 4
};
enum {
HWQUANTON_EXTMAGORIENTATION_TOP0DEGCW = 0,
HWQUANTON_EXTMAGORIENTATION_TOP90DEGCW = 1,
HWQUANTON_EXTMAGORIENTATION_TOP180DEGCW = 2,
HWQUANTON_EXTMAGORIENTATION_TOP270DEGCW = 3,
HWQUANTON_EXTMAGORIENTATION_BOTTOM0DEGCW = 4,
HWQUANTON_EXTMAGORIENTATION_BOTTOM90DEGCW = 5,
HWQUANTON_EXTMAGORIENTATION_BOTTOM180DEGCW = 6,
HWQUANTON_EXTMAGORIENTATION_BOTTOM270DEGCW = 7,
HWQUANTON_EXTMAGORIENTATION_LASTITEM = 8
};
extern char UAVT_HwQuantonRcvrPortOption[][42];
extern char UAVT_HwQuantonUart1Option[][42];
extern char UAVT_HwQuantonUart2Option[][42];
extern char UAVT_HwQuantonUart3Option[][42];
extern char UAVT_HwQuantonUart4Option[][42];
extern char UAVT_HwQuantonUart5Option[][42];
extern char UAVT_HwQuantonUSB_HIDPortOption[][42];
extern char UAVT_HwQuantonUSB_VCPPortOption[][42];
extern char UAVT_HwQuantonGyroRangeOption[][42];
extern char UAVT_HwQuantonAccelRangeOption[][42];
extern char UAVT_HwQuantonMPU6000RateOption[][42];
extern char UAVT_HwQuantonMPU6000DLPFOption[][42];
extern char UAVT_HwQuantonMagnetometerOption[][42];
extern char UAVT_HwQuantonExtMagOrientationOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t Uart1; // enum
uint8_t Uart2; // enum
uint8_t Uart3; // enum
uint8_t Uart4; // enum
uint8_t Uart5; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU6000Rate; // enum
uint8_t MPU6000DLPF; // enum
uint8_t Magnetometer; // enum
uint8_t ExtMagOrientation; // enum
} UAVT_HwQuantonData;
extern UAVT_HwQuantonData uavtalk_HwQuantonData;
/*************************************************************************************************
Filename: hwrevolution.xml
Object: HwRevolution
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWREVOLUTION_OBJID 0xd9ac7e1a
enum {
HWREVOLUTION_RCVRPORT_DISABLED = 0,
HWREVOLUTION_RCVRPORT_PWM = 1,
HWREVOLUTION_RCVRPORT_PPM = 2,
HWREVOLUTION_RCVRPORT_PPM_OUTPUTS = 3,
HWREVOLUTION_RCVRPORT_OUTPUTS = 4,
HWREVOLUTION_RCVRPORT_LASTITEM = 5
};
enum {
HWREVOLUTION_AUXPORT_DISABLED = 0,
HWREVOLUTION_AUXPORT_TELEMETRY = 1,
HWREVOLUTION_AUXPORT_DSM = 2,
HWREVOLUTION_AUXPORT_DEBUGCONSOLE = 3,
HWREVOLUTION_AUXPORT_COMBRIDGE = 4,
HWREVOLUTION_AUXPORT_MAVLINKTX = 5,
HWREVOLUTION_AUXPORT_MAVLINKTX_GPS_RX = 6,
HWREVOLUTION_AUXPORT_HOTT_SUMD = 7,
HWREVOLUTION_AUXPORT_HOTT_SUMH = 8,
HWREVOLUTION_AUXPORT_HOTT_TELEMETRY = 9,
HWREVOLUTION_AUXPORT_PICOC = 10,
HWREVOLUTION_AUXPORT_FRSKY_SPORT_TELEMETRY = 11,
HWREVOLUTION_AUXPORT_LASTITEM = 12
};
enum {
HWREVOLUTION_AUXSBUSPORT_DISABLED = 0,
HWREVOLUTION_AUXSBUSPORT_S_BUS = 1,
HWREVOLUTION_AUXSBUSPORT_DSM = 2,
HWREVOLUTION_AUXSBUSPORT_DEBUGCONSOLE = 3,
HWREVOLUTION_AUXSBUSPORT_COMBRIDGE = 4,
HWREVOLUTION_AUXSBUSPORT_MAVLINKTX = 5,
HWREVOLUTION_AUXSBUSPORT_MAVLINKTX_GPS_RX = 6,
HWREVOLUTION_AUXSBUSPORT_HOTT_SUMD = 7,
HWREVOLUTION_AUXSBUSPORT_HOTT_SUMH = 8,
HWREVOLUTION_AUXSBUSPORT_HOTT_TELEMETRY = 9,
HWREVOLUTION_AUXSBUSPORT_PICOC = 10,
HWREVOLUTION_AUXSBUSPORT_FRSKY_SPORT_TELEMETRY = 11,
HWREVOLUTION_AUXSBUSPORT_LASTITEM = 12
};
enum {
HWREVOLUTION_FLEXIPORT_DISABLED = 0,
HWREVOLUTION_FLEXIPORT_I2C = 1,
HWREVOLUTION_FLEXIPORT_DSM = 2,
HWREVOLUTION_FLEXIPORT_DEBUGCONSOLE = 3,
HWREVOLUTION_FLEXIPORT_COMBRIDGE = 4,
HWREVOLUTION_FLEXIPORT_MAVLINKTX = 5,
HWREVOLUTION_FLEXIPORT_MAVLINKTX_GPS_RX = 6,
HWREVOLUTION_FLEXIPORT_HOTT_SUMD = 7,
HWREVOLUTION_FLEXIPORT_HOTT_SUMH = 8,
HWREVOLUTION_FLEXIPORT_HOTT_TELEMETRY = 9,
HWREVOLUTION_FLEXIPORT_PICOC = 10,
HWREVOLUTION_FLEXIPORT_FRSKY_SPORT_TELEMETRY = 11,
HWREVOLUTION_FLEXIPORT_LASTITEM = 12
};
enum {
HWREVOLUTION_TELEMETRYPORT_DISABLED = 0,
HWREVOLUTION_TELEMETRYPORT_TELEMETRY = 1,
HWREVOLUTION_TELEMETRYPORT_DEBUGCONSOLE = 2,
HWREVOLUTION_TELEMETRYPORT_COMBRIDGE = 3,
HWREVOLUTION_TELEMETRYPORT_LASTITEM = 4
};
enum {
HWREVOLUTION_GPSPORT_DISABLED = 0,
HWREVOLUTION_GPSPORT_TELEMETRY = 1,
HWREVOLUTION_GPSPORT_GPS = 2,
HWREVOLUTION_GPSPORT_DEBUGCONSOLE = 3,
HWREVOLUTION_GPSPORT_COMBRIDGE = 4,
HWREVOLUTION_GPSPORT_LASTITEM = 5
};
enum {
HWREVOLUTION_USB_HIDPORT_USBTELEMETRY = 0,
HWREVOLUTION_USB_HIDPORT_RCTRANSMITTER = 1,
HWREVOLUTION_USB_HIDPORT_DISABLED = 2,
HWREVOLUTION_USB_HIDPORT_LASTITEM = 3
};
enum {
HWREVOLUTION_USB_VCPPORT_USBTELEMETRY = 0,
HWREVOLUTION_USB_VCPPORT_COMBRIDGE = 1,
HWREVOLUTION_USB_VCPPORT_DEBUGCONSOLE = 2,
HWREVOLUTION_USB_VCPPORT_PICOC = 3,
HWREVOLUTION_USB_VCPPORT_DISABLED = 4,
HWREVOLUTION_USB_VCPPORT_LASTITEM = 5
};
enum {
HWREVOLUTION_GYRORANGE_250 = 0,
HWREVOLUTION_GYRORANGE_500 = 1,
HWREVOLUTION_GYRORANGE_1000 = 2,
HWREVOLUTION_GYRORANGE_2000 = 3,
HWREVOLUTION_GYRORANGE_LASTITEM = 4
};
enum {
HWREVOLUTION_ACCELRANGE_2G = 0,
HWREVOLUTION_ACCELRANGE_4G = 1,
HWREVOLUTION_ACCELRANGE_8G = 2,
HWREVOLUTION_ACCELRANGE_16G = 3,
HWREVOLUTION_ACCELRANGE_LASTITEM = 4
};
enum {
HWREVOLUTION_MPU6000RATE_200 = 0,
HWREVOLUTION_MPU6000RATE_333 = 1,
HWREVOLUTION_MPU6000RATE_500 = 2,
HWREVOLUTION_MPU6000RATE_666 = 3,
HWREVOLUTION_MPU6000RATE_1000 = 4,
HWREVOLUTION_MPU6000RATE_2000 = 5,
HWREVOLUTION_MPU6000RATE_4000 = 6,
HWREVOLUTION_MPU6000RATE_8000 = 7,
HWREVOLUTION_MPU6000RATE_LASTITEM = 8
};
enum {
HWREVOLUTION_MPU6000DLPF_256 = 0,
HWREVOLUTION_MPU6000DLPF_188 = 1,
HWREVOLUTION_MPU6000DLPF_98 = 2,
HWREVOLUTION_MPU6000DLPF_42 = 3,
HWREVOLUTION_MPU6000DLPF_20 = 4,
HWREVOLUTION_MPU6000DLPF_10 = 5,
HWREVOLUTION_MPU6000DLPF_5 = 6,
HWREVOLUTION_MPU6000DLPF_LASTITEM = 7
};
extern char UAVT_HwRevolutionRcvrPortOption[][42];
extern char UAVT_HwRevolutionAuxPortOption[][42];
extern char UAVT_HwRevolutionAuxSBusPortOption[][42];
extern char UAVT_HwRevolutionFlexiPortOption[][42];
extern char UAVT_HwRevolutionTelemetryPortOption[][42];
extern char UAVT_HwRevolutionGPSPortOption[][42];
extern char UAVT_HwRevolutionUSB_HIDPortOption[][42];
extern char UAVT_HwRevolutionUSB_VCPPortOption[][42];
extern char UAVT_HwRevolutionGyroRangeOption[][42];
extern char UAVT_HwRevolutionAccelRangeOption[][42];
extern char UAVT_HwRevolutionMPU6000RateOption[][42];
extern char UAVT_HwRevolutionMPU6000DLPFOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t AuxPort; // enum
uint8_t AuxSBusPort; // enum
uint8_t FlexiPort; // enum
uint8_t TelemetryPort; // enum
uint8_t GPSPort; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU6000Rate; // enum
uint8_t MPU6000DLPF; // enum
} UAVT_HwRevolutionData;
extern UAVT_HwRevolutionData uavtalk_HwRevolutionData;
/*************************************************************************************************
Filename: hwrevomini.xml
Object: HwRevoMini
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWREVOMINI_OBJID 0xb265ad64
enum {
HWREVOMINI_RCVRPORT_DISABLED = 0,
HWREVOMINI_RCVRPORT_PWM = 1,
HWREVOMINI_RCVRPORT_PPM = 2,
HWREVOMINI_RCVRPORT_PPM_PWM = 3,
HWREVOMINI_RCVRPORT_PPM_OUTPUTS = 4,
HWREVOMINI_RCVRPORT_OUTPUTS = 5,
HWREVOMINI_RCVRPORT_LASTITEM = 6
};
enum {
HWREVOMINI_MAINPORT_DISABLED = 0,
HWREVOMINI_MAINPORT_TELEMETRY = 1,
HWREVOMINI_MAINPORT_GPS = 2,
HWREVOMINI_MAINPORT_S_BUS = 3,
HWREVOMINI_MAINPORT_DSM = 4,
HWREVOMINI_MAINPORT_DEBUGCONSOLE = 5,
HWREVOMINI_MAINPORT_COMBRIDGE = 6,
HWREVOMINI_MAINPORT_MAVLINKTX = 7,
HWREVOMINI_MAINPORT_MAVLINKTX_GPS_RX = 8,
HWREVOMINI_MAINPORT_HOTT_SUMD = 9,
HWREVOMINI_MAINPORT_HOTT_SUMH = 10,
HWREVOMINI_MAINPORT_HOTT_TELEMETRY = 11,
HWREVOMINI_MAINPORT_FRSKY_SENSOR_HUB = 12,
HWREVOMINI_MAINPORT_LIGHTTELEMETRYTX = 13,
HWREVOMINI_MAINPORT_PICOC = 14,
HWREVOMINI_MAINPORT_FRSKY_SPORT_TELEMETRY = 15,
HWREVOMINI_MAINPORT_LASTITEM = 16
};
enum {
HWREVOMINI_FLEXIPORT_DISABLED = 0,
HWREVOMINI_FLEXIPORT_TELEMETRY = 1,
HWREVOMINI_FLEXIPORT_GPS = 2,
HWREVOMINI_FLEXIPORT_I2C = 3,
HWREVOMINI_FLEXIPORT_DSM = 4,
HWREVOMINI_FLEXIPORT_DEBUGCONSOLE = 5,
HWREVOMINI_FLEXIPORT_COMBRIDGE = 6,
HWREVOMINI_FLEXIPORT_MAVLINKTX = 7,
HWREVOMINI_FLEXIPORT_MAVLINKTX_GPS_RX = 8,
HWREVOMINI_FLEXIPORT_HOTT_SUMD = 9,
HWREVOMINI_FLEXIPORT_HOTT_SUMH = 10,
HWREVOMINI_FLEXIPORT_HOTT_TELEMETRY = 11,
HWREVOMINI_FLEXIPORT_FRSKY_SENSOR_HUB = 12,
HWREVOMINI_FLEXIPORT_LIGHTTELEMETRYTX = 13,
HWREVOMINI_FLEXIPORT_PICOC = 14,
HWREVOMINI_FLEXIPORT_FRSKY_SPORT_TELEMETRY = 15,
HWREVOMINI_FLEXIPORT_LASTITEM = 16
};
enum {
HWREVOMINI_RADIOPORT_DISABLED = 0,
HWREVOMINI_RADIOPORT_TELEMETRY = 1,
HWREVOMINI_RADIOPORT_LASTITEM = 2
};
enum {
HWREVOMINI_USB_HIDPORT_USBTELEMETRY = 0,
HWREVOMINI_USB_HIDPORT_RCTRANSMITTER = 1,
HWREVOMINI_USB_HIDPORT_DISABLED = 2,
HWREVOMINI_USB_HIDPORT_LASTITEM = 3
};
enum {
HWREVOMINI_USB_VCPPORT_USBTELEMETRY = 0,
HWREVOMINI_USB_VCPPORT_COMBRIDGE = 1,
HWREVOMINI_USB_VCPPORT_DEBUGCONSOLE = 2,
HWREVOMINI_USB_VCPPORT_PICOC = 3,
HWREVOMINI_USB_VCPPORT_DISABLED = 4,
HWREVOMINI_USB_VCPPORT_LASTITEM = 5
};
enum {
HWREVOMINI_GYRORANGE_250 = 0,
HWREVOMINI_GYRORANGE_500 = 1,
HWREVOMINI_GYRORANGE_1000 = 2,
HWREVOMINI_GYRORANGE_2000 = 3,
HWREVOMINI_GYRORANGE_LASTITEM = 4
};
enum {
HWREVOMINI_ACCELRANGE_2G = 0,
HWREVOMINI_ACCELRANGE_4G = 1,
HWREVOMINI_ACCELRANGE_8G = 2,
HWREVOMINI_ACCELRANGE_16G = 3,
HWREVOMINI_ACCELRANGE_LASTITEM = 4
};
enum {
HWREVOMINI_MPU6000RATE_200 = 0,
HWREVOMINI_MPU6000RATE_333 = 1,
HWREVOMINI_MPU6000RATE_500 = 2,
HWREVOMINI_MPU6000RATE_666 = 3,
HWREVOMINI_MPU6000RATE_1000 = 4,
HWREVOMINI_MPU6000RATE_2000 = 5,
HWREVOMINI_MPU6000RATE_4000 = 6,
HWREVOMINI_MPU6000RATE_8000 = 7,
HWREVOMINI_MPU6000RATE_LASTITEM = 8
};
enum {
HWREVOMINI_MPU6000DLPF_256 = 0,
HWREVOMINI_MPU6000DLPF_188 = 1,
HWREVOMINI_MPU6000DLPF_98 = 2,
HWREVOMINI_MPU6000DLPF_42 = 3,
HWREVOMINI_MPU6000DLPF_20 = 4,
HWREVOMINI_MPU6000DLPF_10 = 5,
HWREVOMINI_MPU6000DLPF_5 = 6,
HWREVOMINI_MPU6000DLPF_LASTITEM = 7
};
extern char UAVT_HwRevoMiniRcvrPortOption[][42];
extern char UAVT_HwRevoMiniMainPortOption[][42];
extern char UAVT_HwRevoMiniFlexiPortOption[][42];
extern char UAVT_HwRevoMiniRadioPortOption[][42];
extern char UAVT_HwRevoMiniUSB_HIDPortOption[][42];
extern char UAVT_HwRevoMiniUSB_VCPPortOption[][42];
extern char UAVT_HwRevoMiniGyroRangeOption[][42];
extern char UAVT_HwRevoMiniAccelRangeOption[][42];
extern char UAVT_HwRevoMiniMPU6000RateOption[][42];
extern char UAVT_HwRevoMiniMPU6000DLPFOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t MainPort; // enum
uint8_t FlexiPort; // enum
uint8_t RadioPort; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU6000Rate; // enum
uint8_t MPU6000DLPF; // enum
} UAVT_HwRevoMiniData;
extern UAVT_HwRevoMiniData uavtalk_HwRevoMiniData;
/*************************************************************************************************
Filename: hwsparkybgc.xml
Object: HwSparkyBGC
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWSPARKYBGC_OBJID 0xd76f3a36
enum {
HWSPARKYBGC_RCVRPORT_DISABLED = 0,
HWSPARKYBGC_RCVRPORT_PPM = 1,
HWSPARKYBGC_RCVRPORT_S_BUS = 2,
HWSPARKYBGC_RCVRPORT_DSM = 3,
HWSPARKYBGC_RCVRPORT_HOTT_SUMD = 4,
HWSPARKYBGC_RCVRPORT_HOTT_SUMH = 5,
HWSPARKYBGC_RCVRPORT_LASTITEM = 6
};
enum {
HWSPARKYBGC_FLEXIPORT_DISABLED = 0,
HWSPARKYBGC_FLEXIPORT_TELEMETRY = 1,
HWSPARKYBGC_FLEXIPORT_DEBUGCONSOLE = 2,
HWSPARKYBGC_FLEXIPORT_COMBRIDGE = 3,
HWSPARKYBGC_FLEXIPORT_GPS = 4,
HWSPARKYBGC_FLEXIPORT_S_BUS = 5,
HWSPARKYBGC_FLEXIPORT_DSM = 6,
HWSPARKYBGC_FLEXIPORT_MAVLINKTX = 7,
HWSPARKYBGC_FLEXIPORT_MAVLINKTX_GPS_RX = 8,
HWSPARKYBGC_FLEXIPORT_HOTT_TELEMETRY = 9,
HWSPARKYBGC_FLEXIPORT_FRSKY_SENSOR_HUB = 10,
HWSPARKYBGC_FLEXIPORT_LIGHTTELEMETRYTX = 11,
HWSPARKYBGC_FLEXIPORT_FRSKY_SPORT_TELEMETRY = 12,
HWSPARKYBGC_FLEXIPORT_LASTITEM = 13
};
enum {
HWSPARKYBGC_USB_HIDPORT_USBTELEMETRY = 0,
HWSPARKYBGC_USB_HIDPORT_RCTRANSMITTER = 1,
HWSPARKYBGC_USB_HIDPORT_DISABLED = 2,
HWSPARKYBGC_USB_HIDPORT_LASTITEM = 3
};
enum {
HWSPARKYBGC_USB_VCPPORT_USBTELEMETRY = 0,
HWSPARKYBGC_USB_VCPPORT_COMBRIDGE = 1,
HWSPARKYBGC_USB_VCPPORT_DEBUGCONSOLE = 2,
HWSPARKYBGC_USB_VCPPORT_DISABLED = 3,
HWSPARKYBGC_USB_VCPPORT_LASTITEM = 4
};
enum {
HWSPARKYBGC_GYRORANGE_250 = 0,
HWSPARKYBGC_GYRORANGE_500 = 1,
HWSPARKYBGC_GYRORANGE_1000 = 2,
HWSPARKYBGC_GYRORANGE_2000 = 3,
HWSPARKYBGC_GYRORANGE_LASTITEM = 4
};
enum {
HWSPARKYBGC_ACCELRANGE_2G = 0,
HWSPARKYBGC_ACCELRANGE_4G = 1,
HWSPARKYBGC_ACCELRANGE_8G = 2,
HWSPARKYBGC_ACCELRANGE_16G = 3,
HWSPARKYBGC_ACCELRANGE_LASTITEM = 4
};
enum {
HWSPARKYBGC_MPU9150DLPF_256 = 0,
HWSPARKYBGC_MPU9150DLPF_188 = 1,
HWSPARKYBGC_MPU9150DLPF_98 = 2,
HWSPARKYBGC_MPU9150DLPF_42 = 3,
HWSPARKYBGC_MPU9150DLPF_20 = 4,
HWSPARKYBGC_MPU9150DLPF_10 = 5,
HWSPARKYBGC_MPU9150DLPF_5 = 6,
HWSPARKYBGC_MPU9150DLPF_LASTITEM = 7
};
enum {
HWSPARKYBGC_MPU9150RATE_200 = 0,
HWSPARKYBGC_MPU9150RATE_333 = 1,
HWSPARKYBGC_MPU9150RATE_444 = 2,
HWSPARKYBGC_MPU9150RATE_500 = 3,
HWSPARKYBGC_MPU9150RATE_666 = 4,
HWSPARKYBGC_MPU9150RATE_1000 = 5,
HWSPARKYBGC_MPU9150RATE_2000 = 6,
HWSPARKYBGC_MPU9150RATE_4000 = 7,
HWSPARKYBGC_MPU9150RATE_8000 = 8,
HWSPARKYBGC_MPU9150RATE_LASTITEM = 9
};
extern char UAVT_HwSparkyBGCRcvrPortOption[][42];
extern char UAVT_HwSparkyBGCFlexiPortOption[][42];
extern char UAVT_HwSparkyBGCUSB_HIDPortOption[][42];
extern char UAVT_HwSparkyBGCUSB_VCPPortOption[][42];
extern char UAVT_HwSparkyBGCGyroRangeOption[][42];
extern char UAVT_HwSparkyBGCAccelRangeOption[][42];
extern char UAVT_HwSparkyBGCMPU9150DLPFOption[][42];
extern char UAVT_HwSparkyBGCMPU9150RateOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t FlexiPort; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU9150DLPF; // enum
uint8_t MPU9150Rate; // enum
} UAVT_HwSparkyBGCData;
extern UAVT_HwSparkyBGCData uavtalk_HwSparkyBGCData;
/*************************************************************************************************
Filename: hwsparky.xml
Object: HwSparky
Comment: Selection of optional hardware configurations.
*************************************************************************************************/
#define HWSPARKY_OBJID 0x858c848a
enum {
HWSPARKY_RCVRPORT_DISABLED = 0,
HWSPARKY_RCVRPORT_PPM = 1,
HWSPARKY_RCVRPORT_S_BUS = 2,
HWSPARKY_RCVRPORT_DSM = 3,
HWSPARKY_RCVRPORT_HOTT_SUMD = 4,
HWSPARKY_RCVRPORT_HOTT_SUMH = 5,
HWSPARKY_RCVRPORT_LASTITEM = 6
};
enum {
HWSPARKY_FLEXIPORT_DISABLED = 0,
HWSPARKY_FLEXIPORT_TELEMETRY = 1,
HWSPARKY_FLEXIPORT_DEBUGCONSOLE = 2,
HWSPARKY_FLEXIPORT_COMBRIDGE = 3,
HWSPARKY_FLEXIPORT_GPS = 4,
HWSPARKY_FLEXIPORT_S_BUS = 5,
HWSPARKY_FLEXIPORT_DSM = 6,
HWSPARKY_FLEXIPORT_MAVLINKTX = 7,
HWSPARKY_FLEXIPORT_MAVLINKTX_GPS_RX = 8,
HWSPARKY_FLEXIPORT_HOTT_TELEMETRY = 9,
HWSPARKY_FLEXIPORT_FRSKY_SENSOR_HUB = 10,
HWSPARKY_FLEXIPORT_LIGHTTELEMETRYTX = 11,
HWSPARKY_FLEXIPORT_FRSKY_SPORT_TELEMETRY = 12,
HWSPARKY_FLEXIPORT_LASTITEM = 13
};
enum {
HWSPARKY_MAINPORT_DISABLED = 0,
HWSPARKY_MAINPORT_TELEMETRY = 1,
HWSPARKY_MAINPORT_DEBUGCONSOLE = 2,
HWSPARKY_MAINPORT_COMBRIDGE = 3,
HWSPARKY_MAINPORT_GPS = 4,
HWSPARKY_MAINPORT_S_BUS = 5,
HWSPARKY_MAINPORT_DSM = 6,
HWSPARKY_MAINPORT_MAVLINKTX = 7,
HWSPARKY_MAINPORT_MAVLINKTX_GPS_RX = 8,
HWSPARKY_MAINPORT_HOTT_TELEMETRY = 9,
HWSPARKY_MAINPORT_FRSKY_SENSOR_HUB = 10,
HWSPARKY_MAINPORT_LIGHTTELEMETRYTX = 11,
HWSPARKY_MAINPORT_FRSKY_SPORT_TELEMETRY = 12,
HWSPARKY_MAINPORT_LASTITEM = 13
};
enum {
HWSPARKY_OUTPORT_PWM10 = 0,
HWSPARKY_OUTPORT_PWM7_3ADC = 1,
HWSPARKY_OUTPORT_PWM8_2ADC = 2,
HWSPARKY_OUTPORT_PWM9_PWM_IN = 3,
HWSPARKY_OUTPORT_PWM7_PWM_IN_2ADC = 4,
HWSPARKY_OUTPORT_LASTITEM = 5
};
enum {
HWSPARKY_USB_HIDPORT_USBTELEMETRY = 0,
HWSPARKY_USB_HIDPORT_RCTRANSMITTER = 1,
HWSPARKY_USB_HIDPORT_DISABLED = 2,
HWSPARKY_USB_HIDPORT_LASTITEM = 3
};
enum {
HWSPARKY_USB_VCPPORT_USBTELEMETRY = 0,
HWSPARKY_USB_VCPPORT_COMBRIDGE = 1,
HWSPARKY_USB_VCPPORT_DEBUGCONSOLE = 2,
HWSPARKY_USB_VCPPORT_DISABLED = 3,
HWSPARKY_USB_VCPPORT_LASTITEM = 4
};
enum {
HWSPARKY_GYRORANGE_250 = 0,
HWSPARKY_GYRORANGE_500 = 1,
HWSPARKY_GYRORANGE_1000 = 2,
HWSPARKY_GYRORANGE_2000 = 3,
HWSPARKY_GYRORANGE_LASTITEM = 4
};
enum {
HWSPARKY_ACCELRANGE_2G = 0,
HWSPARKY_ACCELRANGE_4G = 1,
HWSPARKY_ACCELRANGE_8G = 2,
HWSPARKY_ACCELRANGE_16G = 3,
HWSPARKY_ACCELRANGE_LASTITEM = 4
};
enum {
HWSPARKY_MPU9150DLPF_256 = 0,
HWSPARKY_MPU9150DLPF_188 = 1,
HWSPARKY_MPU9150DLPF_98 = 2,
HWSPARKY_MPU9150DLPF_42 = 3,
HWSPARKY_MPU9150DLPF_20 = 4,
HWSPARKY_MPU9150DLPF_10 = 5,
HWSPARKY_MPU9150DLPF_5 = 6,
HWSPARKY_MPU9150DLPF_LASTITEM = 7
};
enum {
HWSPARKY_MPU9150RATE_200 = 0,
HWSPARKY_MPU9150RATE_333 = 1,
HWSPARKY_MPU9150RATE_444 = 2,
HWSPARKY_MPU9150RATE_500 = 3,
HWSPARKY_MPU9150RATE_666 = 4,
HWSPARKY_MPU9150RATE_1000 = 5,
HWSPARKY_MPU9150RATE_2000 = 6,
HWSPARKY_MPU9150RATE_4000 = 7,
HWSPARKY_MPU9150RATE_8000 = 8,
HWSPARKY_MPU9150RATE_LASTITEM = 9
};
extern char UAVT_HwSparkyRcvrPortOption[][42];
extern char UAVT_HwSparkyFlexiPortOption[][42];
extern char UAVT_HwSparkyMainPortOption[][42];
extern char UAVT_HwSparkyOutPortOption[][42];
extern char UAVT_HwSparkyUSB_HIDPortOption[][42];
extern char UAVT_HwSparkyUSB_VCPPortOption[][42];
extern char UAVT_HwSparkyGyroRangeOption[][42];
extern char UAVT_HwSparkyAccelRangeOption[][42];
extern char UAVT_HwSparkyMPU9150DLPFOption[][42];
extern char UAVT_HwSparkyMPU9150RateOption[][42];
typedef struct {
uint8_t RcvrPort; // enum
uint8_t FlexiPort; // enum
uint8_t MainPort; // enum
uint8_t OutPort; // enum
uint8_t USB_HIDPort; // enum
uint8_t USB_VCPPort; // enum
uint8_t DSMxBind;
uint8_t GyroRange; // enum
uint8_t AccelRange; // enum
uint8_t MPU9150DLPF; // enum
uint8_t MPU9150Rate; // enum
} UAVT_HwSparkyData;
extern UAVT_HwSparkyData uavtalk_HwSparkyData;
/*************************************************************************************************
Filename: i2cvmuserprogram.xml
Object: I2CVMUserProgram
Comment: Allows GCS to provide a user-defined program to the I2C Virtual Machine
*************************************************************************************************/
#define I2CVMUSERPROGRAM_OBJID 0xed9cc1ac
typedef struct {
uint32_t Program[20];
} UAVT_I2CVMUserProgramData;
extern UAVT_I2CVMUserProgramData uavtalk_I2CVMUserProgramData;
/*************************************************************************************************
Filename: i2cvm.xml
Object: I2CVM
Comment: Snapshot of the register and RAM state of the I2C Virtual Machine
*************************************************************************************************/
#define I2CVM_OBJID 0x2a6a5146
typedef struct {
int32_t r0;
int32_t r1;
int32_t r2;
int32_t r3;
int32_t r4;
int32_t r5;
int32_t r6;
uint16_t pc;
uint8_t ram[8];
} UAVT_I2CVMData;
extern UAVT_I2CVMData uavtalk_I2CVMData;
/*************************************************************************************************
Filename: inssettings.xml
Object: INSSettings
Comment: Settings for the INS to control the algorithm and what is updated
*************************************************************************************************/
#define INSSETTINGS_OBJID 0x8ccff752
enum {
INSSETTINGS_COMPUTEGYROBIAS_FALSE = 0,
INSSETTINGS_COMPUTEGYROBIAS_TRUE = 1,
INSSETTINGS_COMPUTEGYROBIAS_LASTITEM = 2
};
extern char UAVT_INSSettingsComputeGyroBiasOption[][42];
typedef struct {
float X;
float Y;
float Z;
} UAVT_INSSettingsaccel_varType;
typedef struct {
float X;
float Y;
float Z;
} UAVT_INSSettingsgyro_varType;
typedef struct {
float X;
float Y;
float Z;
} UAVT_INSSettingsmag_varType;
typedef struct {
float Pos;
float Vel;
float VertPos;
} UAVT_INSSettingsgps_varType;
typedef struct {
UAVT_INSSettingsaccel_varType accel_var; // float[3]
UAVT_INSSettingsgyro_varType gyro_var; // float[3]
UAVT_INSSettingsmag_varType mag_var; // float[3]
UAVT_INSSettingsgps_varType gps_var; // float[3]
float baro_var;
float MagBiasNullingRate;
uint8_t ComputeGyroBias; // enum
} UAVT_INSSettingsData;
extern UAVT_INSSettingsData uavtalk_INSSettingsData;
/*************************************************************************************************
Filename: insstate.xml
Object: INSState
Comment: Contains the INS state estimate
*************************************************************************************************/
#define INSSTATE_OBJID 0xae367e26
typedef struct {
float State[13];
float Var[13];
} UAVT_INSStateData;
extern UAVT_INSStateData uavtalk_INSStateData;
/*************************************************************************************************
Filename: loggingsettings.xml
Object: LoggingSettings
Comment: Settings for the logging module
*************************************************************************************************/
#define LOGGINGSETTINGS_OBJID 0xa1b7f8a2
enum {
LOGGINGSETTINGS_LOGBEHAVIOR_LOGONSTART = 0,
LOGGINGSETTINGS_LOGBEHAVIOR_LOGONARM = 1,
LOGGINGSETTINGS_LOGBEHAVIOR_LOGOFF = 2,
LOGGINGSETTINGS_LOGBEHAVIOR_LASTITEM = 3
};
extern char UAVT_LoggingSettingsLogBehaviorOption[][42];
typedef struct {
uint8_t LogBehavior; // enum
} UAVT_LoggingSettingsData;
extern UAVT_LoggingSettingsData uavtalk_LoggingSettingsData;
/*************************************************************************************************
Filename: loggingstats.xml
Object: LoggingStats
Comment: Information about logging
*************************************************************************************************/
#define LOGGINGSTATS_OBJID 0x4c859a62
enum {
LOGGINGSTATS_OPERATION_LOGGING = 0,
LOGGINGSTATS_OPERATION_IDLE = 1,
LOGGINGSTATS_OPERATION_DOWNLOAD = 2,
LOGGINGSTATS_OPERATION_COMPLETE = 3,
LOGGINGSTATS_OPERATION_ERROR = 4,
LOGGINGSTATS_OPERATION_LASTITEM = 5
};
extern char UAVT_LoggingStatsOperationOption[][42];
typedef struct {
uint32_t BytesLogged;
uint16_t MinFileId;
uint16_t MaxFileId;
uint16_t FileRequest;
uint16_t FileSectorNum;
uint8_t Operation; // enum
uint8_t FileSector[128];
} UAVT_LoggingStatsData;
extern UAVT_LoggingStatsData uavtalk_LoggingStatsData;
/*************************************************************************************************
Filename: loitercommand.xml
Object: LoiterCommand
Comment: Requested movement while in loiter mode
*************************************************************************************************/
#define LOITERCOMMAND_OBJID 0x80d8d4ba
enum {
LOITERCOMMAND_FRAME_BODY = 0,
LOITERCOMMAND_FRAME_EARTH = 1,
LOITERCOMMAND_FRAME_LASTITEM = 2
};
extern char UAVT_LoiterCommandFrameOption[][42];
typedef struct {
float Forward;
float Right;
float Upwards;
uint8_t Frame; // enum
} UAVT_LoiterCommandData;
extern UAVT_LoiterCommandData uavtalk_LoiterCommandData;
/*************************************************************************************************
Filename: magbias.xml
Object: MagBias
Comment: The gyro data.
*************************************************************************************************/
#define MAGBIAS_OBJID 0x5043e510
typedef struct {
float x;
float y;
float z;
} UAVT_MagBiasData;
extern UAVT_MagBiasData uavtalk_MagBiasData;
/*************************************************************************************************
Filename: magnetometer.xml
Object: Magnetometer
Comment: The mag data.
*************************************************************************************************/
#define MAGNETOMETER_OBJID 0x813b55de
typedef struct {
float x;
float y;
float z;
} UAVT_MagnetometerData;
extern UAVT_MagnetometerData uavtalk_MagnetometerData;
/*************************************************************************************************
Filename: manualcontrolcommand.xml
Object: ManualControlCommand
Comment: The output from the @ref ManualControlModule which decodes the receiver inputs.
*************************************************************************************************/
#define MANUALCONTROLCOMMAND_OBJID 0x5c2f58ac
enum {
MANUALCONTROLCOMMAND_CONNECTED_FALSE = 0,
MANUALCONTROLCOMMAND_CONNECTED_TRUE = 1,
MANUALCONTROLCOMMAND_CONNECTED_LASTITEM = 2
};
extern char UAVT_ManualControlCommandConnectedOption[][42];
typedef struct {
uint16_t Throttle;
uint16_t Roll;
uint16_t Pitch;
uint16_t Yaw;
uint16_t FlightMode;
uint16_t Collective;
uint16_t Accessory0;
uint16_t Accessory1;
uint16_t Accessory2;
uint16_t Arming;
} UAVT_ManualControlCommandChannelType;
typedef struct {
float Throttle;
float Roll;
float Pitch;
float Yaw;
uint32_t RawRssi;
float Collective;
int16_t Rssi;
UAVT_ManualControlCommandChannelType Channel; // uint16[10]
uint8_t Connected; // enum
} UAVT_ManualControlCommandData;
extern UAVT_ManualControlCommandData uavtalk_ManualControlCommandData;
/*************************************************************************************************
Filename: manualcontrolsettings.xml
Object: ManualControlSettings
Comment: Settings to indicate how to decode receiver input by @ref ManualControlModule.
*************************************************************************************************/
#define MANUALCONTROLSETTINGS_OBJID 0x837ed6ca
enum {
MANUALCONTROLSETTINGS_CHANNELGROUPS_PWM = 0,
MANUALCONTROLSETTINGS_CHANNELGROUPS_PPM = 1,
MANUALCONTROLSETTINGS_CHANNELGROUPS_DSM__MAINPORT_ = 2,
MANUALCONTROLSETTINGS_CHANNELGROUPS_DSM__FLEXIPORT_ = 3,
MANUALCONTROLSETTINGS_CHANNELGROUPS_S_BUS = 4,
MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS = 5,
MANUALCONTROLSETTINGS_CHANNELGROUPS_HOTT_SUM = 6,
MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE = 7,
MANUALCONTROLSETTINGS_CHANNELGROUPS_LASTITEM = 8
};
enum {
MANUALCONTROLSETTINGS_RSSITYPE_NONE = 0,
MANUALCONTROLSETTINGS_RSSITYPE_PWM = 1,
MANUALCONTROLSETTINGS_RSSITYPE_PPM = 2,
MANUALCONTROLSETTINGS_RSSITYPE_ADC = 3,
MANUALCONTROLSETTINGS_RSSITYPE_LASTITEM = 4
};
enum {
MANUALCONTROLSETTINGS_ARMING_ALWAYS_DISARMED = 0,
MANUALCONTROLSETTINGS_ARMING_ALWAYS_ARMED = 1,
MANUALCONTROLSETTINGS_ARMING_ROLL_LEFT = 2,
MANUALCONTROLSETTINGS_ARMING_ROLL_RIGHT = 3,
MANUALCONTROLSETTINGS_ARMING_PITCH_FORWARD = 4,
MANUALCONTROLSETTINGS_ARMING_PITCH_AFT = 5,
MANUALCONTROLSETTINGS_ARMING_YAW_LEFT = 6,
MANUALCONTROLSETTINGS_ARMING_YAW_RIGHT = 7,
MANUALCONTROLSETTINGS_ARMING_SWITCH = 8,
MANUALCONTROLSETTINGS_ARMING_LASTITEM = 9
};
enum {
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_NONE = 0,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_RATE = 1,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ATTITUDE = 2,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_AXISLOCK = 3,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_WEAKLEVELING = 4,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_VIRTUALBAR = 5,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_HORIZON = 6,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_RATEMW = 7,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_SYSTEMIDENT = 8,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_POI = 9,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_COORDINATEDFLIGHT = 10,
MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_LASTITEM = 11
};
enum {
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_NONE = 0,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_RATE = 1,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_ATTITUDE = 2,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_AXISLOCK = 3,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_WEAKLEVELING = 4,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_VIRTUALBAR = 5,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_HORIZON = 6,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_RATEMW = 7,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_SYSTEMIDENT = 8,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_POI = 9,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_COORDINATEDFLIGHT = 10,
MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_LASTITEM = 11
};
enum {
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_NONE = 0,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_RATE = 1,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_ATTITUDE = 2,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_AXISLOCK = 3,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_WEAKLEVELING = 4,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_VIRTUALBAR = 5,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_HORIZON = 6,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_RATEMW = 7,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_SYSTEMIDENT = 8,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_POI = 9,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_COORDINATEDFLIGHT = 10,
MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_LASTITEM = 11
};
enum {
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_MANUAL = 0,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ACRO = 1,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_LEVELING = 2,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_VIRTUALBAR = 3,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED1 = 4,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED2 = 5,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED3 = 6,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_AUTOTUNE = 7,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ALTITUDEHOLD = 8,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_VELOCITYCONTROL = 9,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_POSITIONHOLD = 10,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_RETURNTOHOME = 11,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_PATHPLANNER = 12,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_TABLETCONTROL = 13,
MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_LASTITEM = 14
};
extern char UAVT_ManualControlSettingsChannelGroupsOption[][42];
extern char UAVT_ManualControlSettingsRssiTypeOption[][42];
extern char UAVT_ManualControlSettingsArmingOption[][42];
extern char UAVT_ManualControlSettingsStabilization1SettingsOption[][42];
extern char UAVT_ManualControlSettingsStabilization2SettingsOption[][42];
extern char UAVT_ManualControlSettingsStabilization3SettingsOption[][42];
extern char UAVT_ManualControlSettingsFlightModePositionOption[][42];
typedef struct {
int16_t Throttle;
int16_t Roll;
int16_t Pitch;
int16_t Yaw;
int16_t FlightMode;
int16_t Collective;
int16_t Accessory0;
int16_t Accessory1;
int16_t Accessory2;
int16_t Arming;
} UAVT_ManualControlSettingsChannelMinType;
typedef struct {
int16_t Throttle;
int16_t Roll;
int16_t Pitch;
int16_t Yaw;
int16_t FlightMode;
int16_t Collective;
int16_t Accessory0;
int16_t Accessory1;
int16_t Accessory2;
int16_t Arming;
} UAVT_ManualControlSettingsChannelNeutralType;
typedef struct {
int16_t Throttle;
int16_t Roll;
int16_t Pitch;
int16_t Yaw;
int16_t FlightMode;
int16_t Collective;
int16_t Accessory0;
int16_t Accessory1;
int16_t Accessory2;
int16_t Arming;
} UAVT_ManualControlSettingsChannelMaxType;
typedef struct {
uint8_t Throttle;
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
uint8_t FlightMode;
uint8_t Collective;
uint8_t Accessory0;
uint8_t Accessory1;
uint8_t Accessory2;
uint8_t Arming;
} UAVT_ManualControlSettingsChannelGroupsType;
typedef struct {
uint8_t Throttle;
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
uint8_t FlightMode;
uint8_t Collective;
uint8_t Accessory0;
uint8_t Accessory1;
uint8_t Accessory2;
uint8_t Arming;
} UAVT_ManualControlSettingsChannelNumberType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_ManualControlSettingsStabilization1SettingsType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_ManualControlSettingsStabilization2SettingsType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_ManualControlSettingsStabilization3SettingsType;
typedef struct {
float Deadband;
int16_t RssiMax;
int16_t RssiMin;
int16_t RssiPwmPeriod;
UAVT_ManualControlSettingsChannelMinType ChannelMin; // int16[10]
UAVT_ManualControlSettingsChannelNeutralType ChannelNeutral; // int16[10]
UAVT_ManualControlSettingsChannelMaxType ChannelMax; // int16[10]
uint16_t ArmedTimeout;
UAVT_ManualControlSettingsChannelGroupsType ChannelGroups; // enum[10]
uint8_t RssiType; // enum
uint8_t RssiChannelNumber;
UAVT_ManualControlSettingsChannelNumberType ChannelNumber; // uint8[10]
uint8_t Arming; // enum
UAVT_ManualControlSettingsStabilization1SettingsType Stabilization1Settings; // enum[3]
UAVT_ManualControlSettingsStabilization2SettingsType Stabilization2Settings; // enum[3]
UAVT_ManualControlSettingsStabilization3SettingsType Stabilization3Settings; // enum[3]
uint8_t FlightModeNumber;
uint8_t FlightModePosition[6]; // enum
} UAVT_ManualControlSettingsData;
extern UAVT_ManualControlSettingsData uavtalk_ManualControlSettingsData;
/*************************************************************************************************
Filename: mixersettings.xml
Object: MixerSettings
Comment: Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType
*************************************************************************************************/
#define MIXERSETTINGS_OBJID 0x20e376cc
enum {
MIXERSETTINGS_CURVE2SOURCE_THROTTLE = 0,
MIXERSETTINGS_CURVE2SOURCE_ROLL = 1,
MIXERSETTINGS_CURVE2SOURCE_PITCH = 2,
MIXERSETTINGS_CURVE2SOURCE_YAW = 3,
MIXERSETTINGS_CURVE2SOURCE_COLLECTIVE = 4,
MIXERSETTINGS_CURVE2SOURCE_ACCESSORY0 = 5,
MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1 = 6,
MIXERSETTINGS_CURVE2SOURCE_ACCESSORY2 = 7,
MIXERSETTINGS_CURVE2SOURCE_ACCESSORY3 = 8,
MIXERSETTINGS_CURVE2SOURCE_ACCESSORY4 = 9,
MIXERSETTINGS_CURVE2SOURCE_ACCESSORY5 = 10,
MIXERSETTINGS_CURVE2SOURCE_LASTITEM = 11
};
enum {
MIXERSETTINGS_MIXER1TYPE_DISABLED = 0,
MIXERSETTINGS_MIXER1TYPE_MOTOR = 1,
MIXERSETTINGS_MIXER1TYPE_SERVO = 2,
MIXERSETTINGS_MIXER1TYPE_CAMERAROLL = 3,
MIXERSETTINGS_MIXER1TYPE_CAMERAPITCH = 4,
MIXERSETTINGS_MIXER1TYPE_CAMERAYAW = 5,
MIXERSETTINGS_MIXER1TYPE_ACCESSORY0 = 6,
MIXERSETTINGS_MIXER1TYPE_ACCESSORY1 = 7,
MIXERSETTINGS_MIXER1TYPE_ACCESSORY2 = 8,
MIXERSETTINGS_MIXER1TYPE_ACCESSORY3 = 9,
MIXERSETTINGS_MIXER1TYPE_ACCESSORY4 = 10,
MIXERSETTINGS_MIXER1TYPE_ACCESSORY5 = 11,
MIXERSETTINGS_MIXER1TYPE_LASTITEM = 12
};
extern char UAVT_MixerSettingsCurve2SourceOption[][42];
extern char UAVT_MixerSettingsMixer1TypeOption[][42];
typedef struct {
float n;
float n2;
float n5;
float n7;
float n1;
} UAVT_MixerSettingsThrottleCurve1Type;
typedef struct {
float n;
float n2;
float n5;
float n7;
float n1;
} UAVT_MixerSettingsThrottleCurve2Type;
typedef struct {
int8_t ThrottleCurve1;
int8_t ThrottleCurve2;
int8_t Roll;
int8_t Pitch;
int8_t Yaw;
} UAVT_MixerSettingsMixer1VectorType;
typedef struct {
float MaxAccel;
float FeedForward;
float AccelTime;
float DecelTime;
UAVT_MixerSettingsThrottleCurve1Type ThrottleCurve1; // float[5]
UAVT_MixerSettingsThrottleCurve2Type ThrottleCurve2; // float[5]
uint8_t Curve2Source; // enum
uint8_t Mixer1Type; // enum
UAVT_MixerSettingsMixer1VectorType Mixer1Vector; // int8[5]
uint8_t Mixer2Type;
uint8_t Mixer2Vector;
uint8_t Mixer3Type;
uint8_t Mixer3Vector;
uint8_t Mixer4Type;
uint8_t Mixer4Vector;
uint8_t Mixer5Type;
uint8_t Mixer5Vector;
uint8_t Mixer6Type;
uint8_t Mixer6Vector;
uint8_t Mixer7Type;
uint8_t Mixer7Vector;
uint8_t Mixer8Type;
uint8_t Mixer8Vector;
uint8_t Mixer9Type;
uint8_t Mixer9Vector;
uint8_t Mixer10Type;
uint8_t Mixer10Vector;
} UAVT_MixerSettingsData;
extern UAVT_MixerSettingsData uavtalk_MixerSettingsData;
/*************************************************************************************************
Filename: mixerstatus.xml
Object: MixerStatus
Comment: Status for the matrix mixer showing the output of each mixer after all scaling
*************************************************************************************************/
#define MIXERSTATUS_OBJID 0x124e28a
typedef struct {
float Mixer1;
float Mixer2;
float Mixer3;
float Mixer4;
float Mixer5;
float Mixer6;
float Mixer7;
float Mixer8;
float Mixer9;
float Mixer10;
} UAVT_MixerStatusData;
extern UAVT_MixerStatusData uavtalk_MixerStatusData;
/*************************************************************************************************
Filename: modulesettings.xml
Object: ModuleSettings
Comment: Optional module enable/disable configuration.
*************************************************************************************************/
#define MODULESETTINGS_OBJID 0x50780700
enum {
MODULESETTINGS_ADMINSTATE_DISABLED = 0,
MODULESETTINGS_ADMINSTATE_ENABLED = 1,
MODULESETTINGS_ADMINSTATE_LASTITEM = 2
};
enum {
MODULESETTINGS_TELEMETRYSPEED_2400 = 0,
MODULESETTINGS_TELEMETRYSPEED_4800 = 1,
MODULESETTINGS_TELEMETRYSPEED_9600 = 2,
MODULESETTINGS_TELEMETRYSPEED_19200 = 3,
MODULESETTINGS_TELEMETRYSPEED_38400 = 4,
MODULESETTINGS_TELEMETRYSPEED_57600 = 5,
MODULESETTINGS_TELEMETRYSPEED_115200 = 6,
MODULESETTINGS_TELEMETRYSPEED_LASTITEM = 7
};
enum {
MODULESETTINGS_GPSSPEED_2400 = 0,
MODULESETTINGS_GPSSPEED_4800 = 1,
MODULESETTINGS_GPSSPEED_9600 = 2,
MODULESETTINGS_GPSSPEED_19200 = 3,
MODULESETTINGS_GPSSPEED_38400 = 4,
MODULESETTINGS_GPSSPEED_57600 = 5,
MODULESETTINGS_GPSSPEED_115200 = 6,
MODULESETTINGS_GPSSPEED_230400 = 7,
MODULESETTINGS_GPSSPEED_LASTITEM = 8
};
enum {
MODULESETTINGS_GPSDATAPROTOCOL_NMEA = 0,
MODULESETTINGS_GPSDATAPROTOCOL_UBX = 1,
MODULESETTINGS_GPSDATAPROTOCOL_LASTITEM = 2
};
enum {
MODULESETTINGS_GPSAUTOCONFIGURE_FALSE = 0,
MODULESETTINGS_GPSAUTOCONFIGURE_TRUE = 1,
MODULESETTINGS_GPSAUTOCONFIGURE_LASTITEM = 2
};
enum {
MODULESETTINGS_COMUSBBRIDGESPEED_2400 = 0,
MODULESETTINGS_COMUSBBRIDGESPEED_4800 = 1,
MODULESETTINGS_COMUSBBRIDGESPEED_9600 = 2,
MODULESETTINGS_COMUSBBRIDGESPEED_19200 = 3,
MODULESETTINGS_COMUSBBRIDGESPEED_38400 = 4,
MODULESETTINGS_COMUSBBRIDGESPEED_57600 = 5,
MODULESETTINGS_COMUSBBRIDGESPEED_115200 = 6,
MODULESETTINGS_COMUSBBRIDGESPEED_LASTITEM = 7
};
enum {
MODULESETTINGS_I2CVMPROGRAMSELECT_ENDIANTEST = 0,
MODULESETTINGS_I2CVMPROGRAMSELECT_MATHTEST = 1,
MODULESETTINGS_I2CVMPROGRAMSELECT_NONE = 2,
MODULESETTINGS_I2CVMPROGRAMSELECT_OPBAROALTIMETER = 3,
MODULESETTINGS_I2CVMPROGRAMSELECT_USER = 4,
MODULESETTINGS_I2CVMPROGRAMSELECT_LASTITEM = 5
};
enum {
MODULESETTINGS_MAVLINKSPEED_2400 = 0,
MODULESETTINGS_MAVLINKSPEED_4800 = 1,
MODULESETTINGS_MAVLINKSPEED_9600 = 2,
MODULESETTINGS_MAVLINKSPEED_19200 = 3,
MODULESETTINGS_MAVLINKSPEED_38400 = 4,
MODULESETTINGS_MAVLINKSPEED_57600 = 5,
MODULESETTINGS_MAVLINKSPEED_115200 = 6,
MODULESETTINGS_MAVLINKSPEED_LASTITEM = 7
};
enum {
MODULESETTINGS_LIGHTTELEMETRYSPEED_1200 = 0,
MODULESETTINGS_LIGHTTELEMETRYSPEED_2400 = 1,
MODULESETTINGS_LIGHTTELEMETRYSPEED_4800 = 2,
MODULESETTINGS_LIGHTTELEMETRYSPEED_9600 = 3,
MODULESETTINGS_LIGHTTELEMETRYSPEED_19200 = 4,
MODULESETTINGS_LIGHTTELEMETRYSPEED_38400 = 5,
MODULESETTINGS_LIGHTTELEMETRYSPEED_57600 = 6,
MODULESETTINGS_LIGHTTELEMETRYSPEED_115200 = 7,
MODULESETTINGS_LIGHTTELEMETRYSPEED_LASTITEM = 8
};
extern char UAVT_ModuleSettingsAdminStateOption[][42];
extern char UAVT_ModuleSettingsTelemetrySpeedOption[][42];
extern char UAVT_ModuleSettingsGPSSpeedOption[][42];
extern char UAVT_ModuleSettingsGPSDataProtocolOption[][42];
extern char UAVT_ModuleSettingsGPSAutoConfigureOption[][42];
extern char UAVT_ModuleSettingsComUsbBridgeSpeedOption[][42];
extern char UAVT_ModuleSettingsI2CVMProgramSelectOption[][42];
extern char UAVT_ModuleSettingsMavlinkSpeedOption[][42];
extern char UAVT_ModuleSettingsLightTelemetrySpeedOption[][42];
typedef struct {
uint8_t Airspeed;
uint8_t AltitudeHold;
uint8_t Autotune;
uint8_t Battery;
uint8_t CameraStab;
uint8_t ComUsbBridge;
uint8_t FixedWingPathFollower;
uint8_t Fault;
uint8_t GPS;
uint8_t OveroSync;
uint8_t PathPlanner;
uint8_t TxPID;
uint8_t VtolPathFollower;
uint8_t GroundPathFollower;
uint8_t GenericI2CSensor;
uint8_t UAVOMavlinkBridge;
uint8_t UAVOLighttelemetryBridge;
uint8_t VibrationAnalysis;
uint8_t UAVOHoTTBridge;
uint8_t UAVOFrSKYSensorHubBridge;
uint8_t PicoC;
uint8_t UAVOFrSkySPortBridge;
uint8_t Geofence;
uint8_t Logging;
} UAVT_ModuleSettingsAdminStateType;
typedef struct {
UAVT_ModuleSettingsAdminStateType AdminState; // enum[24]
uint8_t TelemetrySpeed; // enum
uint8_t GPSSpeed; // enum
uint8_t GPSDataProtocol; // enum
uint8_t GPSAutoConfigure; // enum
uint8_t ComUsbBridgeSpeed; // enum
uint8_t I2CVMProgramSelect; // enum
uint8_t MavlinkSpeed; // enum
uint8_t LightTelemetrySpeed; // enum
} UAVT_ModuleSettingsData;
extern UAVT_ModuleSettingsData uavtalk_ModuleSettingsData;
/*************************************************************************************************
Filename: mwratesettings.xml
Object: MWRateSettings
Comment: PID settings used by the MWRate stabilization settings
*************************************************************************************************/
#define MWRATESETTINGS_OBJID 0xbd3b5f28
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_MWRateSettingsRollRatePIDType;
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_MWRateSettingsPitchRatePIDType;
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_MWRateSettingsYawRatePIDType;
typedef struct {
UAVT_MWRateSettingsRollRatePIDType RollRatePID; // float[4]
UAVT_MWRateSettingsPitchRatePIDType PitchRatePID; // float[4]
UAVT_MWRateSettingsYawRatePIDType YawRatePID; // float[4]
float DerivativeGamma;
uint8_t RollPitchRate;
uint8_t YawRate;
} UAVT_MWRateSettingsData;
extern UAVT_MWRateSettingsData uavtalk_MWRateSettingsData;
/*************************************************************************************************
Filename: nedaccel.xml
Object: NedAccel
Comment: The projection of acceleration in the NED reference frame used by @ref Guidance.
*************************************************************************************************/
#define NEDACCEL_OBJID 0x7c7f5bc0
typedef struct {
float North;
float East;
float Down;
} UAVT_NedAccelData;
extern UAVT_NedAccelData uavtalk_NedAccelData;
/*************************************************************************************************
Filename: nedposition.xml
Object: NEDPosition
Comment: Contains the current position relative to @ref HomeLocation
*************************************************************************************************/
#define NEDPOSITION_OBJID 0x1fb15a00
typedef struct {
float North;
float East;
float Down;
} UAVT_NEDPositionData;
extern UAVT_NEDPositionData uavtalk_NEDPositionData;
/*************************************************************************************************
Filename: objectpersistence.xml
Object: ObjectPersistence
Comment: Someone who knows please enter this
*************************************************************************************************/
#define OBJECTPERSISTENCE_OBJID 0x99c63292
enum {
OBJECTPERSISTENCE_OPERATION_NOP = 0,
OBJECTPERSISTENCE_OPERATION_LOAD = 1,
OBJECTPERSISTENCE_OPERATION_SAVE = 2,
OBJECTPERSISTENCE_OPERATION_DELETE = 3,
OBJECTPERSISTENCE_OPERATION_FULLERASE = 4,
OBJECTPERSISTENCE_OPERATION_COMPLETED = 5,
OBJECTPERSISTENCE_OPERATION_ERROR = 6,
OBJECTPERSISTENCE_OPERATION_LASTITEM = 7
};
enum {
OBJECTPERSISTENCE_SELECTION_SINGLEOBJECT = 0,
OBJECTPERSISTENCE_SELECTION_ALLSETTINGS = 1,
OBJECTPERSISTENCE_SELECTION_ALLMETAOBJECTS = 2,
OBJECTPERSISTENCE_SELECTION_ALLOBJECTS = 3,
OBJECTPERSISTENCE_SELECTION_LASTITEM = 4
};
extern char UAVT_ObjectPersistenceOperationOption[][42];
extern char UAVT_ObjectPersistenceSelectionOption[][42];
typedef struct {
uint32_t ObjectID;
uint32_t InstanceID;
uint8_t Operation; // enum
uint8_t Selection; // enum
} UAVT_ObjectPersistenceData;
extern UAVT_ObjectPersistenceData uavtalk_ObjectPersistenceData;
/*************************************************************************************************
Filename: oplinksettings.xml
Object: OPLinkSettings
Comment: OPLink configurations options.
*************************************************************************************************/
#define OPLINKSETTINGS_OBJID 0x449737bc
enum {
OPLINKSETTINGS_COORDINATOR_FALSE = 0,
OPLINKSETTINGS_COORDINATOR_TRUE = 1,
OPLINKSETTINGS_COORDINATOR_LASTITEM = 2
};
enum {
OPLINKSETTINGS_PPM_FALSE = 0,
OPLINKSETTINGS_PPM_TRUE = 1,
OPLINKSETTINGS_PPM_LASTITEM = 2
};
enum {
OPLINKSETTINGS_UAVTALK_FALSE = 0,
OPLINKSETTINGS_UAVTALK_TRUE = 1,
OPLINKSETTINGS_UAVTALK_LASTITEM = 2
};
enum {
OPLINKSETTINGS_INPUTCONNECTION_HID = 0,
OPLINKSETTINGS_INPUTCONNECTION_VCP = 1,
OPLINKSETTINGS_INPUTCONNECTION_TELEMETRY = 2,
OPLINKSETTINGS_INPUTCONNECTION_FLEXI = 3,
OPLINKSETTINGS_INPUTCONNECTION_LASTITEM = 4
};
enum {
OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEHID = 0,
OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEVCP = 1,
OPLINKSETTINGS_OUTPUTCONNECTION_REMOTETELEMETRY = 2,
OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEFLEXI = 3,
OPLINKSETTINGS_OUTPUTCONNECTION_TELEMETRY = 4,
OPLINKSETTINGS_OUTPUTCONNECTION_FLEXI = 5,
OPLINKSETTINGS_OUTPUTCONNECTION_LASTITEM = 6
};
enum {
OPLINKSETTINGS_COMSPEED_2400 = 0,
OPLINKSETTINGS_COMSPEED_4800 = 1,
OPLINKSETTINGS_COMSPEED_9600 = 2,
OPLINKSETTINGS_COMSPEED_19200 = 3,
OPLINKSETTINGS_COMSPEED_38400 = 4,
OPLINKSETTINGS_COMSPEED_57600 = 5,
OPLINKSETTINGS_COMSPEED_115200 = 6,
OPLINKSETTINGS_COMSPEED_LASTITEM = 7
};
enum {
OPLINKSETTINGS_MAXRFPOWER_1_25 = 0,
OPLINKSETTINGS_MAXRFPOWER_1_6 = 1,
OPLINKSETTINGS_MAXRFPOWER_3_16 = 2,
OPLINKSETTINGS_MAXRFPOWER_6_3 = 3,
OPLINKSETTINGS_MAXRFPOWER_12_6 = 4,
OPLINKSETTINGS_MAXRFPOWER_25 = 5,
OPLINKSETTINGS_MAXRFPOWER_50 = 6,
OPLINKSETTINGS_MAXRFPOWER_100 = 7,
OPLINKSETTINGS_MAXRFPOWER_LASTITEM = 8
};
extern char UAVT_OPLinkSettingsCoordinatorOption[][42];
extern char UAVT_OPLinkSettingsPPMOption[][42];
extern char UAVT_OPLinkSettingsUAVTalkOption[][42];
extern char UAVT_OPLinkSettingsInputConnectionOption[][42];
extern char UAVT_OPLinkSettingsOutputConnectionOption[][42];
extern char UAVT_OPLinkSettingsComSpeedOption[][42];
extern char UAVT_OPLinkSettingsMaxRFPowerOption[][42];
typedef struct {
uint32_t PairID;
uint32_t MinFrequency;
uint32_t MaxFrequency;
uint16_t SendTimeout;
uint8_t Coordinator; // enum
uint8_t PPM; // enum
uint8_t UAVTalk; // enum
uint8_t InputConnection; // enum
uint8_t OutputConnection; // enum
uint8_t ComSpeed; // enum
uint8_t MaxRFPower; // enum
uint8_t MinPacketSize;
uint8_t FrequencyCalibration;
uint8_t AESKey[32];
} UAVT_OPLinkSettingsData;
extern UAVT_OPLinkSettingsData uavtalk_OPLinkSettingsData;
/*************************************************************************************************
Filename: oplinkstatus.xml
Object: OPLinkStatus
Comment: OPLink device status.
*************************************************************************************************/
#define OPLINKSTATUS_OBJID 0x25e223f0
enum {
OPLINKSTATUS_LINKSTATE_DISCONNECTED = 0,
OPLINKSTATUS_LINKSTATE_CONNECTING = 1,
OPLINKSTATUS_LINKSTATE_CONNECTED = 2,
OPLINKSTATUS_LINKSTATE_LASTITEM = 3
};
extern char UAVT_OPLinkStatusLinkStateOption[][42];
typedef struct {
uint32_t DeviceID;
uint32_t PairIDs[4];
uint16_t BoardRevision;
uint16_t UAVTalkErrors;
uint16_t TXRate;
uint16_t RXRate;
uint16_t TXSeq;
uint16_t RXSeq;
uint8_t Description[40];
uint8_t CPUSerial[12];
uint8_t BoardType;
uint8_t RxGood;
uint8_t RxCorrected;
uint8_t RxErrors;
uint8_t RxMissed;
uint8_t RxFailure;
uint8_t TxResent;
uint8_t TxDropped;
uint8_t TxFailure;
uint8_t Resets;
uint8_t Timeouts;
int8_t RSSI;
int8_t AFCCorrection;
uint8_t LinkQuality;
uint8_t LinkState; // enum
int8_t PairSignalStrengths[4];
} UAVT_OPLinkStatusData;
extern UAVT_OPLinkStatusData uavtalk_OPLinkStatusData;
/*************************************************************************************************
Filename: overosyncsettings.xml
Object: OveroSyncSettings
Comment: Settings to control the behavior of the overo sync module
*************************************************************************************************/
#define OVEROSYNCSETTINGS_OBJID 0xa1abc278
enum {
OVEROSYNCSETTINGS_LOGON_NEVER = 0,
OVEROSYNCSETTINGS_LOGON_ALWAYS = 1,
OVEROSYNCSETTINGS_LOGON_ARMED = 2,
OVEROSYNCSETTINGS_LOGON_LASTITEM = 3
};
extern char UAVT_OveroSyncSettingsLogOnOption[][42];
typedef struct {
uint8_t LogOn; // enum
} UAVT_OveroSyncSettingsData;
extern UAVT_OveroSyncSettingsData uavtalk_OveroSyncSettingsData;
/*************************************************************************************************
Filename: overosyncstats.xml
Object: OveroSyncStats
Comment: Maintains statistics on transfer rate to and from over
*************************************************************************************************/
#define OVEROSYNCSTATS_OBJID 0xd2085fac
enum {
OVEROSYNCSTATS_CONNECTED_FALSE = 0,
OVEROSYNCSTATS_CONNECTED_TRUE = 1,
OVEROSYNCSTATS_CONNECTED_LASTITEM = 2
};
extern char UAVT_OveroSyncStatsConnectedOption[][42];
typedef struct {
uint32_t Send;
uint32_t Received;
uint32_t FramesyncErrors;
uint32_t UnderrunErrors;
uint32_t DroppedUpdates;
uint32_t Packets;
uint8_t Connected; // enum
} UAVT_OveroSyncStatsData;
extern UAVT_OveroSyncStatsData uavtalk_OveroSyncStatsData;
/*************************************************************************************************
Filename: pathdesired.xml
Object: PathDesired
Comment: The endpoint or path the craft is trying to achieve. Can come from @ref ManualControl or @ref PathPlanner
*************************************************************************************************/
#define PATHDESIRED_OBJID 0x8f1cd118
enum {
PATHDESIRED_MODE_FLYENDPOINT = 0,
PATHDESIRED_MODE_FLYVECTOR = 1,
PATHDESIRED_MODE_FLYCIRCLERIGHT = 2,
PATHDESIRED_MODE_FLYCIRCLELEFT = 3,
PATHDESIRED_MODE_DRIVEENDPOINT = 4,
PATHDESIRED_MODE_DRIVEVECTOR = 5,
PATHDESIRED_MODE_DRIVECIRCLELEFT = 6,
PATHDESIRED_MODE_DRIVECIRCLERIGHT = 7,
PATHDESIRED_MODE_HOLDPOSITION = 8,
PATHDESIRED_MODE_CIRCLEPOSITIONLEFT = 9,
PATHDESIRED_MODE_CIRCLEPOSITIONRIGHT = 10,
PATHDESIRED_MODE_LAND = 11,
PATHDESIRED_MODE_LASTITEM = 12
};
extern char UAVT_PathDesiredModeOption[][42];
typedef struct {
float North;
float East;
float Down;
} UAVT_PathDesiredStartType;
typedef struct {
float North;
float East;
float Down;
} UAVT_PathDesiredEndType;
typedef struct {
UAVT_PathDesiredStartType Start; // float[3]
UAVT_PathDesiredEndType End; // float[3]
float StartingVelocity;
float EndingVelocity;
float ModeParameters;
uint8_t Mode; // enum
} UAVT_PathDesiredData;
extern UAVT_PathDesiredData uavtalk_PathDesiredData;
/*************************************************************************************************
Filename: pathplannersettings.xml
Object: PathPlannerSettings
Comment: Settings for the @ref PathPlanner Module
*************************************************************************************************/
#define PATHPLANNERSETTINGS_OBJID 0x77a9e8f0
enum {
PATHPLANNERSETTINGS_PREPROGRAMMEDPATH_NONE = 0,
PATHPLANNERSETTINGS_PREPROGRAMMEDPATH_10M_BOX = 1,
PATHPLANNERSETTINGS_PREPROGRAMMEDPATH_LOGO = 2,
PATHPLANNERSETTINGS_PREPROGRAMMEDPATH_LASTITEM = 3
};
enum {
PATHPLANNERSETTINGS_FLASHOPERATION_NONE = 0,
PATHPLANNERSETTINGS_FLASHOPERATION_FAILED = 1,
PATHPLANNERSETTINGS_FLASHOPERATION_COMPLETED = 2,
PATHPLANNERSETTINGS_FLASHOPERATION_SAVE1 = 3,
PATHPLANNERSETTINGS_FLASHOPERATION_SAVE2 = 4,
PATHPLANNERSETTINGS_FLASHOPERATION_SAVE3 = 5,
PATHPLANNERSETTINGS_FLASHOPERATION_SAVE4 = 6,
PATHPLANNERSETTINGS_FLASHOPERATION_SAVE5 = 7,
PATHPLANNERSETTINGS_FLASHOPERATION_LOAD1 = 8,
PATHPLANNERSETTINGS_FLASHOPERATION_LOAD2 = 9,
PATHPLANNERSETTINGS_FLASHOPERATION_LOAD3 = 10,
PATHPLANNERSETTINGS_FLASHOPERATION_LOAD4 = 11,
PATHPLANNERSETTINGS_FLASHOPERATION_LOAD5 = 12,
PATHPLANNERSETTINGS_FLASHOPERATION_LASTITEM = 13
};
extern char UAVT_PathPlannerSettingsPreprogrammedPathOption[][42];
extern char UAVT_PathPlannerSettingsFlashOperationOption[][42];
typedef struct {
uint8_t PreprogrammedPath; // enum
uint8_t FlashOperation; // enum
} UAVT_PathPlannerSettingsData;
extern UAVT_PathPlannerSettingsData uavtalk_PathPlannerSettingsData;
/*************************************************************************************************
Filename: pathstatus.xml
Object: PathStatus
Comment: Status of the current path mode Can come from any @ref PathFollower module
*************************************************************************************************/
#define PATHSTATUS_OBJID 0x1cfb185a
enum {
PATHSTATUS_STATE_INPROGRESS = 0,
PATHSTATUS_STATE_COMPLETED = 1,
PATHSTATUS_STATE_WARNING = 2,
PATHSTATUS_STATE_CRITICAL = 3,
PATHSTATUS_STATE_LASTITEM = 4
};
extern char UAVT_PathStatusStateOption[][42];
typedef struct {
float fractional_progress;
float error;
uint8_t State; // enum
} UAVT_PathStatusData;
extern UAVT_PathStatusData uavtalk_PathStatusData;
/*************************************************************************************************
Filename: picocsettings.xml
Object: PicoCSettings
Comment: Settings for the @ref PicoC Interpreter Module
*************************************************************************************************/
#define PICOCSETTINGS_OBJID 0x5db16ffe
enum {
PICOCSETTINGS_STARTUP_DISABLED = 0,
PICOCSETTINGS_STARTUP_ONBOOT = 1,
PICOCSETTINGS_STARTUP_WHENARMED = 2,
PICOCSETTINGS_STARTUP_LASTITEM = 3
};
enum {
PICOCSETTINGS_SOURCE_DISABLED = 0,
PICOCSETTINGS_SOURCE_DEMO = 1,
PICOCSETTINGS_SOURCE_INTERACTIVE = 2,
PICOCSETTINGS_SOURCE_FILE = 3,
PICOCSETTINGS_SOURCE_LASTITEM = 4
};
enum {
PICOCSETTINGS_COMSPEED_2400 = 0,
PICOCSETTINGS_COMSPEED_4800 = 1,
PICOCSETTINGS_COMSPEED_9600 = 2,
PICOCSETTINGS_COMSPEED_19200 = 3,
PICOCSETTINGS_COMSPEED_38400 = 4,
PICOCSETTINGS_COMSPEED_57600 = 5,
PICOCSETTINGS_COMSPEED_115200 = 6,
PICOCSETTINGS_COMSPEED_LASTITEM = 7
};
extern char UAVT_PicoCSettingsStartupOption[][42];
extern char UAVT_PicoCSettingsSourceOption[][42];
extern char UAVT_PicoCSettingsComSpeedOption[][42];
typedef struct {
uint32_t MaxFileSize;
uint32_t TaskStackSize;
uint32_t PicoCStackSize;
uint8_t BootFileID;
uint8_t Startup; // enum
uint8_t Source; // enum
uint8_t ComSpeed; // enum
} UAVT_PicoCSettingsData;
extern UAVT_PicoCSettingsData uavtalk_PicoCSettingsData;
/*************************************************************************************************
Filename: picocstatus.xml
Object: PicoCStatus
Comment: status information of the @ref PicoC Interpreter Module.
*************************************************************************************************/
#define PICOCSTATUS_OBJID 0xf132538a
enum {
PICOCSTATUS_COMMAND_IDLE = 0,
PICOCSTATUS_COMMAND_STARTSCRIPT = 1,
PICOCSTATUS_COMMAND_USARTMODE = 2,
PICOCSTATUS_COMMAND_GETSECTOR = 3,
PICOCSTATUS_COMMAND_SETSECTOR = 4,
PICOCSTATUS_COMMAND_LOADFILE = 5,
PICOCSTATUS_COMMAND_SAVEFILE = 6,
PICOCSTATUS_COMMAND_DELETEFILE = 7,
PICOCSTATUS_COMMAND_FORMATPARTITION = 8,
PICOCSTATUS_COMMAND_LASTITEM = 9
};
extern char UAVT_PicoCStatusCommandOption[][42];
typedef struct {
int16_t ExitValue;
int16_t TestValue;
uint16_t SectorID;
uint8_t FileID;
uint8_t Command; // enum
int8_t CommandError;
uint8_t Sector[32];
} UAVT_PicoCStatusData;
extern UAVT_PicoCStatusData uavtalk_PicoCStatusData;
/*************************************************************************************************
Filename: poilocation.xml
Object: PoiLocation
Comment: Contains the current Point of interest relative to @ref HomeLocation
*************************************************************************************************/
#define POILOCATION_OBJID 0x17e829b8
typedef struct {
float North;
float East;
float Down;
} UAVT_PoiLocationData;
extern UAVT_PoiLocationData uavtalk_PoiLocationData;
/*************************************************************************************************
Filename: positionactual.xml
Object: PositionActual
Comment: Contains the current position relative to @ref HomeLocation
*************************************************************************************************/
#define POSITIONACTUAL_OBJID 0xfa9e2d42
typedef struct {
float North;
float East;
float Down;
} UAVT_PositionActualData;
extern UAVT_PositionActualData uavtalk_PositionActualData;
/*************************************************************************************************
Filename: ratedesired.xml
Object: RateDesired
Comment: Status for the matrix mixer showing the output of each mixer after all scaling
*************************************************************************************************/
#define RATEDESIRED_OBJID 0xce8c826
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_RateDesiredData;
extern UAVT_RateDesiredData uavtalk_RateDesiredData;
/*************************************************************************************************
Filename: receiveractivity.xml
Object: ReceiverActivity
Comment: Monitors which receiver channels have been active within the last second.
*************************************************************************************************/
#define RECEIVERACTIVITY_OBJID 0xc02377e6
enum {
RECEIVERACTIVITY_ACTIVEGROUP_PWM = 0,
RECEIVERACTIVITY_ACTIVEGROUP_PPM = 1,
RECEIVERACTIVITY_ACTIVEGROUP_DSM__MAINPORT_ = 2,
RECEIVERACTIVITY_ACTIVEGROUP_DSM__FLEXIPORT_ = 3,
RECEIVERACTIVITY_ACTIVEGROUP_S_BUS = 4,
RECEIVERACTIVITY_ACTIVEGROUP_GCS = 5,
RECEIVERACTIVITY_ACTIVEGROUP_HOTT_SUM = 6,
RECEIVERACTIVITY_ACTIVEGROUP_NONE = 7,
RECEIVERACTIVITY_ACTIVEGROUP_LASTITEM = 8
};
extern char UAVT_ReceiverActivityActiveGroupOption[][42];
typedef struct {
uint8_t ActiveGroup; // enum
uint8_t ActiveChannel;
} UAVT_ReceiverActivityData;
extern UAVT_ReceiverActivityData uavtalk_ReceiverActivityData;
/*************************************************************************************************
Filename: sensorsettings.xml
Object: SensorSettings
Comment: Settings for the @ref Attitude module
*************************************************************************************************/
#define SENSORSETTINGS_OBJID 0xadb3b106
typedef struct {
float X;
float Y;
float Z;
} UAVT_SensorSettingsAccelBiasType;
typedef struct {
float X;
float Y;
float Z;
} UAVT_SensorSettingsAccelScaleType;
typedef struct {
float X;
float Y;
float Z;
} UAVT_SensorSettingsGyroScaleType;
typedef struct {
float n;
float T;
float T2;
float T3;
} UAVT_SensorSettingsXGyroTempCoeffType;
typedef struct {
float n;
float T;
float T2;
float T3;
} UAVT_SensorSettingsYGyroTempCoeffType;
typedef struct {
float n;
float T;
float T2;
float T3;
} UAVT_SensorSettingsZGyroTempCoeffType;
typedef struct {
float X;
float Y;
float Z;
} UAVT_SensorSettingsMagBiasType;
typedef struct {
float X;
float Y;
float Z;
} UAVT_SensorSettingsMagScaleType;
typedef struct {
UAVT_SensorSettingsAccelBiasType AccelBias; // float[3]
UAVT_SensorSettingsAccelScaleType AccelScale; // float[3]
UAVT_SensorSettingsGyroScaleType GyroScale; // float[3]
UAVT_SensorSettingsXGyroTempCoeffType XGyroTempCoeff; // float[4]
UAVT_SensorSettingsYGyroTempCoeffType YGyroTempCoeff; // float[4]
UAVT_SensorSettingsZGyroTempCoeffType ZGyroTempCoeff; // float[4]
UAVT_SensorSettingsMagBiasType MagBias; // float[3]
UAVT_SensorSettingsMagScaleType MagScale; // float[3]
float ZAccelOffset;
} UAVT_SensorSettingsData;
extern UAVT_SensorSettingsData uavtalk_SensorSettingsData;
/*************************************************************************************************
Filename: sessionmanaging.xml
Object: SessionManaging
Comment: Provides session managing to uavtalk
*************************************************************************************************/
#define SESSIONMANAGING_OBJID 0x89034e4a
typedef struct {
uint32_t ObjectID;
uint16_t SessionID;
uint8_t ObjectInstances;
uint8_t NumberOfObjects;
uint8_t ObjectOfInterestIndex;
} UAVT_SessionManagingData;
extern UAVT_SessionManagingData uavtalk_SessionManagingData;
/*************************************************************************************************
Filename: sonaraltitude.xml
Object: SonarAltitude
Comment: The raw data from the ultrasound sonar sensor with altitude estimate.
*************************************************************************************************/
#define SONARALTITUDE_OBJID 0x6c5a0cbc
typedef struct {
float Altitude;
} UAVT_SonarAltitudeData;
extern UAVT_SonarAltitudeData uavtalk_SonarAltitudeData;
/*************************************************************************************************
Filename: stabilizationdesired.xml
Object: StabilizationDesired
Comment: The desired attitude that @ref StabilizationModule will try and achieve if FlightMode is Stabilized. Comes from @ref ManaulControlModule.
*************************************************************************************************/
#define STABILIZATIONDESIRED_OBJID 0xa237dd8e
enum {
STABILIZATIONDESIRED_STABILIZATIONMODE_NONE = 0,
STABILIZATIONDESIRED_STABILIZATIONMODE_RATE = 1,
STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE = 2,
STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK = 3,
STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING = 4,
STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR = 5,
STABILIZATIONDESIRED_STABILIZATIONMODE_HORIZON = 6,
STABILIZATIONDESIRED_STABILIZATIONMODE_RATEMW = 7,
STABILIZATIONDESIRED_STABILIZATIONMODE_SYSTEMIDENT = 8,
STABILIZATIONDESIRED_STABILIZATIONMODE_POI = 9,
STABILIZATIONDESIRED_STABILIZATIONMODE_COORDINATEDFLIGHT = 10,
STABILIZATIONDESIRED_STABILIZATIONMODE_LASTITEM = 11
};
extern char UAVT_StabilizationDesiredStabilizationModeOption[][42];
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_StabilizationDesiredStabilizationModeType;
typedef struct {
float Roll;
float Pitch;
float Yaw;
float Throttle;
UAVT_StabilizationDesiredStabilizationModeType StabilizationMode; // enum[3]
} UAVT_StabilizationDesiredData;
extern UAVT_StabilizationDesiredData uavtalk_StabilizationDesiredData;
/*************************************************************************************************
Filename: stabilizationsettings.xml
Object: StabilizationSettings
Comment: PID settings used by the Stabilization module to combine the @ref AttitudeActual and @ref AttitudeDesired to compute @ref ActuatorDesired
*************************************************************************************************/
#define STABILIZATIONSETTINGS_OBJID 0x89f756cc
enum {
STABILIZATIONSETTINGS_VBARPIROCOMP_FALSE = 0,
STABILIZATIONSETTINGS_VBARPIROCOMP_TRUE = 1,
STABILIZATIONSETTINGS_VBARPIROCOMP_LASTITEM = 2
};
enum {
STABILIZATIONSETTINGS_LOWTHROTTLEZEROINTEGRAL_FALSE = 0,
STABILIZATIONSETTINGS_LOWTHROTTLEZEROINTEGRAL_TRUE = 1,
STABILIZATIONSETTINGS_LOWTHROTTLEZEROINTEGRAL_LASTITEM = 2
};
extern char UAVT_StabilizationSettingsVbarPiroCompOption[][42];
extern char UAVT_StabilizationSettingsLowThrottleZeroIntegralOption[][42];
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_StabilizationSettingsManualRateType;
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_StabilizationSettingsMaximumRateType;
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_StabilizationSettingsPoiMaximumRateType;
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_StabilizationSettingsRollRatePIDType;
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_StabilizationSettingsPitchRatePIDType;
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_StabilizationSettingsYawRatePIDType;
typedef struct {
float Kp;
float Ki;
float ILimit;
} UAVT_StabilizationSettingsRollPIType;
typedef struct {
float Kp;
float Ki;
float ILimit;
} UAVT_StabilizationSettingsPitchPIType;
typedef struct {
float Kp;
float Ki;
float ILimit;
} UAVT_StabilizationSettingsYawPIType;
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_StabilizationSettingsVbarSensitivityType;
typedef struct {
float Kp;
float Ki;
float Kd;
} UAVT_StabilizationSettingsVbarRollPIDType;
typedef struct {
float Kp;
float Ki;
float Kd;
} UAVT_StabilizationSettingsVbarPitchPIDType;
typedef struct {
float Kp;
float Ki;
float Kd;
} UAVT_StabilizationSettingsVbarYawPIDType;
typedef struct {
float Kp;
float Ki;
float ILimit;
} UAVT_StabilizationSettingsCoordinatedFlightYawPIType;
typedef struct {
uint8_t Roll;
uint8_t Pitch;
uint8_t Yaw;
} UAVT_StabilizationSettingsRateExpoType;
typedef struct {
uint8_t Threshold;
uint8_t Attenuation;
} UAVT_StabilizationSettingsRollRateTPAType;
typedef struct {
uint8_t Threshold;
uint8_t Attenuation;
} UAVT_StabilizationSettingsPitchRateTPAType;
typedef struct {
uint8_t Threshold;
uint8_t Attenuation;
} UAVT_StabilizationSettingsYawRateTPAType;
typedef struct {
UAVT_StabilizationSettingsManualRateType ManualRate; // float[3]
UAVT_StabilizationSettingsMaximumRateType MaximumRate; // float[3]
UAVT_StabilizationSettingsPoiMaximumRateType PoiMaximumRate; // float[3]
UAVT_StabilizationSettingsRollRatePIDType RollRatePID; // float[4]
UAVT_StabilizationSettingsPitchRatePIDType PitchRatePID; // float[4]
UAVT_StabilizationSettingsYawRatePIDType YawRatePID; // float[4]
UAVT_StabilizationSettingsRollPIType RollPI; // float[3]
UAVT_StabilizationSettingsPitchPIType PitchPI; // float[3]
UAVT_StabilizationSettingsYawPIType YawPI; // float[3]
UAVT_StabilizationSettingsVbarSensitivityType VbarSensitivity; // float[3]
UAVT_StabilizationSettingsVbarRollPIDType VbarRollPID; // float[3]
UAVT_StabilizationSettingsVbarPitchPIDType VbarPitchPID; // float[3]
UAVT_StabilizationSettingsVbarYawPIDType VbarYawPID; // float[3]
float VbarTau;
float GyroTau;
float DerivativeGamma;
float WeakLevelingKp;
UAVT_StabilizationSettingsCoordinatedFlightYawPIType CoordinatedFlightYawPI; // float[3]
uint8_t RollMax;
uint8_t PitchMax;
uint8_t YawMax;
UAVT_StabilizationSettingsRateExpoType RateExpo; // uint8[3]
UAVT_StabilizationSettingsRollRateTPAType RollRateTPA; // uint8[2]
UAVT_StabilizationSettingsPitchRateTPAType PitchRateTPA; // uint8[2]
UAVT_StabilizationSettingsYawRateTPAType YawRateTPA; // uint8[2]
int8_t VbarGyroSuppress;
uint8_t VbarPiroComp; // enum
uint8_t VbarMaxAngle;
uint8_t DerivativeCutoff;
uint8_t MaxAxisLock;
uint8_t MaxAxisLockRate;
uint8_t MaxWeakLevelingRate;
uint8_t LowThrottleZeroIntegral; // enum
} UAVT_StabilizationSettingsData;
extern UAVT_StabilizationSettingsData uavtalk_StabilizationSettingsData;
/*************************************************************************************************
Filename: stateestimation.xml
Object: StateEstimation
Comment: Settings for how to estimate the state
*************************************************************************************************/
#define STATEESTIMATION_OBJID 0xba09f7c2
enum {
STATEESTIMATION_ATTITUDEFILTER_COMPLEMENTARY = 0,
STATEESTIMATION_ATTITUDEFILTER_INSINDOOR = 1,
STATEESTIMATION_ATTITUDEFILTER_INSOUTDOOR = 2,
STATEESTIMATION_ATTITUDEFILTER_LASTITEM = 3
};
enum {
STATEESTIMATION_NAVIGATIONFILTER_NONE = 0,
STATEESTIMATION_NAVIGATIONFILTER_RAW = 1,
STATEESTIMATION_NAVIGATIONFILTER_INS = 2,
STATEESTIMATION_NAVIGATIONFILTER_LASTITEM = 3
};
extern char UAVT_StateEstimationAttitudeFilterOption[][42];
extern char UAVT_StateEstimationNavigationFilterOption[][42];
typedef struct {
uint8_t AttitudeFilter; // enum
uint8_t NavigationFilter; // enum
} UAVT_StateEstimationData;
extern UAVT_StateEstimationData uavtalk_StateEstimationData;
/*************************************************************************************************
Filename: systemalarms.xml
Object: SystemAlarms
Comment: Alarms from OpenPilot to indicate failure conditions or warnings. Set by various modules.
*************************************************************************************************/
#define SYSTEMALARMS_OBJID 0xe25dd70e
enum {
SYSTEMALARMS_ALARM_UNINITIALISED = 0,
SYSTEMALARMS_ALARM_OK = 1,
SYSTEMALARMS_ALARM_WARNING = 2,
SYSTEMALARMS_ALARM_ERROR = 3,
SYSTEMALARMS_ALARM_CRITICAL = 4,
SYSTEMALARMS_ALARM_LASTITEM = 5
};
enum {
SYSTEMALARMS_CONFIGERROR_STABILIZATION = 0,
SYSTEMALARMS_CONFIGERROR_MULTIROTOR = 1,
SYSTEMALARMS_CONFIGERROR_AUTOTUNE = 2,
SYSTEMALARMS_CONFIGERROR_ALTITUDEHOLD = 3,
SYSTEMALARMS_CONFIGERROR_VELOCITYCONTROL = 4,
SYSTEMALARMS_CONFIGERROR_POSITIONHOLD = 5,
SYSTEMALARMS_CONFIGERROR_PATHPLANNER = 6,
SYSTEMALARMS_CONFIGERROR_NAVFILTER = 7,
SYSTEMALARMS_CONFIGERROR_UNSAFETOARM = 8,
SYSTEMALARMS_CONFIGERROR_UNDEFINED = 9,
SYSTEMALARMS_CONFIGERROR_NONE = 10,
SYSTEMALARMS_CONFIGERROR_LASTITEM = 11
};
enum {
SYSTEMALARMS_MANUALCONTROL_SETTINGS = 0,
SYSTEMALARMS_MANUALCONTROL_NORX = 1,
SYSTEMALARMS_MANUALCONTROL_ACCESSORY = 2,
SYSTEMALARMS_MANUALCONTROL_ALTITUDEHOLD = 3,
SYSTEMALARMS_MANUALCONTROL_PATHFOLLOWER = 4,
SYSTEMALARMS_MANUALCONTROL_UNDEFINED = 5,
SYSTEMALARMS_MANUALCONTROL_NONE = 6,
SYSTEMALARMS_MANUALCONTROL_LASTITEM = 7
};
enum {
SYSTEMALARMS_STATEESTIMATION_GYRO_QUEUE_NOT_UPDATING = 0,
SYSTEMALARMS_STATEESTIMATION_ACCELEROMETER_QUEUE_NOT_UPDATING = 1,
SYSTEMALARMS_STATEESTIMATION_NO_GPS = 2,
SYSTEMALARMS_STATEESTIMATION_NO_MAGNETOMETER = 3,
SYSTEMALARMS_STATEESTIMATION_NO_BAROMETER = 4,
SYSTEMALARMS_STATEESTIMATION_NO_HOME = 5,
SYSTEMALARMS_STATEESTIMATION_TOO_FEW_SATELLITES = 6,
SYSTEMALARMS_STATEESTIMATION_PDOP_TOO_HIGH = 7,
SYSTEMALARMS_STATEESTIMATION_UNDEFINED = 8,
SYSTEMALARMS_STATEESTIMATION_NONE = 9,
SYSTEMALARMS_STATEESTIMATION_LASTITEM = 10
};
extern char UAVT_SystemAlarmsAlarmOption[][42];
extern char UAVT_SystemAlarmsConfigErrorOption[][42];
extern char UAVT_SystemAlarmsManualControlOption[][42];
extern char UAVT_SystemAlarmsStateEstimationOption[][42];
typedef struct {
uint8_t OutOfMemory;
uint8_t CPUOverload;
uint8_t StackOverflow;
uint8_t SystemConfiguration;
uint8_t EventSystem;
uint8_t Telemetry;
uint8_t ManualControl;
uint8_t Actuator;
uint8_t Attitude;
uint8_t Sensors;
uint8_t Stabilization;
uint8_t Geofence;
uint8_t PathFollower;
uint8_t PathPlanner;
uint8_t Battery;
uint8_t FlightTime;
uint8_t I2C;
uint8_t GPS;
uint8_t AltitudeHold;
uint8_t BootFault;
} UAVT_SystemAlarmsAlarmType;
typedef struct {
UAVT_SystemAlarmsAlarmType Alarm; // enum[20]
uint8_t ConfigError; // enum
uint8_t ManualControl; // enum
uint8_t StateEstimation; // enum
} UAVT_SystemAlarmsData;
extern UAVT_SystemAlarmsData uavtalk_SystemAlarmsData;
/*************************************************************************************************
Filename: systemident.xml
Object: SystemIdent
Comment: The input to the relay tuning.
*************************************************************************************************/
#define SYSTEMIDENT_OBJID 0xadafddf2
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_SystemIdentBetaType;
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_SystemIdentBiasType;
typedef struct {
float Roll;
float Pitch;
float Yaw;
} UAVT_SystemIdentNoiseType;
typedef struct {
float Tau;
UAVT_SystemIdentBetaType Beta; // float[3]
UAVT_SystemIdentBiasType Bias; // float[3]
UAVT_SystemIdentNoiseType Noise; // float[3]
float Period;
} UAVT_SystemIdentData;
extern UAVT_SystemIdentData uavtalk_SystemIdentData;
/*************************************************************************************************
Filename: systemsettings.xml
Object: SystemSettings
Comment: Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand
*************************************************************************************************/
#define SYSTEMSETTINGS_OBJID 0x6f3bb6b0
enum {
SYSTEMSETTINGS_AIRFRAMETYPE_FIXEDWING = 0,
SYSTEMSETTINGS_AIRFRAMETYPE_FIXEDWINGELEVON = 1,
SYSTEMSETTINGS_AIRFRAMETYPE_FIXEDWINGVTAIL = 2,
SYSTEMSETTINGS_AIRFRAMETYPE_VTOL = 3,
SYSTEMSETTINGS_AIRFRAMETYPE_HELICP = 4,
SYSTEMSETTINGS_AIRFRAMETYPE_QUADX = 5,
SYSTEMSETTINGS_AIRFRAMETYPE_QUADP = 6,
SYSTEMSETTINGS_AIRFRAMETYPE_HEXA = 7,
SYSTEMSETTINGS_AIRFRAMETYPE_OCTO = 8,
SYSTEMSETTINGS_AIRFRAMETYPE_CUSTOM = 9,
SYSTEMSETTINGS_AIRFRAMETYPE_HEXAX = 10,
SYSTEMSETTINGS_AIRFRAMETYPE_OCTOV = 11,
SYSTEMSETTINGS_AIRFRAMETYPE_OCTOCOAXP = 12,
SYSTEMSETTINGS_AIRFRAMETYPE_OCTOCOAXX = 13,
SYSTEMSETTINGS_AIRFRAMETYPE_HEXACOAX = 14,
SYSTEMSETTINGS_AIRFRAMETYPE_TRI = 15,
SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLECAR = 16,
SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL = 17,
SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE = 18,
SYSTEMSETTINGS_AIRFRAMETYPE_LASTITEM = 19
};
extern char UAVT_SystemSettingsAirframeTypeOption[][42];
typedef struct {
uint32_t AirframeCategorySpecificConfiguration[4];
uint8_t AirframeType; // enum
} UAVT_SystemSettingsData;
extern UAVT_SystemSettingsData uavtalk_SystemSettingsData;
/*************************************************************************************************
Filename: systemstats.xml
Object: SystemStats
Comment: CPU and memory usage from OpenPilot computer.
*************************************************************************************************/
#define SYSTEMSTATS_OBJID 0x74e632d4
typedef struct {
uint32_t FlightTime;
uint32_t HeapRemaining;
uint32_t EventSystemWarningID;
uint32_t ObjectManagerCallbackID;
uint32_t ObjectManagerQueueID;
uint16_t IRQStackRemaining;
uint8_t CPULoad;
int8_t CPUTemp;
} UAVT_SystemStatsData;
extern UAVT_SystemStatsData uavtalk_SystemStatsData;
/*************************************************************************************************
Filename: tabletinfo.xml
Object: TabletInfo
Comment: The information from the tablet to the UAVO.
*************************************************************************************************/
#define TABLETINFO_OBJID 0xb80cc3b2
enum {
TABLETINFO_CONNECTED_FALSE = 0,
TABLETINFO_CONNECTED_TRUE = 1,
TABLETINFO_CONNECTED_LASTITEM = 2
};
enum {
TABLETINFO_TABLETMODEDESIRED_POSITIONHOLD = 0,
TABLETINFO_TABLETMODEDESIRED_RETURNTOHOME = 1,
TABLETINFO_TABLETMODEDESIRED_RETURNTOTABLET = 2,
TABLETINFO_TABLETMODEDESIRED_PATHPLANNER = 3,
TABLETINFO_TABLETMODEDESIRED_FOLLOWME = 4,
TABLETINFO_TABLETMODEDESIRED_LAND = 5,
TABLETINFO_TABLETMODEDESIRED_CAMERAPOI = 6,
TABLETINFO_TABLETMODEDESIRED_LASTITEM = 7
};
enum {
TABLETINFO_POI_FALSE = 0,
TABLETINFO_POI_TRUE = 1,
TABLETINFO_POI_LASTITEM = 2
};
extern char UAVT_TabletInfoConnectedOption[][42];
extern char UAVT_TabletInfoTabletModeDesiredOption[][42];
extern char UAVT_TabletInfoPOIOption[][42];
typedef struct {
int32_t Latitude;
int32_t Longitude;
float Altitude;
uint8_t Connected; // enum
uint8_t TabletModeDesired; // enum
uint8_t POI; // enum
} UAVT_TabletInfoData;
extern UAVT_TabletInfoData uavtalk_TabletInfoData;
/*************************************************************************************************
Filename: taskinfo.xml
Object: TaskInfo
Comment: Task information
*************************************************************************************************/
#define TASKINFO_OBJID 0xc6f6d160
enum {
TASKINFO_RUNNING_FALSE = 0,
TASKINFO_RUNNING_TRUE = 1,
TASKINFO_RUNNING_LASTITEM = 2
};
extern char UAVT_TaskInfoRunningOption[][42];
typedef struct {
uint16_t System;
uint16_t Actuator;
uint16_t Attitude;
uint16_t Sensors;
uint16_t TelemetryTx;
uint16_t TelemetryTxPri;
uint16_t TelemetryRx;
uint16_t GPS;
uint16_t ManualControl;
uint16_t Altitude;
uint16_t Airspeed;
uint16_t Stabilization;
uint16_t AltitudeHold;
uint16_t PathPlanner;
uint16_t PathFollower;
uint16_t FlightPlan;
uint16_t Com2UsbBridge;
uint16_t Usb2ComBridge;
uint16_t OveroSync;
uint16_t ModemRx;
uint16_t ModemTx;
uint16_t ModemStat;
uint16_t Autotune;
uint16_t EventDispatcher;
uint16_t GenericI2CSensor;
uint16_t UAVOMavlinkBridge;
uint16_t UAVOLighttelemetryBridge;
uint16_t UAVORelay;
uint16_t VibrationAnalysis;
uint16_t Battery;
uint16_t UAVOHoTTBridge;
uint16_t UAVOFrSKYSensorHubBridge;
uint16_t PicoC;
uint16_t Logging;
uint16_t UAVOFrSkySPortBridge;
} UAVT_TaskInfoStackRemainingType;
typedef struct {
uint8_t System;
uint8_t Actuator;
uint8_t Attitude;
uint8_t Sensors;
uint8_t TelemetryTx;
uint8_t TelemetryTxPri;
uint8_t TelemetryRx;
uint8_t GPS;
uint8_t ManualControl;
uint8_t Altitude;
uint8_t Airspeed;
uint8_t Stabilization;
uint8_t AltitudeHold;
uint8_t PathPlanner;
uint8_t PathFollower;
uint8_t FlightPlan;
uint8_t Com2UsbBridge;
uint8_t Usb2ComBridge;
uint8_t OveroSync;
uint8_t ModemRx;
uint8_t ModemTx;
uint8_t ModemStat;
uint8_t Autotune;
uint8_t EventDispatcher;
uint8_t GenericI2CSensor;
uint8_t UAVOMavlinkBridge;
uint8_t UAVOLighttelemetryBridge;
uint8_t UAVORelay;
uint8_t VibrationAnalysis;
uint8_t Battery;
uint8_t UAVOHoTTBridge;
uint8_t UAVOFrSKYSBridge;
uint8_t PicoC;
uint8_t Logging;
uint8_t UAVOFrSkySPortBridge;
} UAVT_TaskInfoRunningType;
typedef struct {
uint8_t System;
uint8_t Actuator;
uint8_t Attitude;
uint8_t Sensors;
uint8_t TelemetryTx;
uint8_t TelemetryTxPri;
uint8_t TelemetryRx;
uint8_t GPS;
uint8_t ManualControl;
uint8_t Altitude;
uint8_t Airspeed;
uint8_t Stabilization;
uint8_t AltitudeHold;
uint8_t PathPlanner;
uint8_t PathFollower;
uint8_t FlightPlan;
uint8_t Com2UsbBridge;
uint8_t Usb2ComBridge;
uint8_t OveroSync;
uint8_t ModemRx;
uint8_t ModemTx;
uint8_t ModemStat;
uint8_t Autotune;
uint8_t EventDispatcher;
uint8_t GenericI2CSensor;
uint8_t UAVOMavlinkBridge;
uint8_t UAVOLighttelemetryBridge;
uint8_t UAVORelay;
uint8_t VibrationAnalysis;
uint8_t Battery;
uint8_t UAVOHoTTBridge;
uint8_t UAVOFrSKYSensorHubBridge;
uint8_t PicoC;
uint8_t Logging;
uint8_t UAVOFrSkySPortBridge;
} UAVT_TaskInfoRunningTimeType;
typedef struct {
UAVT_TaskInfoStackRemainingType StackRemaining; // uint16[35]
UAVT_TaskInfoRunningType Running; // enum[35]
UAVT_TaskInfoRunningTimeType RunningTime; // uint8[35]
} UAVT_TaskInfoData;
extern UAVT_TaskInfoData uavtalk_TaskInfoData;
/*************************************************************************************************
Filename: trimanglessettings.xml
Object: TrimAnglesSettings
Comment: The trim angle required for the UAV to fly straight and level.
*************************************************************************************************/
#define TRIMANGLESSETTINGS_OBJID 0x4e09a748
typedef struct {
float Roll;
float Pitch;
} UAVT_TrimAnglesSettingsData;
extern UAVT_TrimAnglesSettingsData uavtalk_TrimAnglesSettingsData;
/*************************************************************************************************
Filename: trimangles.xml
Object: TrimAngles
Comment: The trim angle required for the UAV to fly straight and level.
*************************************************************************************************/
#define TRIMANGLES_OBJID 0x90b8c0de
typedef struct {
float Roll;
float Pitch;
} UAVT_TrimAnglesData;
extern UAVT_TrimAnglesData uavtalk_TrimAnglesData;
/*************************************************************************************************
Filename: txpidsettings.xml
Object: TxPIDSettings
Comment: Settings used by @ref TxPID optional module to tune PID settings using R/C transmitter
*************************************************************************************************/
#define TXPIDSETTINGS_OBJID 0xf25577cc
enum {
TXPIDSETTINGS_UPDATEMODE_NEVER = 0,
TXPIDSETTINGS_UPDATEMODE_WHEN_ARMED = 1,
TXPIDSETTINGS_UPDATEMODE_ALWAYS = 2,
TXPIDSETTINGS_UPDATEMODE_LASTITEM = 3
};
enum {
TXPIDSETTINGS_INPUTS_THROTTLE = 0,
TXPIDSETTINGS_INPUTS_ACCESSORY0 = 1,
TXPIDSETTINGS_INPUTS_ACCESSORY1 = 2,
TXPIDSETTINGS_INPUTS_ACCESSORY2 = 3,
TXPIDSETTINGS_INPUTS_ACCESSORY3 = 4,
TXPIDSETTINGS_INPUTS_ACCESSORY4 = 5,
TXPIDSETTINGS_INPUTS_ACCESSORY5 = 6,
TXPIDSETTINGS_INPUTS_LASTITEM = 7
};
enum {
TXPIDSETTINGS_PIDS_DISABLED = 0,
TXPIDSETTINGS_PIDS_ROLL_RATE_KP = 1,
TXPIDSETTINGS_PIDS_PITCH_RATE_KP = 2,
TXPIDSETTINGS_PIDS_ROLL_PITCH_RATE_KP = 3,
TXPIDSETTINGS_PIDS_YAW_RATE_KP = 4,
TXPIDSETTINGS_PIDS_ROLL_RATE_KI = 5,
TXPIDSETTINGS_PIDS_PITCH_RATE_KI = 6,
TXPIDSETTINGS_PIDS_ROLL_PITCH_RATE_KI = 7,
TXPIDSETTINGS_PIDS_YAW_RATE_KI = 8,
TXPIDSETTINGS_PIDS_ROLL_RATE_KD = 9,
TXPIDSETTINGS_PIDS_PITCH_RATE_KD = 10,
TXPIDSETTINGS_PIDS_ROLL_PITCH_RATE_KD = 11,
TXPIDSETTINGS_PIDS_YAW_RATE_KD = 12,
TXPIDSETTINGS_PIDS_ROLL_RATE_ILIMIT = 13,
TXPIDSETTINGS_PIDS_PITCH_RATE_ILIMIT = 14,
TXPIDSETTINGS_PIDS_ROLL_PITCH_RATE_ILIMIT = 15,
TXPIDSETTINGS_PIDS_YAW_RATE_ILIMIT = 16,
TXPIDSETTINGS_PIDS_ROLL_ATTITUDE_KP = 17,
TXPIDSETTINGS_PIDS_PITCH_ATTITUDE_KP = 18,
TXPIDSETTINGS_PIDS_ROLL_PITCH_ATTITUDE_KP = 19,
TXPIDSETTINGS_PIDS_YAW_ATTITUDE_KP = 20,
TXPIDSETTINGS_PIDS_ROLL_ATTITUDE_KI = 21,
TXPIDSETTINGS_PIDS_PITCH_ATTITUDE_KI = 22,
TXPIDSETTINGS_PIDS_ROLL_PITCH_ATTITUDE_KI = 23,
TXPIDSETTINGS_PIDS_YAW_ATTITUDE_KI = 24,
TXPIDSETTINGS_PIDS_ROLL_ATTITUDE_ILIMIT = 25,
TXPIDSETTINGS_PIDS_PITCH_ATTITUDE_ILIMIT = 26,
TXPIDSETTINGS_PIDS_ROLL_PITCH_ATTITUDE_ILIMIT = 27,
TXPIDSETTINGS_PIDS_YAW_ATTITUDE_ILIMIT = 28,
TXPIDSETTINGS_PIDS_GYROTAU = 29,
TXPIDSETTINGS_PIDS_ROLL_VBARSENSITIVITY = 30,
TXPIDSETTINGS_PIDS_PITCH_VBARSENSITIVITY = 31,
TXPIDSETTINGS_PIDS_ROLL_PITCH_VBARSENSITIVITY = 32,
TXPIDSETTINGS_PIDS_YAW_VBARSENSITIVITY = 33,
TXPIDSETTINGS_PIDS_ROLL_VBAR_KP = 34,
TXPIDSETTINGS_PIDS_PITCH_VBAR_KP = 35,
TXPIDSETTINGS_PIDS_ROLL_PITCH_VBAR_KP = 36,
TXPIDSETTINGS_PIDS_YAW_VBAR_KP = 37,
TXPIDSETTINGS_PIDS_ROLL_VBAR_KI = 38,
TXPIDSETTINGS_PIDS_PITCH_VBAR_KI = 39,
TXPIDSETTINGS_PIDS_ROLL_PITCH_VBAR_KI = 40,
TXPIDSETTINGS_PIDS_YAW_VBAR_KI = 41,
TXPIDSETTINGS_PIDS_ROLL_VBAR_KD = 42,
TXPIDSETTINGS_PIDS_PITCH_VBAR_KD = 43,
TXPIDSETTINGS_PIDS_ROLL_PITCH_VBAR_KD = 44,
TXPIDSETTINGS_PIDS_YAW_VBAR_KD = 45,
TXPIDSETTINGS_PIDS_LASTITEM = 46
};
extern char UAVT_TxPIDSettingsUpdateModeOption[][42];
extern char UAVT_TxPIDSettingsInputsOption[][42];
extern char UAVT_TxPIDSettingsPIDsOption[][42];
typedef struct {
float Instance1;
float Instance2;
float Instance3;
} UAVT_TxPIDSettingsMinPIDType;
typedef struct {
float Instance1;
float Instance2;
float Instance3;
} UAVT_TxPIDSettingsMaxPIDType;
typedef struct {
uint8_t Instance1;
uint8_t Instance2;
uint8_t Instance3;
} UAVT_TxPIDSettingsInputsType;
typedef struct {
uint8_t Instance1;
uint8_t Instance2;
uint8_t Instance3;
} UAVT_TxPIDSettingsPIDsType;
typedef struct {
float ThrottleRange[2];
UAVT_TxPIDSettingsMinPIDType MinPID; // float[3]
UAVT_TxPIDSettingsMaxPIDType MaxPID; // float[3]
uint8_t UpdateMode; // enum
UAVT_TxPIDSettingsInputsType Inputs; // enum[3]
UAVT_TxPIDSettingsPIDsType PIDs; // enum[3]
} UAVT_TxPIDSettingsData;
extern UAVT_TxPIDSettingsData uavtalk_TxPIDSettingsData;
/*************************************************************************************************
Filename: ubloxinfo.xml
Object: UBloxInfo
Comment: UBlox specific information
*************************************************************************************************/
#define UBLOXINFO_OBJID 0xc5302b12
typedef struct {
float swVersion;
uint32_t ParseErrors;
uint8_t hwVersion[8];
} UAVT_UBloxInfoData;
extern UAVT_UBloxInfoData uavtalk_UBloxInfoData;
/*************************************************************************************************
Filename: velocityactual.xml
Object: VelocityActual
Comment: Updated by @ref AHRSCommsModule and used within @ref GuidanceModule for velocity control
*************************************************************************************************/
#define VELOCITYACTUAL_OBJID 0x5a08f61a
typedef struct {
float North;
float East;
float Down;
} UAVT_VelocityActualData;
extern UAVT_VelocityActualData uavtalk_VelocityActualData;
/*************************************************************************************************
Filename: velocitydesired.xml
Object: VelocityDesired
Comment: Used within @ref GuidanceModule to communicate between the task computing the desired velocity and the PID loop to achieve it (running at different rates).
*************************************************************************************************/
#define VELOCITYDESIRED_OBJID 0x9e946992
typedef struct {
float North;
float East;
float Down;
} UAVT_VelocityDesiredData;
extern UAVT_VelocityDesiredData uavtalk_VelocityDesiredData;
/*************************************************************************************************
Filename: vibrationanalysisoutput.xml
Object: VibrationAnalysisOutput
Comment: FFT output from @VibrationTest module.
*************************************************************************************************/
#define VIBRATIONANALYSISOUTPUT_OBJID 0xd02b0a44
typedef struct {
float x;
float y;
float z;
} UAVT_VibrationAnalysisOutputData;
extern UAVT_VibrationAnalysisOutputData uavtalk_VibrationAnalysisOutputData;
/*************************************************************************************************
Filename: vibrationanalysissettings.xml
Object: VibrationAnalysisSettings
Comment: Settings for the @ref VibrationTest Module
*************************************************************************************************/
#define VIBRATIONANALYSISSETTINGS_OBJID 0x5c5c96b6
enum {
VIBRATIONANALYSISSETTINGS_FFTWINDOWSIZE_16 = 0,
VIBRATIONANALYSISSETTINGS_FFTWINDOWSIZE_64 = 1,
VIBRATIONANALYSISSETTINGS_FFTWINDOWSIZE_256 = 2,
VIBRATIONANALYSISSETTINGS_FFTWINDOWSIZE_1024 = 3,
VIBRATIONANALYSISSETTINGS_FFTWINDOWSIZE_LASTITEM = 4
};
enum {
VIBRATIONANALYSISSETTINGS_TESTINGSTATUS_OFF = 0,
VIBRATIONANALYSISSETTINGS_TESTINGSTATUS_ON = 1,
VIBRATIONANALYSISSETTINGS_TESTINGSTATUS_LASTITEM = 2
};
extern char UAVT_VibrationAnalysisSettingsFFTWindowSizeOption[][42];
extern char UAVT_VibrationAnalysisSettingsTestingStatusOption[][42];
typedef struct {
uint16_t SampleRate;
uint8_t FFTWindowSize; // enum
uint8_t TestingStatus; // enum
} UAVT_VibrationAnalysisSettingsData;
extern UAVT_VibrationAnalysisSettingsData uavtalk_VibrationAnalysisSettingsData;
/*************************************************************************************************
Filename: vtolpathfollowersettings.xml
Object: VtolPathFollowerSettings
Comment: Settings for the @ref VtolPathFollowerModule
*************************************************************************************************/
#define VTOLPATHFOLLOWERSETTINGS_OBJID 0xc10e2a3e
enum {
VTOLPATHFOLLOWERSETTINGS_THROTTLECONTROL_FALSE = 0,
VTOLPATHFOLLOWERSETTINGS_THROTTLECONTROL_TRUE = 1,
VTOLPATHFOLLOWERSETTINGS_THROTTLECONTROL_LASTITEM = 2
};
enum {
VTOLPATHFOLLOWERSETTINGS_VELOCITYCHANGEPREDICTION_FALSE = 0,
VTOLPATHFOLLOWERSETTINGS_VELOCITYCHANGEPREDICTION_TRUE = 1,
VTOLPATHFOLLOWERSETTINGS_VELOCITYCHANGEPREDICTION_LASTITEM = 2
};
enum {
VTOLPATHFOLLOWERSETTINGS_YAWMODE_RATE = 0,
VTOLPATHFOLLOWERSETTINGS_YAWMODE_AXISLOCK = 1,
VTOLPATHFOLLOWERSETTINGS_YAWMODE_ATTITUDE = 2,
VTOLPATHFOLLOWERSETTINGS_YAWMODE_PATH = 3,
VTOLPATHFOLLOWERSETTINGS_YAWMODE_POI = 4,
VTOLPATHFOLLOWERSETTINGS_YAWMODE_LASTITEM = 5
};
extern char UAVT_VtolPathFollowerSettingsThrottleControlOption[][42];
extern char UAVT_VtolPathFollowerSettingsVelocityChangePredictionOption[][42];
extern char UAVT_VtolPathFollowerSettingsYawModeOption[][42];
typedef struct {
float Kp;
float Ki;
float ILimit;
} UAVT_VtolPathFollowerSettingsHorizontalPosPIType;
typedef struct {
float Kp;
float Ki;
float Kd;
float ILimit;
} UAVT_VtolPathFollowerSettingsHorizontalVelPIDType;
typedef struct {
UAVT_VtolPathFollowerSettingsHorizontalPosPIType HorizontalPosPI; // float[3]
UAVT_VtolPathFollowerSettingsHorizontalVelPIDType HorizontalVelPID; // float[4]
float VelocityFeedforward;
float MaxRollPitch;
int32_t UpdatePeriod;
float LandingRate;
uint16_t HorizontalVelMax;
uint16_t VerticalVelMax;
uint8_t ThrottleControl; // enum
uint8_t VelocityChangePrediction; // enum
uint8_t EndpointRadius;
uint8_t YawMode; // enum
} UAVT_VtolPathFollowerSettingsData;
extern UAVT_VtolPathFollowerSettingsData uavtalk_VtolPathFollowerSettingsData;
/*************************************************************************************************
Filename: vtolpathfollowerstatus.xml
Object: VtolPathFollowerStatus
Comment: Monitoring of the VTOL path follower
*************************************************************************************************/
#define VTOLPATHFOLLOWERSTATUS_OBJID 0x3238594c
typedef struct {
uint8_t FSM_State;
} UAVT_VtolPathFollowerStatusData;
extern UAVT_VtolPathFollowerStatusData uavtalk_VtolPathFollowerStatusData;
/*************************************************************************************************
Filename: watchdogstatus.xml
Object: WatchdogStatus
Comment: For monitoring the flags in the watchdog and especially the bootup flags
*************************************************************************************************/
#define WATCHDOGSTATUS_OBJID 0xa207fa7c
typedef struct {
uint16_t BootupFlags;
uint16_t ActiveFlags;
} UAVT_WatchdogStatusData;
extern UAVT_WatchdogStatusData uavtalk_WatchdogStatusData;
/*************************************************************************************************
Filename: waypointactive.xml
Object: WaypointActive
Comment: Indicates the currently active waypoint
*************************************************************************************************/
#define WAYPOINTACTIVE_OBJID 0x1ea5b19c
typedef struct {
int16_t Index;
} UAVT_WaypointActiveData;
extern UAVT_WaypointActiveData uavtalk_WaypointActiveData;
/*************************************************************************************************
Filename: waypoint.xml
Object: Waypoint
Comment: A waypoint the aircraft can try and hit. Used by the @ref PathPlanner module
*************************************************************************************************/
#define WAYPOINT_OBJID 0xa6c50a74
enum {
WAYPOINT_MODE_FLYENDPOINT = 0,
WAYPOINT_MODE_FLYVECTOR = 1,
WAYPOINT_MODE_FLYCIRCLERIGHT = 2,
WAYPOINT_MODE_FLYCIRCLELEFT = 3,
WAYPOINT_MODE_DRIVEENDPOINT = 4,
WAYPOINT_MODE_DRIVEVECTOR = 5,
WAYPOINT_MODE_DRIVECIRCLELEFT = 6,
WAYPOINT_MODE_DRIVECIRCLERIGHT = 7,
WAYPOINT_MODE_HOLDPOSITION = 8,
WAYPOINT_MODE_CIRCLEPOSITIONLEFT = 9,
WAYPOINT_MODE_CIRCLEPOSITIONRIGHT = 10,
WAYPOINT_MODE_LAND = 11,
WAYPOINT_MODE_STOP = 12,
WAYPOINT_MODE_INVALID = 13,
WAYPOINT_MODE_LASTITEM = 14
};
extern char UAVT_WaypointModeOption[][42];
typedef struct {
float North;
float East;
float Down;
} UAVT_WaypointPositionType;
typedef struct {
UAVT_WaypointPositionType Position; // float[3]
float Velocity;
float ModeParameters;
uint8_t Mode; // enum
} UAVT_WaypointData;
extern UAVT_WaypointData uavtalk_WaypointData;
/*************************************************************************************************
Filename: windvelocityactual.xml
Object: WindVelocityActual
Comment: Stores 3D wind speed estimation.
*************************************************************************************************/
#define WINDVELOCITYACTUAL_OBJID 0x6d31d2f8
typedef struct {
float North;
float East;
float Down;
} UAVT_WindVelocityActualData;
extern UAVT_WindVelocityActualData uavtalk_WindVelocityActualData;
| 29.870116 | 222 | 0.712051 |
83833e16d94b30286404b66736191652571b5709 | 557 | h | C | Frameworks/ContactsFoundation.framework/Headers/_CNKeyValueObserverHandler.h | CarlAmbroselli/barcelona | 9bd087575935485a4c26674c2414d7ef20d7e168 | [
"Apache-2.0"
] | 13 | 2021-08-12T22:57:13.000Z | 2022-03-09T16:45:52.000Z | Frameworks/ContactsFoundation.framework/Headers/_CNKeyValueObserverHandler.h | CarlAmbroselli/barcelona | 9bd087575935485a4c26674c2414d7ef20d7e168 | [
"Apache-2.0"
] | 20 | 2021-09-03T13:38:34.000Z | 2022-03-17T13:24:39.000Z | Frameworks/ContactsFoundation.framework/Headers/_CNKeyValueObserverHandler.h | CarlAmbroselli/barcelona | 9bd087575935485a4c26674c2414d7ef20d7e168 | [
"Apache-2.0"
] | 2 | 2022-02-13T08:35:11.000Z | 2022-03-17T01:56:47.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import <Foundation/Foundation.h>
@class NSString;
@interface _CNKeyValueObserverHandler : NSObject
{
id _object;
NSString *_keyPath;
id _observer;
}
- (void)observeValueForKeyPath:(id)arg1 ofObject:(id)arg2 change:(id)arg3 context:(void *)arg4;
- (void)stopObserving;
- (void)startObservingWithOptions:(unsigned long long)arg1;
- (id)initWithObject:(id)arg1 keyPath:(id)arg2 observer:(id)arg3;
@end
| 21.423077 | 95 | 0.709156 |
83860e94ce9d72381bed5fe4eb8ed2aa2b94a992 | 3,014 | c | C | drivers/watchdog/tqmx86_wdt.c | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 44 | 2022-03-16T08:32:31.000Z | 2022-03-31T16:02:35.000Z | drivers/watchdog/tqmx86_wdt.c | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 1 | 2022-03-29T02:30:28.000Z | 2022-03-30T03:40:46.000Z | drivers/watchdog/tqmx86_wdt.c | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 18 | 2022-03-19T04:41:04.000Z | 2022-03-31T03:32:12.000Z | // SPDX-License-Identifier: GPL-2.0+
/*
* Watchdog driver for TQMx86 PLD.
*
* The watchdog supports power of 2 timeouts from 1 to 4096sec.
* Once started, it cannot be stopped.
*
* Based on the vendor code written by Vadim V.Vlasov
* <vvlasov@dev.rtsoft.ru>
*/
#include <linux/io.h>
#include <linux/log2.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/timer.h>
#include <linux/watchdog.h>
/* default timeout (secs) */
#define WDT_TIMEOUT 32
static unsigned int timeout;
module_param(timeout, uint, 0);
MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. (1<=timeout<=4096, default="
__MODULE_STRING(WDT_TIMEOUT) ")");
struct tqmx86_wdt {
struct watchdog_device wdd;
void __iomem *io_base;
};
#define TQMX86_WDCFG 0x00 /* Watchdog Configuration Register */
#define TQMX86_WDCS 0x01 /* Watchdog Config/Status Register */
static int tqmx86_wdt_start(struct watchdog_device *wdd)
{
struct tqmx86_wdt *priv = watchdog_get_drvdata(wdd);
iowrite8(0x81, priv->io_base + TQMX86_WDCS);
return 0;
}
static int tqmx86_wdt_set_timeout(struct watchdog_device *wdd, unsigned int t)
{
struct tqmx86_wdt *priv = watchdog_get_drvdata(wdd);
u8 val;
t = roundup_pow_of_two(t);
val = ilog2(t) | 0x90;
val += 3; /* values 0,1,2 correspond to 0.125,0.25,0.5s timeouts */
iowrite8(val, priv->io_base + TQMX86_WDCFG);
wdd->timeout = t;
return 0;
}
static const struct watchdog_info tqmx86_wdt_info = {
.options = WDIOF_SETTIMEOUT |
WDIOF_KEEPALIVEPING,
.identity = "TQMx86 Watchdog",
};
static const struct watchdog_ops tqmx86_wdt_ops = {
.owner = THIS_MODULE,
.start = tqmx86_wdt_start,
.set_timeout = tqmx86_wdt_set_timeout,
};
static int tqmx86_wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct tqmx86_wdt *priv;
struct resource *res;
int err;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res)
return -ENODEV;
priv->io_base = devm_ioport_map(dev, res->start, resource_size(res));
if (!priv->io_base)
return -ENOMEM;
watchdog_set_drvdata(&priv->wdd, priv);
priv->wdd.parent = dev;
priv->wdd.info = &tqmx86_wdt_info;
priv->wdd.ops = &tqmx86_wdt_ops;
priv->wdd.min_timeout = 1;
priv->wdd.max_timeout = 4096;
priv->wdd.max_hw_heartbeat_ms = 4096*1000;
priv->wdd.timeout = WDT_TIMEOUT;
watchdog_init_timeout(&priv->wdd, timeout, dev);
watchdog_set_nowayout(&priv->wdd, WATCHDOG_NOWAYOUT);
tqmx86_wdt_set_timeout(&priv->wdd, priv->wdd.timeout);
err = devm_watchdog_register_device(dev, &priv->wdd);
if (err)
return err;
dev_info(dev, "TQMx86 watchdog\n");
return 0;
}
static struct platform_driver tqmx86_wdt_driver = {
.driver = {
.name = "tqmx86-wdt",
},
.probe = tqmx86_wdt_probe,
};
module_platform_driver(tqmx86_wdt_driver);
MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
MODULE_DESCRIPTION("TQMx86 Watchdog");
MODULE_ALIAS("platform:tqmx86-wdt");
MODULE_LICENSE("GPL");
| 23.732283 | 78 | 0.7286 |
8386437aa4f3d8ef01fd8de15e042d64914d96a3 | 337 | h | C | ALSUniversalAccount/Classes/Plug/BaiChuan/SecondParty/tnet/Tnet.framework/Versions/A/Headers/easy_request.h | profiles/ALSUniversalAccount | 2f49b1e5d374c2bba13d5ab0ed56bf94ddad7a81 | [
"MIT"
] | 6 | 2018-03-29T09:27:43.000Z | 2021-09-06T09:23:13.000Z | ALSUniversalAccount/Classes/Plug/BaiChuan/SecondParty/tnet/Tnet.framework/Versions/A/Headers/easy_request.h | AltairEven/ALSUniversalAccount | 2f49b1e5d374c2bba13d5ab0ed56bf94ddad7a81 | [
"MIT"
] | null | null | null | ALSUniversalAccount/Classes/Plug/BaiChuan/SecondParty/tnet/Tnet.framework/Versions/A/Headers/easy_request.h | AltairEven/ALSUniversalAccount | 2f49b1e5d374c2bba13d5ab0ed56bf94ddad7a81 | [
"MIT"
] | 3 | 2019-01-07T13:20:04.000Z | 2022-03-11T03:43:43.000Z | #ifndef EASY_REQUEST_H_
#define EASY_REQUEST_H_
#include "easy_define.h"
#include "easy_io_struct.h"
/**
* 一个request对象
*/
EASY_CPP_START
void easy_request_server_done(easy_request_t *r);
void easy_request_client_done(easy_request_t *r);
void easy_request_set_cleanup(easy_request_t *r, easy_list_t *output);
EASY_CPP_END
#endif
| 16.047619 | 70 | 0.804154 |
838646a6f8ac320f66ab6106d8c2188a72e5cf45 | 36,414 | h | C | LED_test/include/pylon/gige/_GigEStreamParams.h | imbdus/LEDPLate | e7613eab41d7e9a495b701138e8ea654c0ed62a5 | [
"MIT"
] | null | null | null | LED_test/include/pylon/gige/_GigEStreamParams.h | imbdus/LEDPLate | e7613eab41d7e9a495b701138e8ea654c0ed62a5 | [
"MIT"
] | null | null | null | LED_test/include/pylon/gige/_GigEStreamParams.h | imbdus/LEDPLate | e7613eab41d7e9a495b701138e8ea654c0ed62a5 | [
"MIT"
] | null | null | null |
//-----------------------------------------------------------------------------
// (c) 2004-2008 by Basler Vision Technologies
// Section: Vision Components
// Project: GenApi
//-----------------------------------------------------------------------------
/*!
\file
\brief Interface to the PylonGigE Stream Grabber parameters
*/
//-----------------------------------------------------------------------------
// This file is generated automatically
// Do not modify!
//-----------------------------------------------------------------------------
#ifndef Basler_GigEStreamParams_PARAMS_H
#define Basler_GigEStreamParams_PARAMS_H
#include <GenApi/IEnumerationT.h>
#include <GenApi/NodeMapRef.h>
#include <GenApi/DLLLoad.h>
// common node types
#include <GenApi/IBoolean.h>
#include <GenApi/ICategory.h>
#include <GenApi/ICommand.h>
#include <GenApi/IEnumeration.h>
#include <GenApi/IEnumEntry.h>
#include <GenApi/IFloat.h>
#include <GenApi/IInteger.h>
#include <GenApi/IString.h>
#include <GenApi/IRegister.h>
#ifdef __GNUC__
# undef GCC_VERSION
# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
# undef GCC_DIAGNOSTIC_AWARE
# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200)
# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE
# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600)
#else
# undef GCC_DIAGNOSTIC_AWARE
# define GCC_DIAGNOSTIC_AWARE 0
#endif
#ifdef __GNUC__
// GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc.
// As a result older gcc will not generate warnings about really used deprecated features.
# if GCC_DIAGNOSTIC_AWARE
# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated))
# else
# define GENAPI_DEPRECATED_FEATURE
# endif
#elif defined(_MSC_VER)
# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated)
#else
# define GENAPI_DEPRECATED_FEATURE
#endif
#if GCC_DIAGNOSTIC_AWARE
# if GCC_DIAGNOSTIC_PUSH_POP_AWARE
# pragma GCC diagnostic push
# endif
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
//! The namespace containing the device's control interface and related enumeration types
namespace Basler_GigEStreamParams
{
//**************************************************************************************************
// Enumerations
//**************************************************************************************************
//! Valid values for Type
enum TypeEnums
{
Type_WindowsFilterDriver, //!<The Pylon GigE Vision Streaming Filter Driver.
Type_WindowsIntelPerformanceDriver, //!<The Pylon GigE Vision Performance Driver for Intel network controllers.
Type_SocketDriver, //!<The socket driver.
Type_NoDriverAvailable //!<Indicates that no suitable driver is installed.
};
//! Valid values for Status
enum StatusEnums
{
Status_NotInitialized, //!<The low level stream grabber is not initialized.
Status_Closed, //!<The low level stream grabber is closed.
Status_Open, //!<The low level stream grabber is open.
Status_Locked //!<The low level stream grabber is locked.
};
//! Valid values for AccessMode
enum AccessModeEnums
{
AccessMode_NotInitialized, //!<
AccessMode_Monitor, //!<
AccessMode_Control, //!<
AccessMode_Exclusive //!<
};
//! Valid values for TransmissionType
enum TransmissionTypeEnums
{
TransmissionType_UseCameraConfig, //!<The configuration is read from the camera.
TransmissionType_Unicast, //!<The stream data is sent to the controlling application.
TransmissionType_Multicast, //!<The stream data is sent to multiple devices.
TransmissionType_LimitedBroadcast, //!<The stream is sent to all devices in the local LAN, not to devices on the Internet (i.e. behind a router).
TransmissionType_SubnetDirectedBroadcast //!<The stream data is sent to all destinations in the subnet.
};
//**************************************************************************************************
// Parameter class
//**************************************************************************************************
//! Interface to the PylonGigE Stream Grabber parameters
class CGigEStreamParams_Params
{
//----------------------------------------------------------------------------------------------------------------
// Implementation
//----------------------------------------------------------------------------------------------------------------
protected:
// If you want to show the following methods in the help file
// add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file
//! \cond HIDE_CLASS_METHODS
//! Constructor
CGigEStreamParams_Params(void);
//! Destructor
~CGigEStreamParams_Params(void);
//! Initializes the references
void _Initialize(GENAPI_NAMESPACE::INodeMap*);
//! Return the vendor of the camera
const char* _GetVendorName(void);
//! Returns the camera model name
const char* _GetModelName(void);
//! \endcond
//----------------------------------------------------------------------------------------------------------------
// References to features
//----------------------------------------------------------------------------------------------------------------
public:
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Selects the driver type to be used.
\b Visibility = Beginner
*/
GENAPI_NAMESPACE::IEnumerationT<TypeEnums > &Type;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief The maximum number of buffers that can be used simultaneously.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &MaxNumBuffer;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief The maximum buffer size in bytes that can be registered.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &MaxBufferSize;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Enables or disables the packet resend mechanism.
An image frame consists of n numbers of packets. Each packet has a header consisting of a 24-bit packet ID.
This packet ID increases with each packet sent, and makes it possible for the receiving end to know if a
particular packet has been lost during the transfer. If 'ResendPacketMechanism' is enabled, and the receiving
end notices a lost packet, it will request the other side (e.g. the camera) to send the lost packet again.
If enabled, the 'ResendPacketMechanism' can cause delays in the timing because the sending end will resend
the lost packet. If disabled, image data packet(s) can get lost which results in an incomplete received frame.
You have to weigh the disadvantages and advantages for your special application to decide whether to enable
or disable this command.<br><br>
Default setting: <i>Enabled</i>
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IBoolean &EnableResend;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Timeout period in milliseconds between two packets within one frame.
An image frame consists of n numbers of packets. The packet timeout counting is (re)started
each time a packet is received. If the timeout expires (e.g. no packet was received
during the last 'PacketTimeout' period), the 'Resend Packet Mechanism' is started.
For information, see the 'EnableResend' feature.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &PacketTimeout;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Enables or disables probing of a working large packet size before grabbing.
Enables or disables probing of a working large packet size before grabbing.
Using large packets reduces the overhead for transferring images but
whether a large packet can be transported depends on the used network hardware
and its configuration.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IBoolean &AutoPacketSize;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Size of the sliding receive window in number of frames.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &ReceiveWindowSize;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Resend threshold as percentage of receive window.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &ResendRequestThreshold;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Additional resend batching as percentage of threshold.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &ResendRequestBatching;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Time in milliseconds to wait until a resend request is issued.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &ResendTimeout;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Timeout in milliseconds for missing resend responses.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &ResendRequestResponseTimeout;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Maximum number of resend requests per packet.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &MaximumNumberResendRequests;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief Maximum time in milliseconds to receive all packets of an individual frame.
An image frame consists of n numbers of packets. The 'FrameRetention' always starts from the
point in time the receiving end notices that a packet has been received for a particular frame.
If the transmission of packets of a frame is not completed within the 'FrameRetention' time,
the corresponding frame is delivered with status 'Failed'.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &FrameRetention;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief If enabled, the user can set a custom priority of the receive thread.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IBoolean &ReceiveThreadPriorityOverride;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief The realtime receive thread priority.
This value sets the absolute thread priority of the receive thread.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &ReceiveThreadPriority;
//@}
//! \name Root - Interface to the GigE specific stream parameters.
//@{
/*!
\brief The socket buffer size in KB.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &SocketBufferSize;
//@}
//! \name Debug - Shows information for debugging purposes.
//@{
/*!
\brief Shows the current stream grabber status.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IEnumerationT<StatusEnums > &Status;
//@}
//! \name Debug - Shows information for debugging purposes.
//@{
/*!
\brief Camera access mode.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IEnumerationT<AccessModeEnums > &AccessMode;
//@}
//! \name Debug - Shows information for debugging purposes.
//@{
/*!
\brief Specifies whether the Pylon GigE Vision Performance Driver for Intel network controllers is currently available.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &TypeIsWindowsIntelPerformanceDriverAvailable;
//@}
//! \name Debug - Shows information for debugging purposes.
//@{
/*!
\brief Specifies whether the Pylon GigE Vision Streaming Filter Driver is currently available.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &TypeIsWindowsFilterDriverAvailable;
//@}
//! \name Debug - Shows information for debugging purposes.
//@{
/*!
\brief Specifies whether the socket driver is currently available.
\b Visibility = Guru
*/
GENAPI_NAMESPACE::IInteger &TypeIsSocketDriverAvailable;
//@}
//! \name Statistic - Statistical data.
//@{
/*!
\brief Counts the number of received frames.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &Statistic_Total_Buffer_Count;
//@}
//! \name Statistic - Statistical data.
//@{
/*!
\brief Counts the number of buffers with at least one failed packet (status != success).
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &Statistic_Failed_Buffer_Count;
//@}
//! \name Statistic - Statistical data.
//@{
/*!
\brief Counts the number of frames lost because there were no buffers queued to the driver.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &Statistic_Buffer_Underrun_Count;
//@}
//! \name Statistic - Statistical data.
//@{
/*!
\brief Counts the number of received packets.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &Statistic_Total_Packet_Count;
//@}
//! \name Statistic - Statistical data.
//@{
/*!
\brief Counts the number of failed packets (status != success).
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &Statistic_Failed_Packet_Count;
//@}
//! \name Statistic - Statistical data.
//@{
/*!
\brief Counts the number of emitted PACKETRESEND commands.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &Statistic_Resend_Request_Count;
//@}
//! \name Statistic - Statistical data.
//@{
/*!
\brief Counts the number of packets requested by PACKETRESEND commands.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &Statistic_Resend_Packet_Count;
//@}
//! \name IPConfig - Configuration of the stream destination.
//@{
/*!
\brief Controls whether the stream data is sent to a single device or to multiple devices.
<ul>
<li>
<b>Default (Unicast)</b><br>
The camera sends stream data to a single controlling application. Other devices cannot
receive the stream data.
</li>
<br>
<li>
<b>Broadcast</b><br>
The camera sends the stream data to all devices on the network. The application which
starts/stops the acquisition is called the controlling application. Other applications
can receive the stream data. These applications are called monitor applications, because
they open the camera in read-only mode. This implies that monitor applications cannot
change the camera configuration and they cannot start/stop the image acquisition.
However, monitor applications can request resend requests for lost stream data packets.
<br><br>
Attention: Broadcasting the stream data packets uses a high amount of network bandwidth
because the stream data packets are forwarded to all devices attached to the
network, even if they are not interested in receiving stream data.
</li>
<br>
<li>
<b>Multicast</b><br>
Multicasting is very similar to broadcasting. The main advantage of multicasting is that
multicasting saves network bandwidth, because the image data stream is only sent to those
devices that are interested in receiving the data. To achieve this, the camera sends image
data streams to members of a multicast group only. A multicast group is defined by an IP
address taken from the multicast address range (224.0.0.0 to 239.255.255.255).
<br><br>
Every device that wants to receive a multicast data stream has to be a member of a multicast
group. A member of a specific multicast group only receives data destinated for this group.
Data for other groups is not received. Usually network adapters and switches are able to filter
the data efficently on hardware level (layer-2 packet filtering).
<br><br>
When multicasting is enabled for pylon, pylon automatically takes care of joining and leaving
the multicast groups defined by the destination IP address. Keep in mind that some addresses
from the multicast address range are reserved for general purposes. The address range from
239.255.0.0 to 239.255.255.255 is assigned by RFC 2365 as a locally administered address space.
Use one of these addresses if you are not sure.
<br><br>
On protocol level multicasting involves a so-called IGMP message (IGMP = Internet Group Management Protocol).
To benefit from multicasting, managed network switches should be used. These managed network
switches support the IGMP protocol. Managed network switches supporting the IGMP protocol
will forward multicast packets only if there is a connected device that has joined the
corresponding multicast group. If the switch does not support the IGMP protocol, multicast
is equivalent to broadcasting.
<br><br>
Recommendation:<br>
<ul>
<li>
Each camera should stream to a different multicast group.
</li>
<li>
Streaming to different multicast groups reduces the CPU load and saves network bandwidth
if the network switches supports the IGMP protocol.
</li>
</ul>
</li>
<br>
<li>
<b>Use camera configuration</b><br>
This setting is only available if the application has opened the device in monitor mode. If
the controlling application has already configured the camera stream channel and has possibly
started the acquisition, the monitor application can read all required configuration data
from the camera. Additional configuration is not required. This setting can only be used if
the controlling application has established the stream channel (by opening a pylon stream
grabber object), and the monitor application is started afterwards.
<br><br>
Note, when using broadcast and multicast configurations: When there is more than one camera
device reachable by one network interface, make sure that for each camera a different port
number must be assigned. For assigning port numbers, see the 'DestinationPort' feature.
</li>
</ul>
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IEnumerationT<TransmissionTypeEnums > &TransmissionType;
//@}
//! \name IPConfig - Configuration of the stream destination.
//@{
/*!
\brief Specifies the destination IP address.
The camera will sent all stream data to this IP address. For more details see 'TransmissionType' feature.
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IString &DestinationAddr;
//@}
//! \name IPConfig - Configuration of the stream destination.
//@{
/*!
\brief Specifies the destination port number (0 = auto select).
The camera will sent all stream data to this port.
<b>Port configuration:</b>
<ol>
<li>
<b>Unicast</b><br>
The port is determined automatically.
Manually choosing a port number might be useful for certain firewall configurations.
</li>
<br>
<li>
<b>Broadcast & Multicast</b><br>
For each device reachable by a specific network interface, a unique, unused port number
must be assigned. Be aware that the suggested default value might be already in use.
Choose an unused port or 0=autoselect in that case. The controlling application and all
monitor applications must use the same port number. There is no autoselect feature
availbale for monitor applications, i.e., monitor applications must not use the 0 value.
For monitor applications it is convenient to use the 'UseCameraConfig' value for the
'TransmissionType' feature instead. For more details see the 'TransmissionType' feature.
</li>
</ol>
\b Visibility = Expert
*/
GENAPI_NAMESPACE::IInteger &DestinationPort;
//@}
private:
//! \cond HIDE_CLASS_METHODS
//! not implemented copy constructor
CGigEStreamParams_Params(CGigEStreamParams_Params&);
//! not implemented assignment operator
CGigEStreamParams_Params& operator=(CGigEStreamParams_Params&);
//! \endcond
};
//**************************************************************************************************
// Parameter class implementation
//**************************************************************************************************
//! \cond HIDE_CLASS_METHODS
inline CGigEStreamParams_Params::CGigEStreamParams_Params(void)
: Type( *new GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums>() )
, MaxNumBuffer( *new GENAPI_NAMESPACE::CIntegerRef() )
, MaxBufferSize( *new GENAPI_NAMESPACE::CIntegerRef() )
, EnableResend( *new GENAPI_NAMESPACE::CBooleanRef() )
, PacketTimeout( *new GENAPI_NAMESPACE::CIntegerRef() )
, AutoPacketSize( *new GENAPI_NAMESPACE::CBooleanRef() )
, ReceiveWindowSize( *new GENAPI_NAMESPACE::CIntegerRef() )
, ResendRequestThreshold( *new GENAPI_NAMESPACE::CIntegerRef() )
, ResendRequestBatching( *new GENAPI_NAMESPACE::CIntegerRef() )
, ResendTimeout( *new GENAPI_NAMESPACE::CIntegerRef() )
, ResendRequestResponseTimeout( *new GENAPI_NAMESPACE::CIntegerRef() )
, MaximumNumberResendRequests( *new GENAPI_NAMESPACE::CIntegerRef() )
, FrameRetention( *new GENAPI_NAMESPACE::CIntegerRef() )
, ReceiveThreadPriorityOverride( *new GENAPI_NAMESPACE::CBooleanRef() )
, ReceiveThreadPriority( *new GENAPI_NAMESPACE::CIntegerRef() )
, SocketBufferSize( *new GENAPI_NAMESPACE::CIntegerRef() )
, Status( *new GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums>() )
, AccessMode( *new GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums>() )
, TypeIsWindowsIntelPerformanceDriverAvailable( *new GENAPI_NAMESPACE::CIntegerRef() )
, TypeIsWindowsFilterDriverAvailable( *new GENAPI_NAMESPACE::CIntegerRef() )
, TypeIsSocketDriverAvailable( *new GENAPI_NAMESPACE::CIntegerRef() )
, Statistic_Total_Buffer_Count( *new GENAPI_NAMESPACE::CIntegerRef() )
, Statistic_Failed_Buffer_Count( *new GENAPI_NAMESPACE::CIntegerRef() )
, Statistic_Buffer_Underrun_Count( *new GENAPI_NAMESPACE::CIntegerRef() )
, Statistic_Total_Packet_Count( *new GENAPI_NAMESPACE::CIntegerRef() )
, Statistic_Failed_Packet_Count( *new GENAPI_NAMESPACE::CIntegerRef() )
, Statistic_Resend_Request_Count( *new GENAPI_NAMESPACE::CIntegerRef() )
, Statistic_Resend_Packet_Count( *new GENAPI_NAMESPACE::CIntegerRef() )
, TransmissionType( *new GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums>() )
, DestinationAddr( *new GENAPI_NAMESPACE::CStringRef() )
, DestinationPort( *new GENAPI_NAMESPACE::CIntegerRef() )
{
}
inline CGigEStreamParams_Params::~CGigEStreamParams_Params(void)
{
delete static_cast < GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums> *> (&Type );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&MaxNumBuffer );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&MaxBufferSize );
delete static_cast < GENAPI_NAMESPACE::CBooleanRef*> (&EnableResend );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&PacketTimeout );
delete static_cast < GENAPI_NAMESPACE::CBooleanRef*> (&AutoPacketSize );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&ReceiveWindowSize );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&ResendRequestThreshold );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&ResendRequestBatching );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&ResendTimeout );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&ResendRequestResponseTimeout );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&MaximumNumberResendRequests );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&FrameRetention );
delete static_cast < GENAPI_NAMESPACE::CBooleanRef*> (&ReceiveThreadPriorityOverride );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&ReceiveThreadPriority );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&SocketBufferSize );
delete static_cast < GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums> *> (&Status );
delete static_cast < GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums> *> (&AccessMode );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&TypeIsWindowsIntelPerformanceDriverAvailable );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&TypeIsWindowsFilterDriverAvailable );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&TypeIsSocketDriverAvailable );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Total_Buffer_Count );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Failed_Buffer_Count );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Buffer_Underrun_Count );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Total_Packet_Count );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Failed_Packet_Count );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Resend_Request_Count );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Resend_Packet_Count );
delete static_cast < GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType );
delete static_cast < GENAPI_NAMESPACE::CStringRef*> (&DestinationAddr );
delete static_cast < GENAPI_NAMESPACE::CIntegerRef*> (&DestinationPort );
}
inline void CGigEStreamParams_Params::_Initialize(GENAPI_NAMESPACE::INodeMap* _Ptr)
{
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums> *> (&Type )->SetReference(_Ptr->GetNode("Type"));
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums> *> (&Type )->SetNumEnums(4);
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums> *> (&Type )->SetEnumReference( Type_WindowsFilterDriver, "WindowsFilterDriver" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums> *> (&Type )->SetEnumReference( Type_WindowsIntelPerformanceDriver, "WindowsIntelPerformanceDriver" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums> *> (&Type )->SetEnumReference( Type_SocketDriver, "SocketDriver" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TypeEnums> *> (&Type )->SetEnumReference( Type_NoDriverAvailable, "NoDriverAvailable" ); static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&MaxNumBuffer )->SetReference(_Ptr->GetNode("MaxNumBuffer"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&MaxBufferSize )->SetReference(_Ptr->GetNode("MaxBufferSize"));
static_cast<GENAPI_NAMESPACE::CBooleanRef*> (&EnableResend )->SetReference(_Ptr->GetNode("EnableResend"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&PacketTimeout )->SetReference(_Ptr->GetNode("PacketTimeout"));
static_cast<GENAPI_NAMESPACE::CBooleanRef*> (&AutoPacketSize )->SetReference(_Ptr->GetNode("AutoPacketSize"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&ReceiveWindowSize )->SetReference(_Ptr->GetNode("ReceiveWindowSize"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&ResendRequestThreshold )->SetReference(_Ptr->GetNode("ResendRequestThreshold"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&ResendRequestBatching )->SetReference(_Ptr->GetNode("ResendRequestBatching"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&ResendTimeout )->SetReference(_Ptr->GetNode("ResendTimeout"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&ResendRequestResponseTimeout )->SetReference(_Ptr->GetNode("ResendRequestResponseTimeout"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&MaximumNumberResendRequests )->SetReference(_Ptr->GetNode("MaximumNumberResendRequests"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&FrameRetention )->SetReference(_Ptr->GetNode("FrameRetention"));
static_cast<GENAPI_NAMESPACE::CBooleanRef*> (&ReceiveThreadPriorityOverride )->SetReference(_Ptr->GetNode("ReceiveThreadPriorityOverride"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&ReceiveThreadPriority )->SetReference(_Ptr->GetNode("ReceiveThreadPriority"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&SocketBufferSize )->SetReference(_Ptr->GetNode("SocketBufferSize"));
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums> *> (&Status )->SetReference(_Ptr->GetNode("Status"));
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums> *> (&Status )->SetNumEnums(4);
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums> *> (&Status )->SetEnumReference( Status_NotInitialized, "NotInitialized" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums> *> (&Status )->SetEnumReference( Status_Closed, "Closed" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums> *> (&Status )->SetEnumReference( Status_Open, "Open" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<StatusEnums> *> (&Status )->SetEnumReference( Status_Locked, "Locked" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums> *> (&AccessMode )->SetReference(_Ptr->GetNode("AccessMode"));
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums> *> (&AccessMode )->SetNumEnums(4);
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums> *> (&AccessMode )->SetEnumReference( AccessMode_NotInitialized, "NotInitialized" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums> *> (&AccessMode )->SetEnumReference( AccessMode_Monitor, "Monitor" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums> *> (&AccessMode )->SetEnumReference( AccessMode_Control, "Control" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<AccessModeEnums> *> (&AccessMode )->SetEnumReference( AccessMode_Exclusive, "Exclusive" ); static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&TypeIsWindowsIntelPerformanceDriverAvailable )->SetReference(_Ptr->GetNode("TypeIsWindowsIntelPerformanceDriverAvailable"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&TypeIsWindowsFilterDriverAvailable )->SetReference(_Ptr->GetNode("TypeIsWindowsFilterDriverAvailable"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&TypeIsSocketDriverAvailable )->SetReference(_Ptr->GetNode("TypeIsSocketDriverAvailable"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Total_Buffer_Count )->SetReference(_Ptr->GetNode("Statistic_Total_Buffer_Count"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Failed_Buffer_Count )->SetReference(_Ptr->GetNode("Statistic_Failed_Buffer_Count"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Buffer_Underrun_Count )->SetReference(_Ptr->GetNode("Statistic_Buffer_Underrun_Count"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Total_Packet_Count )->SetReference(_Ptr->GetNode("Statistic_Total_Packet_Count"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Failed_Packet_Count )->SetReference(_Ptr->GetNode("Statistic_Failed_Packet_Count"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Resend_Request_Count )->SetReference(_Ptr->GetNode("Statistic_Resend_Request_Count"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&Statistic_Resend_Packet_Count )->SetReference(_Ptr->GetNode("Statistic_Resend_Packet_Count"));
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType )->SetReference(_Ptr->GetNode("TransmissionType"));
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType )->SetNumEnums(5);
static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType )->SetEnumReference( TransmissionType_UseCameraConfig, "UseCameraConfig" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType )->SetEnumReference( TransmissionType_Unicast, "Unicast" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType )->SetEnumReference( TransmissionType_Multicast, "Multicast" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType )->SetEnumReference( TransmissionType_LimitedBroadcast, "LimitedBroadcast" ); static_cast<GENAPI_NAMESPACE::CEnumerationTRef<TransmissionTypeEnums> *> (&TransmissionType )->SetEnumReference( TransmissionType_SubnetDirectedBroadcast, "SubnetDirectedBroadcast" ); static_cast<GENAPI_NAMESPACE::CStringRef*> (&DestinationAddr )->SetReference(_Ptr->GetNode("DestinationAddr"));
static_cast<GENAPI_NAMESPACE::CIntegerRef*> (&DestinationPort )->SetReference(_Ptr->GetNode("DestinationPort"));
}
inline const char* CGigEStreamParams_Params::_GetVendorName(void)
{
return "Basler";
}
inline const char* CGigEStreamParams_Params::_GetModelName(void)
{
return "GigEStreamParams";
}
//! \endcond
} // namespace Basler_GigEStreamParams
#if GCC_DIAGNOSTIC_AWARE
# if GCC_DIAGNOSTIC_PUSH_POP_AWARE
# pragma GCC diagnostic pop
# else
# pragma GCC diagnostic warning "-Wdeprecated-declarations"
# endif
#endif
#undef GENAPI_DEPRECATED_FEATURE
#endif // Basler_GigEStreamParams_PARAMS_H
| 39.753275 | 980 | 0.646455 |
838721b1244a50108fefdbc1c6ab47cb68ab956d | 3,374 | h | C | JHRequestDebugView/JHRequestDebugView.h | xjh093/JHRequestDebugView | c014fb10851acf8811c7a2a930fbe745e3793486 | [
"MIT"
] | 1 | 2017-10-24T06:44:51.000Z | 2017-10-24T06:44:51.000Z | JHRequestDebugView/JHRequestDebugView.h | xjh093/JHRequestDebugView | c014fb10851acf8811c7a2a930fbe745e3793486 | [
"MIT"
] | 1 | 2019-10-21T08:37:33.000Z | 2019-10-21T11:08:49.000Z | JHRequestDebugView/JHRequestDebugView.h | xjh093/JHRequestDebugView | c014fb10851acf8811c7a2a930fbe745e3793486 | [
"MIT"
] | null | null | null | //
// JHRequestDebugView.h
// JHKit
//
// Created by HaoCold on 2017/10/23.
// Copyright © 2017年 HaoCold. All rights reserved.
// 请求调试窗口
// MIT License
//
// Copyright (c) 2017 xjh093
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#import <UIKit/UIKit.h>
UIKIT_EXTERN NSString *const kJHRequestDebugViewNotification;
@interface JHRequestDebugView : UIView
+ (instancetype)defaultDebugView;
#pragma mark - v1.2.0
/// for GET
- (void)jh_set_GET_task:(NSURLSessionDataTask *)task parameter:(NSDictionary *)dic;
/// for POST
- (void)jh_set_POST_task:(NSURLSessionDataTask *)task parameter:(NSDictionary *)dic;
#pragma mark - v1.1.0
/// store request data for debug
- (void)jh_store_history:(NSString *)url parameter:(NSDictionary *)dic response:(NSDictionary *)response;
#pragma mark - v1.0.0
/*
You should set token or cookie in HTTPHeaderField if needed for two methods below.
*/
/// for GET
- (void)jh_set_GET_URL:(NSString *)url parameter:(NSDictionary *)dic;
/// for POST
- (void)jh_set_POST_URL:(NSString *)url parameter:(NSDictionary *)dic;
@end
/**< Example:
---------------------- version 1.2.0 ---------------------------
GET request :
NSURLSessionDataTask *task = [manager GET:url parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// other code
#if DEBUG
// save for debug.
[[JHRequestDebugView defaultDebugView] jh_store_history:url parameter:dic response:responseObject];
#endif
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// other code
}];
[[JHRequestDebugView defaultDebugView] jh_set_GET_task:task parameter:dic];
---------------------- version 1.0.0 ---------------------------
You should set token or cookie in HTTPHeaderField if needed (in version 1.0.0).
GET request :
[manager GET:url parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// other code
#if DEBUG
// save for debug.
[[JHRequestDebugView defaultDebugView] jh_store_history:URL parameter:dic response:responseObject];
#endif
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// other code
}];
[[JHRequestDebugView defaultDebugView] jh_set_GET_URL:url parameter:dic];
*/
| 32.757282 | 154 | 0.715175 |
8387999bc7555e6e053e0d540badb08de39d3bf7 | 5,770 | c | C | src/ndmp/ndma_noti_calls.c | Acidburn0zzz/bareos | 34a60296af2e2e948c8cd983876eebf5d4d31fc9 | [
"MIT"
] | 1 | 2018-04-28T14:03:39.000Z | 2018-04-28T14:03:39.000Z | src/ndmp/ndma_noti_calls.c | Acidburn0zzz/bareos | 34a60296af2e2e948c8cd983876eebf5d4d31fc9 | [
"MIT"
] | null | null | null | src/ndmp/ndma_noti_calls.c | Acidburn0zzz/bareos | 34a60296af2e2e948c8cd983876eebf5d4d31fc9 | [
"MIT"
] | null | null | null | /*
* Copyright (c) 1998,1999,2000
* Traakan, Inc., Los Altos, CA
* 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 unmodified, 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
*/
/*
* Project: NDMJOB
* Ident: $Id: $
*
* Description:
*
*/
#include "ndmagents.h"
#ifndef NDMOS_OPTION_NO_DATA_AGENT
/*
* DATA Agent originated calls
****************************************************************
*/
int
ndma_notify_data_halted (struct ndm_session *sess)
{
struct ndmconn * conn = sess->plumb.control;
struct ndm_data_agent * da = sess->data_acb;
assert (da->data_state.state == NDMP9_DATA_STATE_HALTED);
assert (da->data_state.halt_reason != NDMP9_DATA_HALT_NA);
NDMC_WITH_NO_REPLY(ndmp9_notify_data_halted, NDMP9VER)
request->reason = da->data_state.halt_reason;
ndma_send_to_control (sess, xa, sess->plumb.data);
NDMC_ENDWITH
return 0;
}
int
ndma_notify_data_read (struct ndm_session *sess,
uint64_t offset, uint64_t length)
{
struct ndmconn * conn = sess->plumb.control;
NDMC_WITH_NO_REPLY(ndmp9_notify_data_read, NDMP9VER)
request->offset = offset;
request->length = length;
ndma_send_to_control (sess, xa, sess->plumb.data);
NDMC_ENDWITH
return 0;
}
#endif /* !NDMOS_OPTION_NO_DATA_AGENT */
#ifndef NDMOS_OPTION_NO_TAPE_AGENT
int
ndma_notify_mover_halted (struct ndm_session *sess)
{
struct ndmconn * conn = sess->plumb.control;
struct ndm_tape_agent * ta = sess->tape_acb;
assert (ta->mover_state.state == NDMP9_MOVER_STATE_HALTED);
assert (ta->mover_state.halt_reason != NDMP9_MOVER_HALT_NA);
NDMC_WITH_NO_REPLY(ndmp9_notify_mover_halted, NDMP9VER)
request->reason = ta->mover_state.halt_reason;
ndma_send_to_control (sess, xa, sess->plumb.tape);
NDMC_ENDWITH
return 0;
}
int
ndma_notify_mover_paused (struct ndm_session *sess)
{
struct ndmconn * conn = sess->plumb.control;
struct ndm_tape_agent * ta = sess->tape_acb;
assert (ta->mover_state.state == NDMP9_MOVER_STATE_PAUSED);
assert (ta->mover_state.pause_reason != NDMP9_MOVER_PAUSE_NA);
NDMC_WITH_NO_REPLY(ndmp9_notify_mover_paused, NDMP9VER)
request->reason = ta->mover_state.pause_reason;
request->seek_position = ta->mover_want_pos;
ndma_send_to_control (sess, xa, sess->plumb.tape);
NDMC_ENDWITH
return 0;
}
#endif /* !NDMOS_OPTION_NO_TAPE_AGENT */
#ifndef NDMOS_EFFECT_NO_SERVER_AGENTS
void
ndma_send_logmsg (struct ndm_session *sess, ndmp9_log_type ltype,
struct ndmconn *from_conn,
char *fmt, ...)
{
struct ndmconn * conn = from_conn;
char buf[4096];
va_list ap;
va_start (ap, fmt);
vsnprintf (buf, sizeof(buf), fmt, ap);
va_end (ap);
if (!from_conn) return;
switch (from_conn->protocol_version) {
#ifndef NDMOS_OPTION_NO_NDMP2
case NDMP2VER:
switch (ltype) {
default:
case NDMP9_LOG_NORMAL:
case NDMP9_LOG_ERROR:
case NDMP9_LOG_WARNING:
NDMC_WITH_NO_REPLY(ndmp2_log_log, NDMP2VER)
request->entry = buf;
ndma_send_to_control (sess, xa, from_conn);
NDMC_ENDWITH
break;
case NDMP9_LOG_DEBUG:
NDMC_WITH_NO_REPLY(ndmp2_log_debug, NDMP2VER)
request->level = NDMP2_DBG_USER_INFO;
request->message = buf;
ndma_send_to_control (sess, xa, from_conn);
NDMC_ENDWITH
break;
}
break;
#endif /* !NDMOS_OPTION_NO_NDMP2 */
#ifndef NDMOS_OPTION_NO_NDMP3
case NDMP3VER:
NDMC_WITH_NO_REPLY(ndmp3_log_message, NDMP3VER)
switch (ltype) {
default:
case NDMP9_LOG_NORMAL:
request->log_type = NDMP3_LOG_NORMAL;
break;
case NDMP9_LOG_DEBUG:
request->log_type = NDMP3_LOG_DEBUG;
break;
case NDMP9_LOG_ERROR:
request->log_type = NDMP3_LOG_ERROR;
break;
case NDMP9_LOG_WARNING:
request->log_type = NDMP3_LOG_WARNING;
break;
}
request->message_id = time(0);
request->entry = buf;
ndma_send_to_control (sess, xa, from_conn);
NDMC_ENDWITH
break;
#endif /* !NDMOS_OPTION_NO_NDMP3 */
#ifndef NDMOS_OPTION_NO_NDMP4
case NDMP4VER:
NDMC_WITH_POST(ndmp4_log_message, NDMP4VER)
switch (ltype) {
default:
case NDMP9_LOG_NORMAL:
request->log_type = NDMP4_LOG_NORMAL;
break;
case NDMP9_LOG_DEBUG:
request->log_type = NDMP4_LOG_DEBUG;
break;
case NDMP9_LOG_ERROR:
request->log_type = NDMP4_LOG_ERROR;
break;
case NDMP9_LOG_WARNING:
request->log_type = NDMP4_LOG_WARNING;
break;
}
request->message_id = time(0);
request->entry = buf;
ndma_send_to_control (sess, xa, from_conn);
NDMC_ENDWITH
break;
#endif /* !NDMOS_OPTION_NO_NDMP4 */
default:
/* BOGUS */
break;
}
}
#endif /* !NDMOS_EFFECT_NO_SERVER_AGENTS */
| 25.418502 | 77 | 0.730676 |
83885de707b70c450015f72d1d42e081e32ea67b | 1,120 | c | C | ft_strncat.c | Maljean/libft | a5e83fd6e869202da44ff6d5f581ae4e11f830ad | [
"MIT"
] | null | null | null | ft_strncat.c | Maljean/libft | a5e83fd6e869202da44ff6d5f581ae4e11f830ad | [
"MIT"
] | null | null | null | ft_strncat.c | Maljean/libft | a5e83fd6e869202da44ff6d5f581ae4e11f830ad | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maljean <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/21 21:27:47 by maljean #+# #+# */
/* Updated: 2018/02/21 21:32:12 by maljean ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncat(char *dest, const char *src, size_t n)
{
size_t i;
size_t j;
i = ft_strlen(dest);
j = 0;
while (src[j] && (j < n))
{
dest[i++] = src[j];
j++;
}
dest[i] = '\0';
return (dest);
}
| 37.333333 | 80 | 0.190179 |
838ad721a04c8c39a528a226af47aac7b93b2ffd | 1,168 | h | C | include/utils.h | dehuacheng/SpAls | 9ce06e2302be01efe1eb29ea7dcfe32b709eecdf | [
"MIT"
] | 7 | 2016-11-29T04:33:29.000Z | 2020-08-31T00:08:04.000Z | include/utils.h | dehuacheng/SpAls | 9ce06e2302be01efe1eb29ea7dcfe32b709eecdf | [
"MIT"
] | null | null | null | include/utils.h | dehuacheng/SpAls | 9ce06e2302be01efe1eb29ea7dcfe32b709eecdf | [
"MIT"
] | 3 | 2016-11-29T20:13:53.000Z | 2019-01-12T15:58:46.000Z | #pragma once
typedef double T;
class Linalg;
class RNGeng;
class SpAlsRNGeng;
class SpAlsUtils;
#include "pRNG.h"
#include "asa007.h"
#include <vector>
#include "CPDecomp.h"
#include "TensorData.h"
using namespace std;
class Linalg
{
public:
static double Fnorm2(const TensorData &data);
static double Fnorm2(CPDecomp &cpd);
static double Fnorm2Diff(const TensorData &data, CPDecomp &cpd);
};
class SpAlsRNGeng
{
public:
SpAlsRNGeng(size_t seed = 0)
{
tmpeng.seed(seed);
}
double nextRNG();
void seed(size_t seed) { tmpeng.seed(seed); }
protected:
sitmo::prng_engine tmpeng;
double rand01();
};
class SpAlsUtils
{
public:
static vector<size_t> getFroms(const int notFrom, const int NDIM);
static void invert(const vector<vector<T>> &A, vector<vector<T>> &goal, const int N_MAX);
static void reset(vector<vector<T>> &A);
static void reset(vector<T> &row);
static void printMatrix(const vector<vector<T>> &A);
static void printVector(const vector<T> &A);
static unsigned drawFromCmf(const vector<T> &cmf, T val);
static void pdf2Cmf(const vector<T> &pdf, vector<T> &cmf);
};
| 22.461538 | 93 | 0.685788 |
838b610486e03051133f07a44e9d0cf4b08dc123 | 5,386 | c | C | open-vm-tools/services/plugins/guestInfo/perfMonLinux.c | tmeralli-tehtris/open-vm-tools-security-research | 9f759add2ddb2c48a0588beb41295568301cad6a | [
"X11"
] | null | null | null | open-vm-tools/services/plugins/guestInfo/perfMonLinux.c | tmeralli-tehtris/open-vm-tools-security-research | 9f759add2ddb2c48a0588beb41295568301cad6a | [
"X11"
] | null | null | null | open-vm-tools/services/plugins/guestInfo/perfMonLinux.c | tmeralli-tehtris/open-vm-tools-security-research | 9f759add2ddb2c48a0588beb41295568301cad6a | [
"X11"
] | null | null | null | /*********************************************************
* Copyright (C) 2008 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation version 2.1 and no 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 Lesser GNU General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*********************************************************/
/*
* This file gathers the virtual memory stats from Linux guest to be
* passed on to the vmx.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
#include "vmware.h"
#include "guestInfo.h"
#include "strutil.h"
#include "debug.h"
#ifndef NO_PROCPS
#include "vm_procps.h"
static void GuestInfoMonitorGetStat(GuestMemInfo *vmStats);
static Bool GuestInfoMonitorReadMeminfo(GuestMemInfo *vmStats);
#endif
#define LINUX_MEMINFO_FLAGS (MEMINFO_MEMTOTAL | MEMINFO_MEMFREE | MEMINFO_MEMBUFF |\
MEMINFO_MEMCACHE | MEMINFO_MEMACTIVE | MEMINFO_MEMINACTIVE |\
MEMINFO_SWAPINRATE | MEMINFO_SWAPOUTRATE |\
MEMINFO_IOINRATE | MEMINFO_IOOUTRATE)
/*
*----------------------------------------------------------------------
*
* GuestInfo_PerfMon --
*
* Gather performance stats.
*
* Results:
* Gathered stats. Returns FALSE on failure.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Bool
GuestInfo_PerfMon(GuestMemInfo *vmStats) // OUT: filled vmstats
{
#ifndef NO_PROCPS
ASSERT(vmStats);
vmStats->flags = 0;
GuestInfoMonitorGetStat(vmStats);
if (GuestInfoMonitorReadMeminfo(vmStats)) {
vmStats->flags |= LINUX_MEMINFO_FLAGS;
return TRUE;
}
#endif
return FALSE;
}
#ifndef NO_PROCPS
/*
*----------------------------------------------------------------------
*
* GuestInfoMonitorGetStat --
*
* Calls getstat() to gather memory stats.
*
* Results:
* Gathered stats in vmStats.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static void
GuestInfoMonitorGetStat(GuestMemInfo *vmStats) // OUT: filled vmstats
{
uint32 hz = Hertz;
uint32 dummy;
jiff cpuUse[2];
jiff cpuNic[2];
jiff cpuSys[2];
jiff cpuIdl[2];
jiff cpuIow[2];
jiff cpuXxx[2];
jiff cpuYyy[2];
jiff cpuZzz[2];
jiff cpuTotal;
jiff cpuHalf;
unsigned long pageIn[2];
unsigned long pageOut[2];
unsigned long swapIn[2];
unsigned long swapOut[2];
unsigned int dummy2[2];
unsigned long kb_per_page = sysconf(_SC_PAGESIZE) / 1024ul;
meminfo();
getstat(cpuUse, cpuNic, cpuSys, cpuIdl, cpuIow, cpuXxx, cpuYyy, cpuZzz,
pageIn, pageOut, swapIn, swapOut, dummy2, dummy2, &dummy, &dummy,
&dummy, &dummy);
cpuTotal = *cpuUse + *cpuNic + *cpuSys + *cpuXxx +
*cpuYyy + *cpuIdl + *cpuIow + *cpuZzz;
cpuHalf = cpuTotal / 2UL;
vmStats->memFree = kb_main_free;
vmStats->memBuff = kb_main_buffers;
vmStats->memCache = kb_main_cached,
vmStats->memInactive = kb_inactive;
vmStats->memActive = kb_active;
vmStats->swapInRate = (uint64)((*swapIn * kb_per_page * hz + cpuHalf) / cpuTotal);
vmStats->swapOutRate = (uint64)((*swapOut * kb_per_page * hz + cpuHalf) / cpuTotal);
vmStats->ioInRate = (uint64)((*pageIn * kb_per_page * hz + cpuHalf) / cpuTotal);
vmStats->ioOutRate = (uint64)((*pageOut * kb_per_page * hz + cpuHalf) / cpuTotal);
}
/*
*----------------------------------------------------------------------
*
* GuestInfoMonitorReadMeminfo --
*
* Reads /proc/meminfo to gather phsycial memory and huge page stats.
*
* Results:
* Read /proc/meminfo for total physical memory and huge pages info.
* Returns FALSE on failure.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static Bool
GuestInfoMonitorReadMeminfo(GuestMemInfo *vmStats) // OUT: filled vmstats
{
char buf[512];
uint64 value;
FILE *fp;
/* Get the total memory, and huge page info from /proc/meminfo. */
fp = fopen("/proc/meminfo", "r");
if (!fp) {
Log("GuestInfoMonitorReadMeminfo: Error opening /proc/meminfo.\n");
return FALSE;
}
while(!feof(fp)) {
if (fscanf(fp, "%s %"FMT64"u", buf, &value) != 2) {
continue;
}
if (StrUtil_StartsWith(buf, "MemTotal")) {
vmStats->memTotal = value;
}
if (StrUtil_StartsWith(buf, "HugePages_Total")) {
vmStats->hugePagesTotal = value;
vmStats->flags |= MEMINFO_HUGEPAGESTOTAL;
}
if (StrUtil_StartsWith(buf, "HugePages_Free")) {
vmStats->hugePagesFree = value;
vmStats->flags |= MEMINFO_HUGEPAGESFREE;
}
}
fclose(fp);
return TRUE;
}
#endif
| 28.198953 | 90 | 0.590234 |
838c56c8022bb25703a43bbca8a2cd559d20d91e | 359 | h | C | EnvironmentMonitoring/Sender/stringConverter.h | Engin-Boot/environment-case-s1b8 | 9395db786955005b1a97f2f496c0e4ec111e4ccc | [
"MIT"
] | null | null | null | EnvironmentMonitoring/Sender/stringConverter.h | Engin-Boot/environment-case-s1b8 | 9395db786955005b1a97f2f496c0e4ec111e4ccc | [
"MIT"
] | null | null | null | EnvironmentMonitoring/Sender/stringConverter.h | Engin-Boot/environment-case-s1b8 | 9395db786955005b1a97f2f496c0e4ec111e4ccc | [
"MIT"
] | null | null | null | #pragma once
#include <iostream>
#include <vector>
#include <string>
#include "iConverter.h"
using namespace std;
class stringConverter : public iConverter
{
public:
virtual string convert(vector<EnvironmentParameter>& v) override {
string result;
for (unsigned i = 0; i < v.size(); i++) {
result += v[i].toString() + ";";
}
return result;
}
}; | 18.894737 | 67 | 0.67688 |
838da6f5cbc81aded73c701caa70f2afd270c073 | 892 | h | C | usr/lib/libcoreroutine.dylib/RTEventHistogram.h | lechium/tvOS124Headers | 11d1b56dd4c0ffd88b9eac43f87a5fd6f7228475 | [
"MIT"
] | 4 | 2019-08-27T18:03:47.000Z | 2021-09-18T06:29:00.000Z | usr/lib/libcoreroutine.dylib/RTEventHistogram.h | lechium/tvOS124Headers | 11d1b56dd4c0ffd88b9eac43f87a5fd6f7228475 | [
"MIT"
] | null | null | null | usr/lib/libcoreroutine.dylib/RTEventHistogram.h | lechium/tvOS124Headers | 11d1b56dd4c0ffd88b9eac43f87a5fd6f7228475 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Saturday, August 24, 2019 at 9:49:25 PM Mountain Standard Time
* Operating System: Version 12.4 (Build 16M568)
* Image Source: /usr/lib/libcoreroutine.dylib
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@protocol RTEventHistogram <NSObject>
@required
-(void)addEvent:(id)arg1;
-(void)addEvents:(id)arg1;
-(void)addEventId:(id)arg1;
-(id)allSortedEventIdsWithComparator:(/*^block*/id)arg1;
-(id)allEventIds;
-(double)weightForEventId:(id)arg1;
-(id)topN:(unsigned long long)arg1 usingComparator:(/*^block*/id)arg2;
-(id)allSortedByWeightEventIds;
-(void)addEventIds:(id)arg1;
-(void)addEvent:(id)arg1 weight:(double)arg2;
-(void)addEventId:(id)arg1 weight:(double)arg2;
-(id)topN:(unsigned long long)arg1;
-(id)top;
-(id)topUsingComparator:(/*^block*/id)arg1;
-(void)reset;
-(void)clear;
@end
| 28.774194 | 81 | 0.73991 |
838e74a4c002fd73b835a5cb7694e8fb9cbf8f25 | 985 | h | C | tools/defs.h | cahirwpz/python-amidev | 6accf463feb0a5763bf0fb66603f4cc354dd99f4 | [
"BSD-3-Clause"
] | 2 | 2019-08-07T06:07:53.000Z | 2019-12-01T20:59:22.000Z | tools/defs.h | cahirwpz/amigaos-dev-toolkit | 6accf463feb0a5763bf0fb66603f4cc354dd99f4 | [
"BSD-3-Clause"
] | null | null | null | tools/defs.h | cahirwpz/amigaos-dev-toolkit | 6accf463feb0a5763bf0fb66603f4cc354dd99f4 | [
"BSD-3-Clause"
] | 1 | 2021-03-03T05:48:25.000Z | 2021-03-03T05:48:25.000Z | /* defs.h -- this file is part of GccFindHit
* Copyright (C) 1995 Daniel Verite -- daniel@brainstorm.eu.org
* This program is distributed under the General GNU Public License version 2
* See the file COPYING for information about the GPL
*/
#ifndef _DEFS_H_
#define _DEFS_H_
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <dos/doshunks.h>
#include "a.out.h"
#define GETWORD(x) ntohs(x)
#define GETLONG(x) ntohl(x)
#define PUTWORD(x) htons(x)
#define PUTLONG(x) htonl(x)
/* Converts an SLINE value to an offset in the text section.
This definition is OK for ld 1.8, currently used on the Amiga AFAIK,
but you may change that for another linker */
#define OFFSET_N_SLINE(x) (x)
/* amigaos hunk header structure */
struct Header {
int32_t nb_hunks;
int32_t first;
int32_t last;
int32_t sizes[1];
};
/* bsd header structure */
struct bsd_header{
int32_t magic;
int32_t symsz;
int32_t strsz;
};
#endif
| 21.888889 | 77 | 0.718782 |
838fc7dec8d082f478e76691a2bf9ebe4f92e0f1 | 1,843 | h | C | CircuitGraphEvaluator.h | dylech30th/CircuitCalculator | fc7f52547f58de68722408ef2cf3518310ac5416 | [
"WTFPL"
] | 1 | 2022-01-25T08:05:01.000Z | 2022-01-25T08:05:01.000Z | CircuitGraphEvaluator.h | dylech30th/CircuitCalculator | fc7f52547f58de68722408ef2cf3518310ac5416 | [
"WTFPL"
] | null | null | null | CircuitGraphEvaluator.h | dylech30th/CircuitCalculator | fc7f52547f58de68722408ef2cf3518310ac5416 | [
"WTFPL"
] | null | null | null | // GPL v3 License
//
// CircuitCalculator/CircuitCalculator
// Copyright (c) 2022 CircuitCalculator/CircuitGraphEvaluator.h
//
// 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 3 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, see <http://www.gnu.org/licenses/>.
#pragma once
#include <memory>
#include <optional>
#include "CircuitScriptGraphNode.h"
#include "Graph.h"
class CircuitGraphEvaluator
{
Graph<std::shared_ptr<CircuitScriptGraphNode>> graph;
Graph<std::string> reducedGraph;
std::string impedance(const std::shared_ptr<CircuitScriptGraphNode>&);
std::string generateSerialEquation(const std::vector<Node<std::string>>& set);
static std::string generateParallelEquation(const std::vector<std::string>& vec);
void translateGraph();
std::unordered_map<std::pair<Node<std::string>, Node<std::string>>, std::vector<std::vector<Node<std::string>>>> allNonTrivialPathsOfReducedGraph();
template <typename T>
static std::optional<std::pair<std::pair<Node<T>, Node<T>>, std::vector<std::vector<Node<T>>>>> anyNonBranchingParallelEdge(Graph<T>& graph, const std::unordered_map<std::pair<Node<T>, Node<T>>, std::vector<std::vector<Node<T>>>>& allPaths);
bool reduce();
public:
explicit CircuitGraphEvaluator(const Graph<std::shared_ptr<CircuitScriptGraphNode>>& graph);
std::string generateEquation();
}; | 36.86 | 242 | 0.751492 |
838ff54d4a8873bbf264cf6792f30971b21391f6 | 1,505 | c | C | FreeBSD/bin/pax/getoldopt.c | TigerBSD/FreeBSD-Custom-ThinkPad | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | 4 | 2016-08-22T22:02:55.000Z | 2017-03-04T22:56:44.000Z | FreeBSD/bin/pax/getoldopt.c | TigerBSD/FreeBSD-Custom-ThinkPad | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | 21 | 2016-08-11T09:43:43.000Z | 2017-01-29T12:52:56.000Z | FreeBSD/bin/pax/getoldopt.c | TigerBSD/TigerBSD | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | null | null | null | /* $OpenBSD: getoldopt.c,v 1.9 2009/10/27 23:59:22 deraadt Exp $ */
/* $NetBSD: getoldopt.c,v 1.3 1995/03/21 09:07:28 cgd Exp $ */
/*-
* Plug-compatible replacement for getopt() for parsing tar-like
* arguments. If the first argument begins with "-", it uses getopt;
* otherwise, it uses the old rules used by tar, dump, and ps.
*
* Written 25 August 1985 by John Gilmore (ihnp4!hoptoad!gnu) and placed
* in the Public Domain for your edification and enjoyment.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int getoldopt(int, char **, const char *);
int
getoldopt(int argc, char **argv, const char *optstring)
{
static char *key; /* Points to next keyletter */
static char use_getopt; /* !=0 if argv[1][0] was '-' */
char c;
char *place;
optarg = NULL;
if (key == NULL) { /* First time */
if (argc < 2)
return (-1);
key = argv[1];
if (*key == '-')
use_getopt++;
else
optind = 2;
}
if (use_getopt)
return (getopt(argc, argv, optstring));
c = *key++;
if (c == '\0') {
key--;
return (-1);
}
place = strchr(optstring, c);
if (place == NULL || c == ':') {
fprintf(stderr, "%s: unknown option %c\n", argv[0], c);
return ('?');
}
place++;
if (*place == ':') {
if (optind < argc) {
optarg = argv[optind];
optind++;
} else {
fprintf(stderr, "%s: %c argument missing\n",
argv[0], c);
return ('?');
}
}
return (c);
}
| 20.616438 | 72 | 0.594684 |
83904c914b5a9f73a41f3ccdfb628ecef5cd22a4 | 4,096 | h | C | mi8/include/media/msm_vidc.h | wqk317/mi8_kernel_source | e3482d1a7ea6021de2fc8f3178496b4b043bb727 | [
"MIT"
] | null | null | null | mi8/include/media/msm_vidc.h | wqk317/mi8_kernel_source | e3482d1a7ea6021de2fc8f3178496b4b043bb727 | [
"MIT"
] | null | null | null | mi8/include/media/msm_vidc.h | wqk317/mi8_kernel_source | e3482d1a7ea6021de2fc8f3178496b4b043bb727 | [
"MIT"
] | 1 | 2020-03-28T11:26:15.000Z | 2020-03-28T11:26:15.000Z | /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef _MSM_VIDC_H_
#define _MSM_VIDC_H_
#include <linux/poll.h>
#include <linux/videodev2.h>
#include <linux/types.h>
#include <linux/msm_ion.h>
#include <uapi/media/msm_vidc.h>
#define HAL_BUFFER_MAX 0xd
enum smem_type {
SMEM_ION,
};
enum smem_prop {
SMEM_CACHED,
SMEM_SECURE,
};
/* NOTE: if you change this enum you MUST update the
* "buffer-type-tz-usage-table" for any affected target
* in arch/arm/boot/dts/<arch>.dtsi
*/
enum hal_buffer {
HAL_BUFFER_NONE = 0x0,
HAL_BUFFER_INPUT = 0x1,
HAL_BUFFER_OUTPUT = 0x2,
HAL_BUFFER_OUTPUT2 = 0x4,
HAL_BUFFER_EXTRADATA_INPUT = 0x8,
HAL_BUFFER_EXTRADATA_OUTPUT = 0x10,
HAL_BUFFER_EXTRADATA_OUTPUT2 = 0x20,
HAL_BUFFER_INTERNAL_SCRATCH = 0x40,
HAL_BUFFER_INTERNAL_SCRATCH_1 = 0x80,
HAL_BUFFER_INTERNAL_SCRATCH_2 = 0x100,
HAL_BUFFER_INTERNAL_PERSIST = 0x200,
HAL_BUFFER_INTERNAL_PERSIST_1 = 0x400,
HAL_BUFFER_INTERNAL_CMD_QUEUE = 0x800,
HAL_BUFFER_INTERNAL_RECON = 0x1000,
};
struct dma_mapping_info {
struct device *dev;
struct dma_iommu_mapping *mapping;
struct sg_table *table;
struct dma_buf_attachment *attach;
struct dma_buf *buf;
};
struct msm_smem {
u32 refcount;
int fd;
void *dma_buf;
void *handle;
void *kvaddr;
u32 device_addr;
unsigned int offset;
unsigned int size;
unsigned long flags;
enum hal_buffer buffer_type;
struct dma_mapping_info mapping_info;
int mem_type;
void *smem_priv;
};
enum smem_cache_ops {
SMEM_CACHE_CLEAN,
SMEM_CACHE_INVALIDATE,
SMEM_CACHE_CLEAN_INVALIDATE,
};
enum core_id {
MSM_VIDC_CORE_VENUS = 0,
MSM_VIDC_CORE_Q6,
MSM_VIDC_CORES_MAX,
};
enum session_type {
MSM_VIDC_ENCODER = 0,
MSM_VIDC_DECODER,
MSM_VIDC_UNKNOWN,
MSM_VIDC_MAX_DEVICES = MSM_VIDC_UNKNOWN,
};
union msm_v4l2_cmd {
struct v4l2_decoder_cmd dec;
struct v4l2_encoder_cmd enc;
};
void *msm_vidc_open(int core_id, int session_type);
int msm_vidc_close(void *instance);
int msm_vidc_suspend(int core_id);
int msm_vidc_querycap(void *instance, struct v4l2_capability *cap);
int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
int msm_vidc_s_fmt(void *instance, struct v4l2_format *f);
int msm_vidc_g_fmt(void *instance, struct v4l2_format *f);
int msm_vidc_release_buffers(void *instance, int buffer_type);
int msm_vidc_prepare_buf(void *instance, struct v4l2_buffer *b);
int msm_vidc_s_ctrl(void *instance, struct v4l2_control *a);
int msm_vidc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
int msm_vidc_g_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
int msm_vidc_g_ctrl(void *instance, struct v4l2_control *a);
int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
int msm_vidc_release_buffer(void *instance, int buffer_type,
unsigned int buffer_index);
int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b);
int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b);
int msm_vidc_streamon(void *instance, enum v4l2_buf_type i);
int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl);
int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i);
int msm_vidc_comm_cmd(void *instance, union msm_v4l2_cmd *cmd);
int msm_vidc_poll(void *instance, struct file *filp,
struct poll_table_struct *pt);
int msm_vidc_subscribe_event(void *instance,
const struct v4l2_event_subscription *sub);
int msm_vidc_unsubscribe_event(void *instance,
const struct v4l2_event_subscription *sub);
int msm_vidc_dqevent(void *instance, struct v4l2_event *event);
int msm_vidc_g_crop(void *instance, struct v4l2_crop *a);
int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize);
#endif
| 30.567164 | 77 | 0.791016 |
8391547102af0e9247dfa38a45209eb4f6b92396 | 10,131 | c | C | src/sys/geom/geom_pc98.c | dnybz/MeshBSD | 5c6c0539ce13d7cda9e2645e2e9e916e371f87b2 | [
"BSD-3-Clause"
] | null | null | null | src/sys/geom/geom_pc98.c | dnybz/MeshBSD | 5c6c0539ce13d7cda9e2645e2e9e916e371f87b2 | [
"BSD-3-Clause"
] | null | null | null | src/sys/geom/geom_pc98.c | dnybz/MeshBSD | 5c6c0539ce13d7cda9e2645e2e9e916e371f87b2 | [
"BSD-3-Clause"
] | null | null | null | /*-
* Copyright (c) 2002 Poul-Henning Kamp
* Copyright (c) 2002 Networks Associates Technology, Inc.
* All rights reserved.
*
* This software was developed for the FreeBSD Project by Poul-Henning Kamp
* and NAI Labs, the Security Research Division of Network Associates, Inc.
* under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
* DARPA CHATS research program.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/11.0/sys/geom/geom_pc98.c 300288 2016-05-20 08:25:37Z kib $");
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/bio.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/diskpc98.h>
#include <geom/geom.h>
#include <geom/geom_slice.h>
FEATURE(geom_pc98, "GEOM NEC PC9800 partitioning support");
#define PC98_CLASS_NAME "PC98"
struct g_pc98_softc {
u_int fwsectors, fwheads, sectorsize;
int type[PC98_NPARTS];
u_char sec[8192];
};
static void
g_pc98_print(int i, struct pc98_partition *dp)
{
char sname[17];
strncpy(sname, dp->dp_name, 16);
sname[16] = '\0';
hexdump(dp, sizeof(dp[0]), NULL, 0);
printf("[%d] mid:%d(0x%x) sid:%d(0x%x)",
i, dp->dp_mid, dp->dp_mid, dp->dp_sid, dp->dp_sid);
printf(" s:%d/%d/%d", dp->dp_scyl, dp->dp_shd, dp->dp_ssect);
printf(" e:%d/%d/%d", dp->dp_ecyl, dp->dp_ehd, dp->dp_esect);
printf(" sname:%s\n", sname);
}
/*
* XXX: Add gctl_req arg and give good error msgs.
* XXX: Check that length argument does not bring boot code inside any slice.
*/
static int
g_pc98_modify(struct g_geom *gp, struct g_pc98_softc *ms, u_char *sec, int len __unused)
{
int i, error;
off_t s[PC98_NPARTS], l[PC98_NPARTS];
struct pc98_partition dp[PC98_NPARTS];
g_topology_assert();
if (sec[0x1fe] != 0x55 || sec[0x1ff] != 0xaa)
return (EBUSY);
#if 0
/*
* By convetion, it seems that the ipl program has a jump at location
* 0 to the real start of the boot loader. By convetion, it appears
* that after this jump, there's a string, terminated by at last one,
* if not more, zeros, followed by the target of the jump. FreeBSD's
* pc98 boot0 uses 'IPL1' followed by 3 zeros here, likely for
* compatibility with some older boot loader. Linux98's boot loader
* appears to use 'Linux 98' followed by only two. GRUB/98 appears to
* use 'GRUB/98 ' followed by none. These last two appear to be
* ported from the ia32 versions, but appear to show similar
* convention. Grub/98 has an additional NOP after the jmp, which
* isn't present in others.
*
* The following test was inspired by looking only at partitions
* with FreeBSD's boot0 (or one that it is compatible with). As
* such, if failed when other IPL programs were used.
*/
if (sec[4] != 'I' || sec[5] != 'P' || sec[6] != 'L' || sec[7] != '1')
return (EBUSY);
#endif
for (i = 0; i < PC98_NPARTS; i++)
pc98_partition_dec(
sec + 512 + i * sizeof(struct pc98_partition), &dp[i]);
for (i = 0; i < PC98_NPARTS; i++) {
/* If start and end are identical it's bogus */
if (dp[i].dp_ssect == dp[i].dp_esect &&
dp[i].dp_shd == dp[i].dp_ehd &&
dp[i].dp_scyl == dp[i].dp_ecyl)
s[i] = l[i] = 0;
else if (dp[i].dp_ecyl == 0)
s[i] = l[i] = 0;
else {
s[i] = (off_t)dp[i].dp_scyl *
ms->fwsectors * ms->fwheads * ms->sectorsize;
l[i] = (off_t)(dp[i].dp_ecyl - dp[i].dp_scyl + 1) *
ms->fwsectors * ms->fwheads * ms->sectorsize;
}
if (bootverbose) {
printf("PC98 Slice %d on %s:\n", i + 1, gp->name);
g_pc98_print(i, dp + i);
}
if (s[i] < 0 || l[i] < 0)
error = EBUSY;
else
error = g_slice_config(gp, i, G_SLICE_CONFIG_CHECK,
s[i], l[i], ms->sectorsize,
"%ss%d", gp->name, i + 1);
if (error)
return (error);
}
for (i = 0; i < PC98_NPARTS; i++) {
ms->type[i] = (dp[i].dp_sid << 8) | dp[i].dp_mid;
g_slice_config(gp, i, G_SLICE_CONFIG_SET, s[i], l[i],
ms->sectorsize, "%ss%d", gp->name, i + 1);
}
bcopy(sec, ms->sec, sizeof (ms->sec));
return (0);
}
static int
g_pc98_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
{
struct g_geom *gp;
struct g_pc98_softc *ms;
struct g_slicer *gsp;
struct g_consumer *cp;
int error, opened;
gp = pp->geom;
gsp = gp->softc;
ms = gsp->softc;
opened = 0;
error = 0;
switch(cmd) {
case DIOCSPC98: {
if (!(fflag & FWRITE))
return (EPERM);
g_topology_lock();
cp = LIST_FIRST(&gp->consumer);
if (cp->acw == 0) {
error = g_access(cp, 0, 1, 0);
if (error == 0)
opened = 1;
}
if (!error)
error = g_pc98_modify(gp, ms, data, 8192);
if (!error)
error = g_write_data(cp, 0, data, 8192);
if (opened)
g_access(cp, 0, -1 , 0);
g_topology_unlock();
return(error);
}
default:
return (ENOIOCTL);
}
}
static int
g_pc98_start(struct bio *bp)
{
struct g_provider *pp;
struct g_geom *gp;
struct g_pc98_softc *mp;
struct g_slicer *gsp;
int idx;
pp = bp->bio_to;
idx = pp->index;
gp = pp->geom;
gsp = gp->softc;
mp = gsp->softc;
if (bp->bio_cmd == BIO_GETATTR) {
if (g_handleattr_int(bp, "PC98::type", mp->type[idx]))
return (1);
if (g_handleattr_off_t(bp, "PC98::offset",
gsp->slices[idx].offset))
return (1);
}
return (0);
}
static void
g_pc98_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
struct g_consumer *cp __unused, struct g_provider *pp)
{
struct g_pc98_softc *mp;
struct g_slicer *gsp;
struct pc98_partition dp;
char sname[17];
gsp = gp->softc;
mp = gsp->softc;
g_slice_dumpconf(sb, indent, gp, cp, pp);
if (pp != NULL) {
pc98_partition_dec(
mp->sec + 512 +
pp->index * sizeof(struct pc98_partition), &dp);
strncpy(sname, dp.dp_name, 16);
sname[16] = '\0';
if (indent == NULL) {
sbuf_printf(sb, " ty %d", mp->type[pp->index]);
sbuf_printf(sb, " sn %s", sname);
} else {
sbuf_printf(sb, "%s<type>%d</type>\n", indent,
mp->type[pp->index]);
sbuf_printf(sb, "%s<sname>%s</sname>\n", indent,
sname);
}
}
}
static struct g_geom *
g_pc98_taste(struct g_class *mp, struct g_provider *pp, int flags)
{
struct g_geom *gp;
struct g_consumer *cp;
int error;
struct g_pc98_softc *ms;
u_int fwsectors, fwheads, sectorsize;
u_char *buf;
g_trace(G_T_TOPOLOGY, "g_pc98_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
if (flags == G_TF_NORMAL &&
!strcmp(pp->geom->class->name, PC98_CLASS_NAME))
return (NULL);
gp = g_slice_new(mp, PC98_NPARTS, pp, &cp, &ms, sizeof *ms,
g_pc98_start);
if (gp == NULL)
return (NULL);
g_topology_unlock();
do {
if (gp->rank != 2 && flags == G_TF_NORMAL)
break;
error = g_getattr("GEOM::fwsectors", cp, &fwsectors);
if (error || fwsectors == 0) {
fwsectors = 17;
if (bootverbose)
printf("g_pc98_taste: guessing %d sectors\n",
fwsectors);
}
error = g_getattr("GEOM::fwheads", cp, &fwheads);
if (error || fwheads == 0) {
fwheads = 8;
if (bootverbose)
printf("g_pc98_taste: guessing %d heads\n",
fwheads);
}
sectorsize = cp->provider->sectorsize;
if (sectorsize % 512 != 0)
break;
buf = g_read_data(cp, 0, 8192, NULL);
if (buf == NULL)
break;
ms->fwsectors = fwsectors;
ms->fwheads = fwheads;
ms->sectorsize = sectorsize;
g_topology_lock();
g_pc98_modify(gp, ms, buf, 8192);
g_topology_unlock();
g_free(buf);
break;
} while (0);
g_topology_lock();
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);
}
return (gp);
}
static void
g_pc98_config(struct gctl_req *req, struct g_class *mp, const char *verb)
{
struct g_geom *gp;
struct g_consumer *cp;
struct g_pc98_softc *ms;
struct g_slicer *gsp;
int opened = 0, error = 0;
void *data;
int len;
g_topology_assert();
gp = gctl_get_geom(req, mp, "geom");
if (gp == NULL)
return;
if (strcmp(verb, "write PC98")) {
gctl_error(req, "Unknown verb");
return;
}
gsp = gp->softc;
ms = gsp->softc;
data = gctl_get_param(req, "data", &len);
if (data == NULL)
return;
if (len < 8192 || (len % 512)) {
gctl_error(req, "Wrong request length");
return;
}
cp = LIST_FIRST(&gp->consumer);
if (cp->acw == 0) {
error = g_access(cp, 0, 1, 0);
if (error == 0)
opened = 1;
}
if (!error)
error = g_pc98_modify(gp, ms, data, len);
if (error)
gctl_error(req, "conflict with open slices");
if (!error)
error = g_write_data(cp, 0, data, len);
if (error)
gctl_error(req, "sector zero write failed");
if (opened)
g_access(cp, 0, -1 , 0);
return;
}
static struct g_class g_pc98_class = {
.name = PC98_CLASS_NAME,
.version = G_VERSION,
.taste = g_pc98_taste,
.dumpconf = g_pc98_dumpconf,
.ctlreq = g_pc98_config,
.ioctl = g_pc98_ioctl,
};
DECLARE_GEOM_CLASS(g_pc98_class, g_pc98);
| 27.160858 | 89 | 0.655809 |
83925f75a10696ef420f636a786cb860e71cf62e | 4,292 | h | C | winp/winp/menu/menu_item_component.h | benbraide/winp | 2a20b82708d239a93cc50f239798d69f7217c47b | [
"MIT"
] | null | null | null | winp/winp/menu/menu_item_component.h | benbraide/winp | 2a20b82708d239a93cc50f239798d69f7217c47b | [
"MIT"
] | null | null | null | winp/winp/menu/menu_item_component.h | benbraide/winp | 2a20b82708d239a93cc50f239798d69f7217c47b | [
"MIT"
] | null | null | null | #pragma once
#include "../ui/ui_surface.h"
#include "../event/event_handler.h"
#include "menu_tree.h"
namespace winp::event{
class draw_item_dispatcher;
}
namespace winp::menu{
class group;
class object;
class wrapper;
template <class base_type>
class generic_collection_base;
class item_component : public ui::surface, public component, public event::tree_handler{
public:
item_component();
explicit item_component(bool);
explicit item_component(thread::object &thread);
item_component(thread::object &thread, bool);
explicit item_component(ui::tree &parent);
item_component(ui::tree &parent, bool);
virtual ~item_component();
virtual std::size_t get_absolute_index(const std::function<void(std::size_t)> &callback = nullptr) const override;
virtual UINT get_local_id(const std::function<void(UINT)> &callback = nullptr) const;
virtual bool set_state(UINT value, const std::function<void(thread::item &, bool)> &callback = nullptr);
virtual bool remove_state(UINT value, const std::function<void(thread::item &, bool)> &callback = nullptr);
virtual UINT get_states(const std::function<void(UINT)> &callback = nullptr) const;
virtual bool has_state(UINT value, const std::function<void(bool)> &callback = nullptr) const;
virtual bool has_states(UINT value, const std::function<void(bool)> &callback = nullptr) const;
virtual bool enable(const std::function<void(thread::item &, bool)> &callback = nullptr);
virtual bool disable(const std::function<void(thread::item &, bool)> &callback = nullptr);
virtual bool is_disabled(const std::function<void(bool)> &callback = nullptr) const;
virtual bool is_owner_drawn(const std::function<void(bool)> &callback = nullptr) const;
virtual bool is_popup_item(const std::function<void(bool)> &callback = nullptr) const;
event::manager<item_component, event::object> create_event{ *this };
event::manager<item_component, event::object> destroy_event{ *this };
event::manager<item_component, event::draw_item> draw_item_event{ *this };
event::manager<item_component, event::measure_item> measure_item_event{ *this };
protected:
friend class event::measure_item;
friend class event::draw_item_dispatcher;
friend class menu::object;
friend class menu::wrapper;
friend class menu::group;
template <class> friend class menu::generic_collection_base;
friend class thread::surface_manager;
virtual void event_handlers_count_changed_(event::manager_base &e, std::size_t previous_count, std::size_t current_count);
virtual void destruct_() override;
virtual bool create_() override;
virtual bool destroy_() override;
virtual bool is_created_() const override;
virtual const wchar_t *get_theme_name_() const override;
virtual std::size_t get_count_() const override;
virtual bool handle_parent_change_event_(event::tree &e) override;
virtual void handle_parent_changed_event_(event::tree &e) override;
virtual void handle_index_changed_event_(event::tree &e) override;
virtual UINT get_local_id_() const;
virtual std::size_t get_absolute_index_() const;
virtual ui::surface *get_popup_() const;
virtual const std::wstring *get_label_() const;
virtual const std::wstring *get_shortcut_() const;
virtual HFONT get_font_() const;
virtual bool set_state_(UINT value);
virtual bool remove_state_(UINT value);
virtual UINT get_states_() const;
virtual UINT get_persistent_states_() const;
virtual UINT get_filtered_states_() const;
virtual bool has_state_(UINT value) const;
virtual bool has_states_(UINT value) const;
virtual UINT get_types_() const;
virtual bool has_type_(UINT value) const;
virtual bool is_owner_drawn_() const;
virtual bool is_popup_item_() const;
virtual HBITMAP get_bitmap_() const;
virtual HBITMAP get_checked_bitmap_() const;
virtual HBITMAP get_unchecked_bitmap_() const;
virtual bool update_(const MENUITEMINFOW &info);
virtual bool update_states_();
virtual bool update_types_();
virtual void register_id_();
virtual void generate_id_(std::size_t max_tries = 0xFFFFu);
virtual bool id_is_unique_() const;
UINT local_id_ = 0u;
bool is_created_state_ = false;
UINT states_ = 0u;
UINT types_ = 0u;
HFONT font_ = nullptr;
};
}
| 27.164557 | 124 | 0.750932 |
8393164c3b84e4d9dde9a0a8bfeb1130b568ee13 | 3,478 | h | C | Code/Framework/AzFramework/Platform/Android/AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Android.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-09-13T00:01:12.000Z | 2021-09-13T00:01:12.000Z | Code/Framework/AzFramework/Platform/Android/AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Android.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | null | null | null | Code/Framework/AzFramework/Platform/Android/AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Android.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-07-20T11:07:25.000Z | 2021-07-20T11:07:25.000Z | /*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
struct AInputEvent;
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace AzFramework
{
////////////////////////////////////////////////////////////////////////////////////////////////
//! EBus interface used to listen for raw android input as broadcast by the system. Applications
//! that want android events to be processed by the AzFramework input system must broadcast all
//! input events received by the native input handle, which is the lowest level we can get input.
//!
//! It's possible to receive multiple events per index (finger) per frame, and it is likely that
//! android input events will not be dispatched from the main thread, so care should be taken to
//! ensure thread safety when implementing event handlers that connect to this android event bus.
//!
//! This EBus is intended primarily for the AzFramework input system to process raw input events.
//! Most systems that need to process input should use the generic AzFramework input interfaces,
//! but if necessary it is perfectly valid to connect directly to this EBus for android events.
class RawInputNotificationsAndroid : public AZ::EBusTraits
{
public:
////////////////////////////////////////////////////////////////////////////////////////////
//! EBus Trait: raw input notifications are addressed to a single address
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
////////////////////////////////////////////////////////////////////////////////////////////
//! EBus Trait: raw input notifications can be handled by multiple listeners
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
////////////////////////////////////////////////////////////////////////////////////////////
//! Default destructor
virtual ~RawInputNotificationsAndroid() = default;
////////////////////////////////////////////////////////////////////////////////////////////
//! Process raw input events (assumed to be dispatched on any thread)
//! \param[in] rawInputEvent The raw input event data
virtual void OnRawInputEvent(const AInputEvent* /*rawInputEvent*/) {}
////////////////////////////////////////////////////////////////////////////////////////////
//! Process raw text events (assumed to be dispatched on any thread)
//! \param[in] charsModifiedUTF8 The raw chars (encoded using modified UTF-8)
virtual void OnRawInputTextEvent(const char* /*charsModifiedUTF8*/) {}
////////////////////////////////////////////////////////////////////////////////////////////
//! Process raw virtual keyboard events (assumed to be dispatched on any thread)
//! \param[in] keyCode The key code of the virtual keyboard event
//! \param[in] keyAction The key action of the virtual keyboard event
virtual void OnRawInputVirtualKeyboardEvent(int /*keyCode*/, int /*keyAction*/) {}
};
using RawInputNotificationBusAndroid = AZ::EBus<RawInputNotificationsAndroid>;
} // namespace AzFramework
| 56.096774 | 158 | 0.552616 |
8393f1b246ad26442620df35c24d3dc57532c825 | 341 | h | C | src/renderer/opengl/texture.h | AlkimiaStudios/alkahest-engine | f8ad44a78362e45361f9fc2b1ab17048537eeb82 | [
"Beerware"
] | null | null | null | src/renderer/opengl/texture.h | AlkimiaStudios/alkahest-engine | f8ad44a78362e45361f9fc2b1ab17048537eeb82 | [
"Beerware"
] | null | null | null | src/renderer/opengl/texture.h | AlkimiaStudios/alkahest-engine | f8ad44a78362e45361f9fc2b1ab17048537eeb82 | [
"Beerware"
] | null | null | null | #pragma once
#include "../../macros.h"
#include "../texture.h"
namespace Alkahest
{
class NOT_EXPORTED OpenGLTexture2D : public Texture2D
{
public:
OpenGLTexture2D() {};
virtual ~OpenGLTexture2D() {};
unsigned int load(const char* file) override;
void use(unsigned int slot) override;
};
} | 18.944444 | 57 | 0.621701 |
8394a496b5692d9c338a77848faffc671f8fad60 | 48,758 | h | C | cartodata/src/library/volume/volumebase_d.h | brainvisa/aims-free | 5852c1164292cadefc97cecace022d14ab362dc4 | [
"CECILL-B"
] | 4 | 2019-07-09T05:34:10.000Z | 2020-10-16T00:03:15.000Z | cartodata/src/library/volume/volumebase_d.h | brainvisa/aims-free | 5852c1164292cadefc97cecace022d14ab362dc4 | [
"CECILL-B"
] | 72 | 2018-10-31T14:52:50.000Z | 2022-03-04T11:22:51.000Z | cartodata/src/library/volume/volumebase_d.h | brainvisa/aims-free | 5852c1164292cadefc97cecace022d14ab362dc4 | [
"CECILL-B"
] | null | null | null | /* This software and supporting documentation are distributed by
* Institut Federatif de Recherche 49
* CEA/NeuroSpin, Batiment 145,
* 91191 Gif-sur-Yvette cedex
* France
*
* This software is governed by the CeCILL-B license under
* French law and abiding by the rules of distribution of free software.
* You can use, modify and/or redistribute the software under the
* terms of the CeCILL-B license as circulated by CEA, CNRS
* and INRIA at the following URL "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
#ifndef CARTODATA_VOLUME_VOLUMEBASE_D_H
#define CARTODATA_VOLUME_VOLUMEBASE_D_H
//--- cartodata --------------------------------------------------------------
#include <cartodata/volume/volumebase.h>
#include <cartodata/volume/volumebase_d_operators.h>
#include <cartodata/volume/volumebase_d_inline.h>
#include <cartodata/volume/volumebase_d_instantiate.h>
#include <cartodata/volume/volumeref.h>
#include <cartodata/volume/volumeproxy_d.h>
//--- cartobase --------------------------------------------------------------
#include <cartobase/type/limits.h>
#include <cartobase/type/string_conversion.h>
#include <cartobase/object/object.h>
#include <cartobase/object/property.h>
#include <cartobase/object/propertyfilter.h>
#include <cartobase/containers/nditerator.h>
//--- soma-io ----------------------------------------------------------------
#include <soma-io/allocator/allocator.h>
//--- std --------------------------------------------------------------------
#include <cstdlib>
#include <algorithm>
#include <stdexcept>
#include <string>
#include <stdio.h>
//----------------------------------------------------------------------------
namespace carto
{
//============================================================================
// CONSTRUCTORS
//============================================================================
/***************************************************************************
* Default Constructor
**************************************************************************/
template < typename T >
Volume< T >::Volume( int sizeX, int sizeY, int sizeZ, int sizeT,
const AllocatorContext& allocatorContext,
bool allocated )
: VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
_items( 0U, allocatorContext ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
allocate( -1, -1, -1, -1, allocated, allocatorContext );
}
template < typename T >
Volume< T >::Volume( const Position4Di & size,
const AllocatorContext& allocatorContext,
bool allocated ):
VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
size[1] > 0 ? size[1] : 1,
size[2] > 0 ? size[2] : 1,
size[3] > 0 ? size[3] : 1 ),
_items( 0U, allocatorContext ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
allocate( -1, -1, -1, -1, allocated, allocatorContext );
}
/***************************************************************************
* Constructor with border
**************************************************************************/
template < typename T >
void Volume< T >::constructBorders( const Position & bordersize,
const AllocatorContext& allocatorContext,
bool allocated )
{
if( !bordersize.empty()
&& bordersize != Position4Di().toVector() )
{
size_t i, n = VolumeProxy<T>::_size.size();
size_t bsize = sizeof(T);
std::vector<int> large_size( n );
for( i=0; i<n; ++i )
{
large_size[i] = VolumeProxy<T>::_size[i];
if( i < bordersize.size() )
large_size[i] += bordersize[i] * 2;
bsize *= VolumeProxy<T>::_size[i];
}
_refvol.reset( new Volume<T>( large_size,
allocatorContext, allocated ) );
allocate( -1, -1, -1, -1, true,
_refvol->allocatorContext().isAllocated()
? AllocatorContext( AllocatorStrategy::NotOwner,
rc_ptr<DataSource>( new BufferDataSource
( (char *) &(*_refvol)( bordersize ),
bsize ) ) )
: allocatorContext );
if( _refvol->allocatorContext().isAllocated() )
{
// fix offsets
#ifdef CARTO_USE_BLITZ
blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
int i, n=VolumeProxy<T>::_size.size();
for(i=0; i<n; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
_blitz.reference
( blitz::Array<T,8>
( &_items[0],
dims,
_refvol->_blitz.stride(),
blitz::GeneralArrayStorage<8>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
#else
_lineoffset = &(*_refvol)( 0, 1, 0 ) - &(*_refvol)( 0, 0, 0 );
_sliceoffset = &(*_refvol)( 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
_volumeoffset = &(*_refvol)( 0, 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
#endif
}
}
else // no border
{
allocate( -1, -1, -1, -1, allocated, allocatorContext );
}
}
template < typename T >
Volume< T >::Volume( int sizeX, int sizeY, int sizeZ, int sizeT,
const Position4Di & bordersize,
const AllocatorContext& allocatorContext,
bool allocated )
: VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
_items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
DataSource::none() ) ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( bordersize.toVector() )
{
constructBorders( bordersize.toVector(), allocatorContext, allocated );
}
template < typename T >
Volume< T >::Volume( const Position4Di & size,
const Position4Di & bordersize,
const AllocatorContext& allocatorContext,
bool allocated ):
VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
size[1] > 0 ? size[1] : 1,
size[2] > 0 ? size[2] : 1,
size[3] > 0 ? size[3] : 1 ),
_items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
DataSource::none() ) ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( bordersize.toVector() )
{
constructBorders( bordersize.toVector(), allocatorContext, allocated );
}
template < typename T >
Volume< T >::Volume( int sizeX, int sizeY, int sizeZ,
int sizeT, int bordersize,
const AllocatorContext& allocatorContext,
bool allocated )
: VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
_items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
DataSource::none() ) ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
_pos[0] = bordersize;
_pos[1] = bordersize;
_pos[2] = bordersize;
constructBorders(
Position4Di( bordersize, bordersize, bordersize, 0 ).toVector(),
allocatorContext, allocated );
}
template < typename T >
Volume< T >::Volume( const Position4Di & size,
int bordersize,
const AllocatorContext& allocatorContext,
bool allocated ):
VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
size[1] > 0 ? size[1] : 1,
size[2] > 0 ? size[2] : 1,
size[3] > 0 ? size[3] : 1 ),
_items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
DataSource::none() ) ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
_pos[0] = bordersize;
_pos[1] = bordersize;
_pos[2] = bordersize;
constructBorders(
Position4Di( bordersize, bordersize, bordersize, 0 ).toVector(),
allocatorContext, allocated );
}
template < typename T >
Volume< T >::Volume( const std::vector<int> & size,
const AllocatorContext& allocatorContext,
bool allocated ):
VolumeProxy< T >( size ),
_items( 0U, allocatorContext ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
allocate( std::vector<int>( 1, -1 ), allocated, allocatorContext );
}
template < typename T >
Volume< T >::Volume( const std::vector<int> & size,
const std::vector<int> & bordersize,
const AllocatorContext& allocatorContext,
bool allocated ):
VolumeProxy< T >( size ),
_items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
DataSource::none() ) ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( bordersize )
{
while( _pos.size() < 4 )
_pos.push_back( 0 );
constructBorders( bordersize, allocatorContext, allocated );
}
/***************************************************************************
* Buffer Constructor
**************************************************************************/
template < typename T >
Volume< T >::Volume( int sizeX, int sizeY, int sizeZ, int sizeT, T* buffer,
const std::vector<size_t> *strides )
: VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
_items( sizeX * sizeY * sizeZ * sizeT, buffer ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
allocate( -1, -1, -1, -1, true, allocatorContext(), strides );
}
template < typename T >
Volume< T >::Volume( const Position4Di & size, T* buffer,
const std::vector<size_t> *strides ):
VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
size[1] > 0 ? size[1] : 1,
size[2] > 0 ? size[2] : 1,
size[3] > 0 ? size[3] : 1 ),
_items( (long)(size[0] > 0 ? size[0] : 1) *
(long)(size[1] > 0 ? size[1] : 1) *
(long)(size[2] > 0 ? size[2] : 1) *
(long)(size[3] > 0 ? size[3] : 1), buffer ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
allocate( -1, -1, -1, -1, true, allocatorContext(), strides );
}
template < typename T >
Volume< T >::Volume( const std::vector<int> & size, T* buffer,
const std::vector<size_t> *strides ):
VolumeProxy< T >( size ),
_items( (long) Position4Di::size_num_elements( size ), buffer ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( 4, 0 )
{
allocate( std::vector<int>( 1, -1 ), true, allocatorContext(), strides );
}
/***************************************************************************
* View Constructor
**************************************************************************/
template<typename T> inline
Volume<T>::Volume( rc_ptr<Volume<T> > other,
const Position4Di & pos, const Position4Di & size,
const AllocatorContext & allocContext )
: VolumeProxy<T>( size[0] >= 0 ? size[0] :
other->allocatorContext().isAllocated() ? other->getSizeX() : 1,
size[1] >= 0 ? size[1] :
other->allocatorContext().isAllocated() ? other->getSizeY() : 1,
size[2] >= 0 ? size[2] :
other->allocatorContext().isAllocated() ? other->getSizeZ() : 1,
size[3] >= 0 ? size[3] :
other->allocatorContext().isAllocated() ? other->getSizeT() : 1 ),
_items( 0U, allocContext ),
_refvol( other ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( pos.toVector() )
{
if( other->allocatorContext().isAllocated() )
{
size_t bsize = sizeof(T);
int i, n = size.size();
for( i=0; i<n; ++i )
bsize *= size[i];
allocate( -1, -1, -1, -1, true,
AllocatorContext( AllocatorStrategy::NotOwner,
rc_ptr<DataSource>( new BufferDataSource
( (char *) &(*other)( pos.toVector() ),
bsize ) ) ) );
// fix offsets
#ifdef CARTO_USE_BLITZ
blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
n = VolumeProxy<T>::_size.size();
for( i=0; i<n; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
_blitz.reference
( blitz::Array<T,Volume<T>::DIM_MAX>
( &_items[0],
dims,
other->_blitz.stride(),
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
#else
_lineoffset = &(*other)( 0, 1, 0 ) - &(*other)( 0, 0, 0 );
_sliceoffset = &(*other)( 0, 0, 1 ) - &(*other)( 0, 0, 0 );
_volumeoffset = &(*other)( 0, 0, 0, 1 ) - &(*other)( 0, 0, 0 );
#endif
}
else
allocate( -1, -1, -1, -1, true, allocContext );
/* copy voxel_size from underlying volume, if any.
This should probably be more general, but cannot be applied to all
header properties (size, transformations...).
WARNING: Moreover here we do not guarantee to keep both voxel_size
unique: we point to the same vector of values for now, but it can be
replaced (thus, duplicated) by a setProperty().
We could use a addBuiltinProperty(), but then the voxel size has to be
stored in a fixed location somewhere.
*/
try
{
carto::Object vs = other->header().getProperty( "voxel_size" );
size_t n = this->getSize().size();
if( vs->size() > n )
{
// drop additional sizes
size_t i;
std::vector<carto::Object> vs2( n );
for( i=0; i<n; ++i )
vs2[i] = vs->getArrayItem( i );
this->header().setProperty( "voxel_size", vs2 );
}
else
this->header().setProperty( "voxel_size", vs );
}
catch( ... )
{
// never mind.
}
}
template<typename T> inline
Volume<T>::Volume( rc_ptr<Volume<T> > other,
const Position & pos, const Position & size,
const AllocatorContext & allocContext )
: VolumeProxy<T>( Position4Di::fixed_size( size ) ),
_items( 0U, allocContext ),
_refvol( other ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( Position4Di::fixed_position( pos ) )
{
if( other->allocatorContext().isAllocated() )
{
size_t bsize = sizeof(T);
int i, n = size.size();
for( i=0; i<n; ++i )
bsize *= size[i];
allocate( -1, -1, -1, -1, true,
AllocatorContext( AllocatorStrategy::NotOwner,
rc_ptr<DataSource>( new BufferDataSource
( (char *) &(*other)( pos ),
bsize ) ) ) );
// fix offsets
#ifdef CARTO_USE_BLITZ
blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
n = VolumeProxy<T>::_size.size();
for(i=0; i<n; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
_blitz.reference
( blitz::Array<T,Volume<T>::DIM_MAX>
( &_items[0],
dims,
other->_blitz.stride(),
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
#else
_lineoffset = &(*other)( 0, 1, 0 ) - &(*other)( 0, 0, 0 );
_sliceoffset = &(*other)( 0, 0, 1 ) - &(*other)( 0, 0, 0 );
_volumeoffset = &(*other)( 0, 0, 0, 1 ) - &(*other)( 0, 0, 0 );
#endif
}
else
allocate( -1, -1, -1, -1, true, allocContext );
/* copy voxel_size from underlying volume, if any.
This should probably be more general, but cannot be applied to all
header properties (size, transformations...).
WARNING: Moreover here we do not guarantee to keep both voxel_size
unique: we point to the same vector of values for now, but it can be
replaced (thus, duplicated) by a setProperty().
We could use a addBuiltinProperty(), but then the voxel size has to be
stored in a fixed location somewhere.
*/
try
{
carto::Object vs = other->header().getProperty( "voxel_size" );
size_t n = this->getSize().size();
if( vs->size() > n )
{
// drop additional sizes
size_t i;
std::vector<carto::Object> vs2( n );
for( i=0; i<n; ++i )
vs2[i] = vs->getArrayItem( i );
this->header().setProperty( "voxel_size", vs2 );
}
else
this->header().setProperty( "voxel_size", vs );
}
catch( ... )
{
// never mind.
}
}
// view + buffer (only for IO)
template < typename T >
Volume< T >::Volume( rc_ptr<Volume<T> > other, const Position & pos,
const Position & size, T* buffer,
const std::vector<size_t> & strides )
: VolumeProxy<T>( size ),
_items( (long) Position4Di::size_num_elements( size ), buffer ),
_refvol( other ),
#ifndef CARTO_USE_BLITZ
_lineoffset( 0 ),
_sliceoffset( 0 ),
_volumeoffset( 0 ),
#endif
_pos( pos )
{
allocate( -1, -1, -1, -1, true, allocatorContext(), &strides );
}
/***************************************************************************
* Copy Constructor
**************************************************************************/
template < typename T >
Volume< T >::Volume( const Volume< T >& other )
: RCObject(),
VolumeProxy< T >( other ),
_items( other._items ),
#ifdef CARTO_USE_BLITZ
// TODO: test blitz ownership / strides
// _blitz = other.blitz;
_blitz( &_items[0],
other._blitz.shape(),
other._blitz.stride(),
blitz::GeneralArrayStorage<8>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ),
#else
_lineoffset( other._lineoffset ),
_sliceoffset( other._sliceoffset ),
_volumeoffset( other._volumeoffset ),
#endif
_refvol( other.refVolume().get() ?
new Volume<T>( *other.refVolume() ) : 0 ),
_pos( other.posInRefVolume() )
{
if( _refvol.get() ) // view case: the underlying volume is copied.
{
Position4Di pos = other.posInRefVolume();
std::vector<int> oldSize(1, -1);
allocate( oldSize, true, _refvol->allocatorContext().isAllocated()
? AllocatorContext( AllocatorStrategy::NotOwner,
rc_ptr<DataSource>( new BufferDataSource
( (char *) &(*_refvol)( pos[0], pos[1], pos[2], pos[3] ),
VolumeProxy<T>::getSizeX() * VolumeProxy<T>::getSizeY()
* VolumeProxy<T>::getSizeZ()
* VolumeProxy<T>::getSizeT()
* sizeof(T) ) ) )
: AllocatorContext( other.allocatorContext() ) );
if( _refvol->allocatorContext().isAllocated() )
{
// fix offsets
#ifdef CARTO_USE_BLITZ
blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
int i, n=VolumeProxy<T>::_size.size();
for( i=0; i<n; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
_blitz.reference
( blitz::Array<T,Volume<T>::DIM_MAX>
( &_items[0],
dims,
other._blitz.stride(),
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 5, 6, 7, 8 ), true ) ) );
#else
_lineoffset = &other( 0, 1, 0 ) - &other( 0, 0, 0 );
_sliceoffset = &other( 0, 0, 1 ) - &other( 0, 0, 0 );
_volumeoffset = &other( 0, 0, 0, 1 ) - &other( 0, 0, 0 );
#endif
}
}
}
template < typename T >
Volume< T >::~Volume()
{
}
//============================================================================
// M E T H O D S
//============================================================================
template < typename T > inline
const AllocatorContext& Volume<T>::allocatorContext() const
{
return _items.allocatorContext();
}
template <typename T> inline
rc_ptr<Volume<T> > Volume<T>::refVolume() const
{
return _refvol;
}
template <typename T> inline
const typename Volume<T>::Position & Volume<T>::posInRefVolume() const
{
return _pos;
}
template <typename T>
inline
int Volume<T>::getLevelsCount() const {
int l = 0;
rc_ptr<Volume<T> > v(const_cast<Volume<T> *>(this));
while (!v.isNull()) {
l++;
v = v->refVolume();
}
return l;
}
template <typename T>
inline
int Volume<T>::refLevel(const int level) const {
int c = getLevelsCount();
int l = level;
if (l < 0) {
l = c + l;
}
if ((l < 0) && (l >= c)) {
throw std::out_of_range("level " + carto::toString(level)
+ " is out range (" + carto::toString(-c)
+ ", " + carto::toString(c-1) + ")");
}
return l;
}
template <typename T>
inline
rc_ptr<Volume<T> > Volume<T>::refVolumeAtLevel(const int level) const {
int l = refLevel(level);
int c = 0;
rc_ptr<Volume<T> > v(const_cast<Volume<T> *>(this));
while ((c < l) && (!v.isNull())) {
v = v->refVolume();
c++;
}
return v;
}
template <typename T>
inline
typename Volume<T>::Position Volume<T>::posInRefVolumeAtLevel(
const int level) const {
int l = refLevel(level);
size_t s = this->getSize().size();
typename Volume<T>::Position offset(s, 0);
int c = 0;
rc_ptr<Volume<T> > v(const_cast<Volume<T> *>(this));
while ((c < l) && (!v.isNull())) {
const Position & pos = v->posInRefVolume();
for (size_t i = 0; i < s; ++i)
offset[i] += pos[i];
v = v->refVolume();
c++;
}
return offset;
}
template <typename T> inline
void Volume<T>::updateItemsBuffer()
{
if ( !allocatorContext().isAllocated()
|| (allocatorContext().accessMode() == AllocatorStrategy::NotOwner) )
{
// Free old buffer
_items.free();
if (_refvol.get())
{
// Recreate items buffer that reference volume
// using correct sizes and position
if( _refvol->allocatorContext().isAllocated() )
{
size_t size = sizeof(T);
int i, n = VolumeProxy<T>::_size.size();
for( i=0; i<n; ++i )
size *= VolumeProxy<T>::_size[i];
_items.allocate(
0U,
AllocatorContext( AllocatorStrategy::NotOwner,
rc_ptr<DataSource>( new BufferDataSource
( (char *) &(*(_refvol))( _pos ),
size ) ) ) );
}
else
_items.allocate( 0U, allocatorContext() );
if ( _refvol->allocatorContext().isAllocated() )
{
// fix offsets
#ifdef CARTO_USE_BLITZ
blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
int i, n=VolumeProxy<T>::_size.size();
for( i=0; i<n; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
_blitz.reference
( blitz::Array<T,Volume<T>::DIM_MAX>
( &_items[0],
dims,
_refvol->_blitz.stride(),
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
#else
_lineoffset = &(*_refvol)( 0, 1, 0 ) - &(*_refvol)( 0, 0, 0 );
_sliceoffset = &(*_refvol)( 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
_volumeoffset = &(*_refvol)( 0, 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
#endif
}
/* copy voxel_size from underlying volume, if any.
This should probably be more general, but cannot be applied to all
header properties (size, transformations...).
WARNING: Moreover here we do not guarantee to keep both voxel_size
unique: we point to the same vector of values for now, but it can be
replaced (thus, duplicated) by a setProperty().
We could use a addBuiltinProperty(), but then the voxel size has to be
stored in a fixed location somewhere.
*/
try
{
carto::Object vs = _refvol->header().getProperty( "voxel_size" );
this->header().setProperty( "voxel_size", vs );
}
catch( ... )
{
// never mind.
}
}
}
}
template <typename T> inline
void Volume<T>::setPosInRefVolume( const Position4Di & pos )
{
if ( pos != _pos )
{
_pos = pos.toVector();
updateItemsBuffer();
}
}
template <typename T> inline
void Volume<T>::setPosInRefVolume( const Position & pos ) {
if (pos != _pos)
{
_pos = pos;
while( _pos.size() < 4 )
_pos.push_back( 0 );
updateItemsBuffer();
}
}
template <typename T> inline
void Volume<T>::setRefVolume( const rc_ptr<Volume<T> > & refvol) {
if (refvol.get() != _refvol.get()) {
_refvol = refvol;
updateItemsBuffer();
}
}
template <typename T> inline
std::vector<int> Volume<T>::getBorders() const
{
std::vector<int> borders( VolumeProxy<T>::_size.size() * 2, 0 );
if( _refvol.get() && _refvol->allocatorContext().isAllocated() )
{
int i, n = VolumeProxy<T>::_size.size();
for( i=0; i<n; ++i )
borders[i*2 + 1] = _refvol->_size[i] - VolumeProxy<T>::_size[i];
for( i=0, n=_pos.size(); i<n; ++i )
{
borders[i*2] = _pos[i];
borders[i*2+1] -= _pos[i];
}
}
return borders;
}
template <typename T> inline
std::vector<size_t> Volume<T>::getStrides() const
{
#ifdef CARTO_USE_BLITZ
const blitz::TinyVector<BlitzStridesType, Volume<T>::DIM_MAX>& bstrides = _blitz.stride();
int d, n = VolumeProxy<T>::_size.size();
std::vector<size_t> strides( n );
for (d = 0; d < n; ++d)
strides[d] = bstrides[d];
#else
std::vector<size_t> strides(4);
strides[0] = 1;
strides[1] = _lineoffset;
strides[2] = _sliceoffset;
strides[3] = _volumeoffset;
#endif
return strides;
}
template < typename T >
Volume< T >& Volume< T >::operator=( const Volume< T >& other )
{
if( &other == this )
return *this;
bool b = Headered::signalsBlocked();
if( !b )
Headered::blockSignals( true );
this->VolumeProxy< T >::operator=( other );
// copy buffer, preserving allocator
_items.copy( other._items, other.allocatorContext() );
#ifdef CARTO_USE_BLITZ
// TODO: test blitz ownership / strides
// _blitz.reference( other.blitz );
blitz::TinyVector<long, Volume<T>::DIM_MAX> dims;
int i, n = VolumeProxy<T>::_size.size();
for( i=0; i<n; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
_blitz.reference
( blitz::Array<T,Volume<T>::DIM_MAX>
( &_items[0],
dims,
other._blitz.stride(),
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
#else
_lineoffset = other._lineoffset;
_sliceoffset = other._sliceoffset;
_volumeoffset = other._volumeoffset;
#endif
_refvol = other._refvol;
_pos = other._pos;
initialize();
if( !b )
Headered::blockSignals( false );
return *this;
}
template <typename T>
void Volume<T>::copySubVolume( const Volume<T> & source,
const std::vector<int> & pos )
{
std::vector<int> size = this->getSize();
std::vector<int> osize = source.getSize();
int i;
for( i=0; i<size.size() && i<osize.size(); ++i )
{
int ip = 0;
if( pos.size() > i )
ip = pos[i];
size[i] = std::min( size[i] - ip, osize[i] );
}
for( ; i<size.size(); ++i )
size[i] = 1;
line_NDIterator<T> it( &at( pos ), size, this->getStrides() );
const_line_NDIterator<T> oit( &source.at( 0 ), size, source.getStrides() );
T *p, *pn;
const T *op;
for( ; !it.ended(); ++it, ++oit )
{
p = &*it;
op = &*oit;
for( pn=p + it.line_length(); p!=pn;
it.inc_line_ptr( p ), oit.inc_line_ptr( op ) )
*p = *op;
}
}
template <typename T>
void Volume<T>::copySubVolume( const rc_ptr<Volume<T> > & source,
const std::vector<int> & pos )
{
copySubVolume( *source, pos );
}
template < typename T >
typename Volume< T >::iterator Volume< T >::begin()
{
#ifdef CARTO_USE_BLITZ
return _blitz.begin();
#else
return _items.begin();
#endif
}
template < typename T >
typename Volume< T >::iterator Volume< T >::end()
{
#ifdef CARTO_USE_BLITZ
return _blitz.end();
#else
return _items.end();
#endif
}
template < typename T >
typename Volume< T >::const_iterator Volume< T >::begin() const
{
#ifdef CARTO_USE_BLITZ
return _blitz.begin();
#else
return _items.begin();
#endif
}
template < typename T >
typename Volume< T >::const_iterator Volume< T >::end() const
{
#ifdef CARTO_USE_BLITZ
return _blitz.end();
#else
return _items.end();
#endif
}
template < typename T >
void Volume< T >::initialize()
{
// initializing headered stuff
this->Headered::initialize();
// creating size filter
std::set< std::string > sizePropertyNames;
sizePropertyNames.insert( "sizeX" );
sizePropertyNames.insert( "sizeY" );
sizePropertyNames.insert( "sizeZ" );
sizePropertyNames.insert( "sizeT" );
sizePropertyNames.insert( "volume_dimension" );
rc_ptr< PropertyFilter >
sizeRcPropertyFilter( new PropertyFilter( "size", sizePropertyNames ) );
// adding size filter to headered and connecting signal to slot
Headered::addPropertyFilter( sizeRcPropertyFilter );
Headered::connect( sizeRcPropertyFilter->getName(),
::sigc::mem_fun( *this, &Volume< T >::slotSizeChanged ) );
}
template < typename T >
void Volume< T >::allocate( int oldSizeX,
int oldSizeY,
int oldSizeZ,
int oldSizeT,
bool allocate,
const AllocatorContext& ac,
const std::vector<size_t> *strides )
{
std::vector<int> oldSize(4);
oldSize[0] = oldSizeX;
oldSize[1] = oldSizeY;
oldSize[2] = oldSizeZ;
oldSize[3] = oldSizeT;
Volume< T >::allocate( oldSize, allocate, ac, strides );
}
template < typename T >
void Volume< T >::allocate( const std::vector<int> & oldSize,
bool allocate,
const AllocatorContext& ac,
const std::vector<size_t> *nstrides )
{
std::vector<unsigned long long int> strides(Volume<T>::DIM_MAX, 0);
int i = 0, n = oldSize.size(), nn = VolumeProxy<T>::_size.size();
unsigned long long int stride_max = 0;
unsigned long long int total_len = 0;
if( nstrides )
{
for( ; i<std::min(nstrides->size(), size_t(nn)); ++i )
{
strides[i] = (*nstrides)[i];
if( strides[i] > stride_max )
stride_max = strides[i];
if( strides[i] * VolumeProxy<T>::_size[i] > total_len )
total_len = strides[i] * VolumeProxy<T>::_size[i];
}
}
for( ; i<nn; ++i )
{
strides[i] = ( i == 0 ? 1 : VolumeProxy<T>::_size[i-1] * stride_max );
if( strides[i] > stride_max )
stride_max = strides[i];
if( strides[i] * VolumeProxy<T>::_size[i] > total_len )
total_len = strides[i] * VolumeProxy<T>::_size[i];
}
for( ; i<Volume<T>::DIM_MAX; ++i )
strides[i] = ( i == nn ? VolumeProxy<T>::_size[i-1] * stride_max
: strides[i-1] );
if ( total_len * sizeof(T) >
(unsigned long long int) std::numeric_limits< size_t >::max() )
{
throw std::runtime_error
( std::string( "attempt to allocate a volume which size is greater "
"than allowed by the system (" )
+ toString( std::numeric_limits< size_t >::max() ) + " bytes)" );
}
bool no_old = true;
for( i=0; i<n; ++i )
if( oldSize[i] != -1 )
{
no_old = false;
break;
}
if ( !allocate // why !allocate ?
|| !_items.allocatorContext().isAllocated()
|| no_old )
{
// allocating memory space
_items.free();
if( allocate )
_items.allocate( ( size_t ) total_len, ac );
}
else if ( oldSize != VolumeProxy<T>::_size
|| &ac != &_items.allocatorContext() )
{
// allocating a new memory space
AllocatedVector<T> newItems( ( size_t ) total_len, ac );
std::vector<int> minSize = VolumeProxy<T>::_size;
for( i=0; i<std::min(n, nn); ++i )
if( oldSize[i] < minSize[i] )
minSize[i] = oldSize[i];
// preserving data
int x, y, z, t;
if( newItems.allocatorContext().allocatorType()
!= AllocatorStrategy::ReadOnlyMap )
for ( t = 0; t < minSize[3]; t++ )
{
for ( z = 0; z < minSize[2]; z++ )
{
for ( y = 0; y < minSize[1]; y++ )
{
for ( x = 0; x < minSize[0]; x++ )
{
// TODO: handle former strides with oldSize
newItems[ x * strides[0] +
y * strides[1] +
z * ( size_t ) strides[2] +
t * ( size_t ) strides[3] ] =
_items[ x +
y * oldSize[0] +
z * ( size_t ) oldSize[0]
* ( size_t ) oldSize[1] +
t * ( size_t ) oldSize[0] *
( size_t ) oldSize[1]
* ( size_t ) oldSize[2] ];
}
}
}
}
// copying new data to old one
_items = newItems;
}
blitz::TinyVector<BlitzStridesType, Volume<T>::DIM_MAX> bstrides;
if( nstrides )
{
for( i=0; i<nn; ++i )
bstrides[i] = strides[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
{
bstrides[i] = ( i == 0 ? VolumeProxy<T>::_size[0]
: VolumeProxy<T>::_size[i] * stride_max );
if( strides[i] > stride_max )
stride_max = bstrides[i];
}
}
if( allocate )
{
#ifdef CARTO_USE_BLITZ
// TODO: test blitz ownership / strides
/*
std::cout << "alloc blitz: " << VolumeProxy<T>::_size[0] << ", "
<< VolumeProxy<T>::_size[1] << ", "
<< VolumeProxy<T>::_size[2] << ", "
<< VolumeProxy<T>::_size[3] << std::endl;
*/
blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
for( i=0; i<nn; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
if( nstrides)
_blitz.reference( blitz::Array<T,Volume<T>::DIM_MAX>
( &_items[0],
dims,
bstrides,
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ),
true ) ) );
else
_blitz.reference( blitz::Array<T,Volume<T>::DIM_MAX>
( &_items[0],
dims,
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ),
true ) ) );
/*
std::cout << &_items[0] << " / " << &_blitz( 0 ) << std::endl;
std::cout << blitz::shape( VolumeProxy<T>::_size[0],
VolumeProxy<T>::_size[1],
VolumeProxy<T>::_size[2],
VolumeProxy<T>::_size[3}] ) << std::endl;
std::cout << "blitz data: " << _blitz.data() << std::endl;
std::cout << "blitz ordering: " << _blitz.ordering() << std::endl;
std::cout << "blitz numEl: " << _blitz.numElements() << std::endl;
std::cout << "blitz strides: " << _blitz.stride() << std::endl;
*/
#else
_lineoffset = strides[1];
_sliceoffset = strides[2];
_volumeoffset = strides[3];
#endif
}
else
{
#ifdef CARTO_USE_BLITZ
blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
for( i=0; i<nn; ++i )
dims[i] = VolumeProxy<T>::_size[i];
for( ; i<Volume<T>::DIM_MAX; ++i )
dims[i] = 1;
if( nstrides )
// TODO: test blitz ownership
_blitz.reference( blitz::Array<T,Volume<T>::DIM_MAX>
( 0,
dims,
bstrides,
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
else
// TODO: test blitz ownership / strides
_blitz.reference( blitz::Array<T,Volume<T>::DIM_MAX>
( 0,
dims,
blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
#else
if( nstrides )
{
_lineoffset = strides[1];
_sliceoffset = strides[2];
_volumeoffset = strides[3];
}
else
{
_lineoffset = 0;
_sliceoffset = 0;
_volumeoffset = 0;
}
#endif
}
}
template < typename T >
void Volume< T >::allocate()
{
if( !allocatorContext().isAllocated() )
{
std::vector<size_t> strides = getStrides();
allocate( VolumeProxy<T>::getSize(), true, allocatorContext(),
&strides );
}
}
template < typename T >
void Volume< T >::slotSizeChanged( const PropertyFilter& propertyFilter )
{
/* std::cout << "Volume< " << DataTypeCode<T>::name()
<< " >::slotSizeChanged"
<< std::endl; */
std::vector<int> oldSize = VolumeProxy<T>::_size;
if ( propertyFilter.hasOldValue( "sizeX" ) )
{
oldSize[0] =
propertyFilter.getOldValue( "sizeX" )->GenericObject::value< int >();
}
if ( propertyFilter.hasOldValue( "sizeY" ) )
{
oldSize[1] =
propertyFilter.getOldValue( "sizeY" )->GenericObject::value< int >();
}
if ( propertyFilter.hasOldValue( "sizeZ" ) )
{
oldSize[2] =
propertyFilter.getOldValue( "sizeZ" )->GenericObject::value< int >();
}
if ( propertyFilter.hasOldValue( "sizeT" ) )
{
oldSize[3] =
propertyFilter.getOldValue( "sizeT" )->GenericObject::value< int >();
}
/*
std::cout << "old size: " << oldSize[0] << ", " << oldSize[1] << ", "
<< oldSize[2] << ", " << oldSize[3] << std::endl;
std::cout << "new size: " << VolumeProxy<T>::_size[0] << ", "
<< VolumeProxy<T>::_size[1] << ", "
<< VolumeProxy<T>::_size[2] << ", " << VolumeProxy<T>::_size[3]
<< std::endl;
*/
allocate( oldSize,
_items.allocatorContext().isAllocated(), allocatorContext() );
}
template < typename T >
void Volume< T >::reallocate( int sizeX,
int sizeY,
int sizeZ,
int sizeT,
bool keepcontents,
const AllocatorContext & ac,
bool alloc,
const std::vector<size_t> *strides )
{
int oldx = VolumeProxy<T>::_size[0];
int oldy = VolumeProxy<T>::_size[1];
int oldz = VolumeProxy<T>::_size[2];
int oldt = VolumeProxy<T>::_size[3];
VolumeProxy<T>::_size.resize( 4 );
VolumeProxy<T>::_size[0] = sizeX;
VolumeProxy<T>::_size[1] = sizeY;
VolumeProxy<T>::_size[2] = sizeZ;
VolumeProxy<T>::_size[3] = sizeT;
if( keepcontents || ( sizeX == oldx && sizeY == oldy && sizeZ == oldz
&& sizeT == oldt ) )
allocate( oldx, oldy, oldz, oldt, alloc, ac, strides );
else
allocate( std::vector<int>(1, -1), alloc, ac, strides );
// emit a signal ?
}
template < typename T >
void Volume< T >::reallocate( const Position4Di & size,
bool keepcontents,
const AllocatorContext & ac,
bool alloc,
const std::vector<size_t> *strides )
{
return reallocate( size[0] > 0 ? size[0] : 1,
size[1] > 0 ? size[1] : 1,
size[2] > 0 ? size[2] : 1,
size[3] > 0 ? size[3] : 1,
keepcontents, ac, alloc, strides );
}
template < typename T >
void Volume< T >::reallocate( const std::vector<int> & size,
bool keepcontents,
const AllocatorContext & ac,
bool alloc,
const std::vector<size_t> *strides )
{
std::vector<int> old = VolumeProxy<T>::_size;
VolumeProxy<T>::_size = size;
while( VolumeProxy<T>::_size.size() < 4 )
VolumeProxy<T>::_size.push_back( 1 );
VolumeProxy<T>::header().changeBuiltinProperty( "sizeX",
VolumeProxy<T>::_size[0] );
VolumeProxy<T>::header().changeBuiltinProperty( "sizeY",
VolumeProxy<T>::_size[1] );
VolumeProxy<T>::header().changeBuiltinProperty( "sizeZ",
VolumeProxy<T>::_size[2] );
VolumeProxy<T>::header().changeBuiltinProperty( "sizeT",
VolumeProxy<T>::_size[3] );
if( keepcontents || size == old )
allocate( old, alloc, ac, strides );
else
allocate( std::vector<int>(1, -1), alloc, ac, strides );
// emit a signal ?
}
//============================================================================
// U T I L I T I E S
//============================================================================
template <typename T>
Volume<T>* Creator<Volume<T> >::create( Object header,
const AllocatorContext & context,
Object options )
{
std::vector<int> dims( 4, 1 );
bool unalloc = false;
if( !header->getProperty( "volume_dimension", dims ) )
{
header->getProperty( "sizeX", dims[0] );
header->getProperty( "sizeY", dims[1] );
header->getProperty( "sizeZ", dims[2] );
header->getProperty( "sizeT", dims[3] );
}
options->getProperty( "unallocated", unalloc );
std::vector<int> borders( 3, 0 );
try {
borders[0] = (int) rint( options->getProperty( "border" )->getScalar() );
borders[1] = (int) rint( options->getProperty( "border" )->getScalar() );
borders[2] = (int) rint( options->getProperty( "border" )->getScalar() );
} catch( ... ) {}
try {
borders[0] = (int) rint( options->getProperty( "bx" )->getScalar() );
} catch( ... ) {}
try {
borders[1] = (int) rint( options->getProperty( "by" )->getScalar() );
} catch( ... ) {}
try {
borders[2] = (int) rint( options->getProperty( "bz" )->getScalar() );
} catch( ... ) {}
Volume<T> *obj;
if( borders[0] != 0 || borders[1] != 0 || borders[2] != 0 )
{
std::vector<int> big_dims = dims;
big_dims[0] += borders[0] * 2;
big_dims[1] += borders[1] * 2;
big_dims[2] += borders[2] * 2;
obj = new Volume<T>( big_dims, context, !unalloc );
obj = new Volume<T>( rc_ptr<Volume<T> >( obj ), borders, dims, context );
}
else
obj = new Volume<T>( dims, context, !unalloc );
obj->blockSignals( true );
obj->header().copyProperties( header );
// restore original sizes : temporary too...
obj->blockSignals( false );
return obj;
}
template <typename T>
void Creator<Volume<T> >::setup( Volume<T> & obj, Object header,
const AllocatorContext & context,
Object options )
{
std::vector<int> dims( 4, 1 );
bool unalloc = false, partial = false, keep_allocation = false;
try
{
carto::Object p = options->getProperty( "partial_reading" );
partial = bool( p->getScalar() );
}
catch( ... ) {}
if( !partial )
{
if( !header->getProperty( "volume_dimension", dims ) )
{
header->getProperty( "sizeX", dims[0] );
header->getProperty( "sizeY", dims[1] );
header->getProperty( "sizeZ", dims[2] );
header->getProperty( "sizeT", dims[3] );
}
try
{
carto::Object p = options->getProperty( "unallocated" );
unalloc = bool( p->getScalar() );
}
catch( ... ) {}
try
{
carto::Object p = options->getProperty( "keep_allocation" );
keep_allocation = bool( p->getScalar() );
}
catch( ... ) {}
if( !keep_allocation || !obj.allocatorContext().isAllocated()
|| obj.allocatorContext().allocatorType()
!= AllocatorStrategy::Unallocated )
obj.reallocate( dims, false, context, !unalloc );
}
else
{
const_cast<AllocatorContext &>( obj.allocatorContext() ).setDataSource
( context.dataSource() );
// preserve dimensions
dims = obj.getSize();
}
obj.blockSignals( true );
obj.header().copyProperties( header );
if( partial )
{
// restore dimensions
PropertySet & ps = obj.header();
ps.setProperty( "volume_dimension", dims );
ps.setProperty( "sizeX", dims[0] );
ps.setProperty( "sizeY", dims[1] );
ps.setProperty( "sizeZ", dims[2] );
ps.setProperty( "sizeT", dims[3] );
}
obj.blockSignals( false );
}
} // namespace carto
#endif // CARTODATA_VOLUME_VOLUMEBASE_D_H
| 32.397342 | 94 | 0.508368 |
8397fad1177cc58b0c2b45354f755ce7f0b46f88 | 2,901 | h | C | media/base/stream_parser.h | gavinp/chromium | 681563ea0f892a051f4ef3d5e53438e0bb7d2261 | [
"BSD-3-Clause"
] | 1 | 2016-03-10T09:13:57.000Z | 2016-03-10T09:13:57.000Z | media/base/stream_parser.h | gavinp/chromium | 681563ea0f892a051f4ef3d5e53438e0bb7d2261 | [
"BSD-3-Clause"
] | 1 | 2022-03-13T08:39:05.000Z | 2022-03-13T08:39:05.000Z | media/base/stream_parser.h | gavinp/chromium | 681563ea0f892a051f4ef3d5e53438e0bb7d2261 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_STREAM_PARSER_H_
#define MEDIA_BASE_STREAM_PARSER_H_
#include <deque>
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "base/time.h"
#include "media/base/media_export.h"
namespace media {
class AudioDecoderConfig;
class Buffer;
class VideoDecoderConfig;
// Provides callback methods for StreamParser to report information
// about the media stream.
class MEDIA_EXPORT StreamParserHost {
public:
typedef std::deque<scoped_refptr<Buffer> > BufferQueue;
StreamParserHost();
virtual ~StreamParserHost();
// A new audio decoder configuration was encountered. All audio buffers
// after this call will be associated with this configuration.
virtual bool OnNewAudioConfig(const AudioDecoderConfig& config) = 0;
// A new video decoder configuration was encountered. All video buffers
// after this call will be associated with this configuration.
virtual bool OnNewVideoConfig(const VideoDecoderConfig& config) = 0;
// New audio buffers have been received.
virtual bool OnAudioBuffers(const BufferQueue& buffers) = 0;
// New video buffers have been received.
virtual bool OnVideoBuffers(const BufferQueue& buffers) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(StreamParserHost);
};
// Abstract interface for parsing media byte streams.
class MEDIA_EXPORT StreamParser {
public:
StreamParser();
virtual ~StreamParser();
// Indicates completion of parser initialization.
// First parameter - Indicates initialization success. Set to true if
// initialization was successful. False if an error
// occurred.
// Second parameter - Indicates the stream duration. Only contains a valid
// value if the first parameter is true.
typedef base::Callback<void(bool, base::TimeDelta)> InitCB;
// Initialize the parser with necessary callbacks. Must be called before any
// data is passed to Parse(). |init_cb| will be called once enough data has
// been parsed to determine the initial stream configurations, presentation
// start time, and duration.
virtual void Init(const InitCB& init_cb, StreamParserHost* host) = 0;
// Called when a seek occurs. This flushes the current parser state
// and puts the parser in a state where it can receive data for the new seek
// point.
virtual void Flush() = 0;
// Called when there is new data to parse.
//
// Returns < 0 if the parse fails.
// Returns 0 if more data is needed.
// Returning > 0 indicates success & the number of bytes parsed.
virtual int Parse(const uint8* buf, int size) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(StreamParser);
};
} // namespace media
#endif // MEDIA_BASE_STREAM_PARSER_H_
| 33.344828 | 78 | 0.738366 |
8399c55edc6e68bbf06da9cef2addb49c23b60e1 | 1,770 | h | C | plugins/robots/interpreters/iotikKitInterpreter/src/iotikKitInterpreterPlugin.h | Victor-Y-Fadeev/qreal | 2c7f14d5eb24753d4a7c038e13a3fa3026adce18 | [
"Apache-2.0"
] | 6 | 2017-07-03T13:55:35.000Z | 2018-11-28T03:39:51.000Z | plugins/robots/interpreters/iotikKitInterpreter/src/iotikKitInterpreterPlugin.h | Victor-Y-Fadeev/qreal | 2c7f14d5eb24753d4a7c038e13a3fa3026adce18 | [
"Apache-2.0"
] | 27 | 2017-06-29T09:36:37.000Z | 2017-11-25T14:50:04.000Z | plugins/robots/interpreters/iotikKitInterpreter/src/iotikKitInterpreterPlugin.h | Victor-Y-Fadeev/qreal | 2c7f14d5eb24753d4a7c038e13a3fa3026adce18 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2017 QReal Research group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */
#pragma once
#include <kitBase/kitPluginInterface.h>
#include <iotikKit/blocks/iotikBlocksFactory.h>
namespace iotik {
class IotikKitInterpreterPlugin : public QObject, public kitBase::KitPluginInterface
{
Q_OBJECT
Q_INTERFACES(kitBase::KitPluginInterface)
Q_PLUGIN_METADATA(IID "iotik.IotikKitInterpreterPlugin")
public:
IotikKitInterpreterPlugin();
QString kitId() const override;
QString friendlyKitName() const override;
QList<kitBase::robotModel::RobotModelInterface *> robotModels() override;
kitBase::blocksBase::BlocksFactoryInterface *blocksFactoryFor(
const kitBase::robotModel::RobotModelInterface *model) override;
QList<qReal::ActionInfo> customActions() override; // Transfers ownership of embedded QActions
QList<qReal::HotKeyActionInfo> hotKeyActions() override;
QList<kitBase::AdditionalPreferences *> settingsWidgets() override;
QString defaultSettingsFile() const override;
QIcon iconForFastSelector(const kitBase::robotModel::RobotModelInterface &robotModel) const override;
private:
/// @todo Use shared pointers instead of this sh~.
blocks::IotikBlocksFactory *mBlocksFactory = nullptr; // Transfers ownership
};
}
| 33.396226 | 102 | 0.783051 |
839b4f2a6a4d93228a1a80433de29515b588eba5 | 1,054 | h | C | HZScanUIDemo/HZCaptureScanTool/HZCaptureScanManager.h | JHB-Client/HZScanUIDemo | cdd926799662edd0826aec98f1247e5c609fadb7 | [
"Apache-2.0"
] | 1 | 2020-08-10T06:46:10.000Z | 2020-08-10T06:46:10.000Z | HZScanUIDemo/HZCaptureScanTool/HZCaptureScanManager.h | JHB-Client/HZScanUIDemo | cdd926799662edd0826aec98f1247e5c609fadb7 | [
"Apache-2.0"
] | null | null | null | HZScanUIDemo/HZCaptureScanTool/HZCaptureScanManager.h | JHB-Client/HZScanUIDemo | cdd926799662edd0826aec98f1247e5c609fadb7 | [
"Apache-2.0"
] | null | null | null | //
// HZCaptureScanManager.h
// HZScanUIDemo
//
// Created by admin on 2020/6/22.
// Copyright © 2020 admin. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@class HZCaptureScanManager;
NS_ASSUME_NONNULL_BEGIN
@protocol HZCaptureScanManagerOutputDelegate <NSObject>
- (void)captureScanManager:(HZCaptureScanManager *)captureScanManager didOutputMetadataObjects:(NSArray *)metadataObjects codeString:(NSString *)codeString;
- (void)captureScanManager:(HZCaptureScanManager *)captureScanManager didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer codeImage:(UIImage *)codeImage;
@end
@interface HZCaptureScanManager : NSObject
@property (nonatomic, weak) id <HZCaptureScanManagerOutputDelegate> outputDelegate;
@property (nonatomic, strong) UIView *preview;
@property (nonatomic, assign) CGRect interestReact;
@property (nonatomic, assign) BOOL torchNeeds;
+ (instancetype)shareManager;
- (void)startScanning;
- (void)stopScanning;
- (void)destroy;
@end
NS_ASSUME_NONNULL_END
| 35.133333 | 156 | 0.8074 |
839b8cbdb1af16a7965386781d07c929ce750186 | 3,283 | h | C | mdv_tests/mdv_platform/mdv_ebus.h | wwwVladislav/MedvedDB | 2c4b999871decd77ed12a8a9d0ec2f4a73215354 | [
"Apache-2.0"
] | 5 | 2019-09-05T13:40:13.000Z | 2020-04-20T12:41:55.000Z | mdv_tests/mdv_platform/mdv_ebus.h | wwwVladislav/MedvedDB | 2c4b999871decd77ed12a8a9d0ec2f4a73215354 | [
"Apache-2.0"
] | 27 | 2019-08-20T16:16:16.000Z | 2020-02-28T11:14:11.000Z | mdv_tests/mdv_platform/mdv_ebus.h | wwwVladislav/MedvedDB | 2c4b999871decd77ed12a8a9d0ec2f4a73215354 | [
"Apache-2.0"
] | 1 | 2019-09-27T08:06:11.000Z | 2019-09-27T08:06:11.000Z | #pragma once
#include <minunit.h>
#include <mdv_ebus.h>
#include <stdatomic.h>
typedef struct
{
mdv_event base;
atomic_int rc;
} mdv_event_test;
static mdv_event * mdv_event_test_retain(mdv_event *base)
{
mdv_event_test *event = (mdv_event_test *)base;
atomic_fetch_add(&event->rc, 1);
return base;
}
static uint32_t mdv_event_test_release(mdv_event *base)
{
mdv_event_test *event = (mdv_event_test *)base;
int rc = atomic_fetch_sub(&event->rc, 1) - 1;
if (!rc)
mdv_free(event);
return rc;
}
static mdv_errno mdv_event_test_handler(void *arg, mdv_event *event)
{
atomic_int *counter = arg;
atomic_fetch_add(counter, 1);
(void)event;
return MDV_OK;
}
MU_TEST(platform_ebus)
{
mdv_ebus_config const config =
{
.threadpool =
{
.size = 2,
.thread_attrs =
{
.stack_size = MDV_THREAD_STACK_SIZE
}
},
.event =
{
.queues_count = 4,
.max_id = 1
}
};
static mdv_ievent ievent_test =
{
.retain = mdv_event_test_retain,
.release = mdv_event_test_release
};
mdv_ebus *ebus = mdv_ebus_create(&config);
mu_check(ebus);
mdv_event_test *event_0 = mdv_alloc(sizeof(mdv_event_test));
event_0->base.vptr = &ievent_test;
event_0->base.type = 0;
event_0->rc = 1;
mdv_event_test *event_1 = mdv_alloc(sizeof(mdv_event_test));
event_1->base.vptr = &ievent_test;
event_1->base.type = 1;
event_1->rc = 1;
atomic_int counter_0 = 0, counter_1 = 0;
mu_check(mdv_ebus_subscribe(ebus,
0,
&counter_0,
mdv_event_test_handler) == MDV_OK);
mu_check(mdv_ebus_subscribe(ebus,
1,
&counter_1,
mdv_event_test_handler) == MDV_OK);
mu_check(mdv_ebus_subscribe(ebus,
0,
&counter_1,
mdv_event_test_handler) == MDV_OK);
mdv_ebus_unsubscribe(ebus,
0,
&counter_1,
mdv_event_test_handler);
for(int i = 0; i < 4; ++i)
{
mu_check(mdv_ebus_publish(ebus,
(mdv_event *)event_0,
MDV_EVT_DEFAULT) == MDV_OK);
mu_check(mdv_ebus_publish(ebus,
(mdv_event *)event_1,
MDV_EVT_DEFAULT) == MDV_OK);
}
while(atomic_load(&counter_0) < 4);
while(atomic_load(&counter_1) < 4);
mu_check(mdv_ebus_publish(ebus,
(mdv_event *)event_0,
MDV_EVT_SYNC) == MDV_OK);
mu_check(mdv_ebus_publish(ebus,
(mdv_event *)event_1,
MDV_EVT_SYNC) == MDV_OK);
mu_check(atomic_load(&counter_0) == 5);
mu_check(atomic_load(&counter_1) == 5);
mdv_event_test_release((mdv_event *)event_0);
mdv_event_test_release((mdv_event *)event_1);
mdv_ebus_release(ebus);
}
| 25.449612 | 68 | 0.522693 |
839bff7d4e9118a4a9a7ea9b168f45a875b605b9 | 5,172 | c | C | Driver/GUIDemo/GUIDEMO_Speed.c | robot-hq/RobotHQ.Driver | e1264c59ce2daeb9182bbb8da52f8df141a2b249 | [
"MIT"
] | null | null | null | Driver/GUIDemo/GUIDEMO_Speed.c | robot-hq/RobotHQ.Driver | e1264c59ce2daeb9182bbb8da52f8df141a2b249 | [
"MIT"
] | null | null | null | Driver/GUIDemo/GUIDEMO_Speed.c | robot-hq/RobotHQ.Driver | e1264c59ce2daeb9182bbb8da52f8df141a2b249 | [
"MIT"
] | null | null | null | /*********************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2012 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.16 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File : GUIDEMO_Speed.c
Purpose : Speed demo
----------------------------------------------------------------------
*/
#include <stdlib.h> /* for rand */
#include "GUIDEMO.h"
#if (SHOW_GUIDEMO_SPEED)
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static const GUI_COLOR _aColor[8] = {
0x000000,
0x0000FF,
0x00FF00,
0x00FFFF,
0xFF0000,
0xFF00FF,
0xFFFF00,
0xFFFFFF
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetPixelsPerSecond
*/
static U32 _GetPixelsPerSecond(void) {
GUI_COLOR Color, BkColor;
U32 x0, y0, x1, y1, xSize, ySize;
I32 t, t0;
U32 Cnt, PixelsPerSecond, PixelCnt;
//
// Find an area which is not obstructed by any windows
//
xSize = LCD_GetXSize();
ySize = LCD_GetYSize();
Cnt = 0;
x0 = 0;
x1 = xSize - 1;
y0 = 65;
y1 = ySize - 60 - 1;
Color = GUI_GetColor();
BkColor = GUI_GetBkColor();
GUI_SetColor(BkColor);
//
// Repeat fill as often as possible in 100 ms
//
t0 = GUIDEMO_GetTime();
do {
GUI_FillRect(x0, y0, x1, y1);
Cnt++;
t = GUIDEMO_GetTime();
} while ((t - (t0 + 100)) <= 0);
//
// Compute result
//
t -= t0;
PixelCnt = (x1 - x0 + 1) * (y1 - y0 + 1) * Cnt;
PixelsPerSecond = PixelCnt / t * 1000;
GUI_SetColor(Color);
return PixelsPerSecond;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIDEMO_Speed
*/
void GUIDEMO_Speed(void) {
int TimeStart, i;
U32 PixelsPerSecond;
unsigned aColorIndex[8];
int xSize, ySize, vySize;
GUI_RECT Rect, ClipRect;
char cText[40] = { 0 };
xSize = LCD_GetXSize();
ySize = LCD_GetYSize();
vySize = LCD_GetVYSize();
#if GUI_SUPPORT_CURSOR
GUI_CURSOR_Hide();
#endif
if (vySize > ySize) {
ClipRect.x0 = 0;
ClipRect.y0 = 0;
ClipRect.x1 = xSize;
ClipRect.y1 = ySize;
GUI_SetClipRect(&ClipRect);
}
GUIDEMO_ShowIntro("High speed",
"Multi layer clipping\n"
"Highly optimized drivers");
for (i = 0; i< 8; i++) {
aColorIndex[i] = GUI_Color2Index(_aColor[i]);
}
TimeStart = GUIDEMO_GetTime();
for (i = 0; ((GUIDEMO_GetTime() - TimeStart) < 5000) && (GUIDEMO_CheckCancel() == 0); i++) {
GUI_SetColorIndex(aColorIndex[i&7]);
//
// Calculate random positions
//
Rect.x0 = rand() % xSize - xSize / 2;
Rect.y0 = rand() % ySize - ySize / 2;
Rect.x1 = Rect.x0 + 20 + rand() % xSize;
Rect.y1 = Rect.y0 + 20 + rand() % ySize;
GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1);
//
// Clip rectangle to visible area and add the number of pixels (for speed computation)
//
if (Rect.x1 >= xSize) {
Rect.x1 = xSize - 1;
}
if (Rect.y1 >= ySize) {
Rect.y1 = ySize - 1;
}
if (Rect.x0 < 0 ) {
Rect.x0 = 0;
}
if (Rect.y1 < 0) {
Rect.y1 = 0;
}
GUI_Exec();
//
// Allow short breaks so we do not use all available CPU time ...
//
}
GUIDEMO_NotifyStartNext();
PixelsPerSecond = _GetPixelsPerSecond();
GUI_SetClipRect(NULL);
GUIDEMO_DrawBk(0);
GUI_SetColor(GUI_WHITE);
GUI_SetTextMode(GUI_TM_TRANS);
GUI_SetFont(&GUI_FontRounded22);
GUI_DrawBitmap(&bmSeggerLogo70x35, 5, 5);
GUIDEMO_AddStringToString(cText, "Pixels/sec: ");
GUIDEMO_AddIntToString(cText, PixelsPerSecond);
GUI_DispStringHCenterAt(cText, xSize >> 1, (ySize - GUI_GetFontSizeY()) >> 1);
GUIDEMO_Delay(4000);
#if GUI_SUPPORT_CURSOR
GUI_CURSOR_Show();
#endif
}
#else
void GUIDEMO_Speed(void) {}
#endif
| 28.108696 | 94 | 0.474478 |
839eb008e27c0a146fba6735ace3acd2c47908ee | 310 | h | C | Wikipedia/Code/AbuseFilterAlert.h | aliwaqar981/iosWikipedia | 06da0ac3ea347328adf2611b503032449682b7a3 | [
"MIT"
] | 1 | 2019-03-15T20:18:57.000Z | 2019-03-15T20:18:57.000Z | Wikipedia/Code/AbuseFilterAlert.h | aliwaqar981/iosWikipedia | 06da0ac3ea347328adf2611b503032449682b7a3 | [
"MIT"
] | null | null | null | Wikipedia/Code/AbuseFilterAlert.h | aliwaqar981/iosWikipedia | 06da0ac3ea347328adf2611b503032449682b7a3 | [
"MIT"
] | 1 | 2018-07-22T21:57:13.000Z | 2018-07-22T21:57:13.000Z | #import "TabularScrollView.h"
typedef NS_ENUM(NSInteger, AbuseFilterAlertType) {
ABUSE_FILTER_WARNING,
ABUSE_FILTER_DISALLOW
};
@interface AbuseFilterAlert : TabularScrollView
- (id)initWithType:(AbuseFilterAlertType)alertType;
@property (nonatomic, readonly) AbuseFilterAlertType alertType;
@end
| 20.666667 | 63 | 0.806452 |
83a10cc87a1d25fe068345618d433cd91162f5dd | 1,443 | h | C | chrome/browser/ui/app_list/search/ranking/top_match_ranker.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 76 | 2020-09-02T03:05:41.000Z | 2022-03-30T04:40:55.000Z | chrome/browser/ui/app_list/search/ranking/top_match_ranker.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 45 | 2020-09-02T03:21:37.000Z | 2022-03-31T22:19:45.000Z | chrome/browser/ui/app_list/search/ranking/top_match_ranker.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 8 | 2020-07-22T18:49:18.000Z | 2022-02-08T10:27:16.000Z | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_RANKING_TOP_MATCH_RANKER_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_RANKING_TOP_MATCH_RANKER_H_
#include "chrome/browser/ui/app_list/search/ranking/ranker.h"
namespace app_list {
// A ranker that inspects the scores of incoming results and picks out some of
// them to become 'top matches' to be moved to the top of the results list.
//
// Choosing top matches is done by simply thresholding the scores of incoming
// results. It is assumed that this runs after scores have been transformed to a
// near-uniform distribution per-provider by the ScoreNormalizingRanker, and so
// a score of 0.95 indicates a 95th percentile result from a provider, for
// example. It is also assumed that this runs before the category ranker, which
// moves the scores out of the normalized range [0,1].
class TopMatchRanker : public Ranker {
public:
TopMatchRanker();
~TopMatchRanker() override;
TopMatchRanker(const TopMatchRanker&) = delete;
TopMatchRanker& operator=(const TopMatchRanker&) = delete;
// Ranker:
void Rank(ResultsMap& results,
CategoriesMap& categories,
ProviderType provider) override;
};
} // namespace app_list
#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_RANKING_TOP_MATCH_RANKER_H_
| 37.973684 | 80 | 0.774082 |
83a17a77fd5297296a1708336dfffa7b826c6c18 | 1,906 | h | C | JobSystem/Src/JobSystem/WorkerThread.h | markoostveen/JobSystem | 8497b60410aae6128a7cef8e29454756d9fbee09 | [
"Apache-2.0"
] | null | null | null | JobSystem/Src/JobSystem/WorkerThread.h | markoostveen/JobSystem | 8497b60410aae6128a7cef8e29454756d9fbee09 | [
"Apache-2.0"
] | null | null | null | JobSystem/Src/JobSystem/WorkerThread.h | markoostveen/JobSystem | 8497b60410aae6128a7cef8e29454756d9fbee09 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "Job.h"
#include "AtomicMutex.h"
#include <thread>
#include <functional>
#include <mutex>
#include <unordered_set>
#include <queue>
#include <condition_variable>
namespace JbSystem {
class JobSystem;
class JobSystemWorker {
friend class JobSystem;
public:
JobSystemWorker(JobSystem* jobsystem);
JobSystemWorker(const JobSystemWorker& worker);
~JobSystemWorker();
/// <summary>
/// returns weather or not worker is open to execute tasks
/// there might be a delay in thread actually exiting be carefull
/// </summary>
/// <returns></returns>
const bool IsRunning();
void WaitForShutdown();
void Start(); //Useful when thread became lost for some reason
Job* TryTakeJob(const JobPriority& maxTimeInvestment = JobPriority::High);
/// <summary>
/// Give a job to the worker thread
/// NOTE* This will take ownership over the job
/// </summary>
/// <param name="newJob"></param>
/// <param name="priority"></param>
void GiveJob(Job*& newJob, const JobPriority priority);
void GiveFutureJob(int& jobId);
void GiveFutureJobs(const std::vector<const Job*>& newjobs, int startIndex, int size);
/// <summary>
/// Finishes job and cleans up after
/// </summary>
/// <param name="job"></param>
void FinishJob(Job*& job);
bool IsJobScheduled(const int& jobId);
bool IsJobFinished(const int& jobId);
//Is the read suppost to be active
bool Active;
void ThreadLoop();
private:
JobSystem* _jobsystem;
mutex _modifyingThread;
std::queue<Job*> _highPriorityTaskQueue;
std::queue<Job*> _normalPriorityTaskQueue;
std::queue<Job*> _lowPriorityTaskQueue;
mutex _completedJobsMutex;
std::unordered_set<int> _completedJobs;
mutex _scheduledJobsMutex;
std::unordered_set<int> _scheduledJobs;
std::mutex _isRunningMutex;
std::condition_variable _isRunningConditionalVariable;
std::thread _worker;
};
} | 25.078947 | 88 | 0.716159 |
83a27cdda138820de48363e928bfe78519b27553 | 809 | h | C | avs/proj2/proj/parallel_builder/loop_mesh_builder.h | vmarcin/FIT-projects | 69e3e0f1f271aefd3135f92a681738a4f1a24395 | [
"MIT"
] | null | null | null | avs/proj2/proj/parallel_builder/loop_mesh_builder.h | vmarcin/FIT-projects | 69e3e0f1f271aefd3135f92a681738a4f1a24395 | [
"MIT"
] | null | null | null | avs/proj2/proj/parallel_builder/loop_mesh_builder.h | vmarcin/FIT-projects | 69e3e0f1f271aefd3135f92a681738a4f1a24395 | [
"MIT"
] | null | null | null | /**
* @file loop_mesh_builder.h
*
* @author Vladimir Marcin <xmarci10@stud.fit.vutbr.cz>
*
* @brief Parallel Marching Cubes implementation using OpenMP loops
*
* @date 15.12.2019
**/
#ifndef LOOP_MESH_BUILDER_H
#define LOOP_MESH_BUILDER_H
#include <vector>
#include "base_mesh_builder.h"
class LoopMeshBuilder : public BaseMeshBuilder
{
public:
LoopMeshBuilder(unsigned gridEdgeSize);
protected:
unsigned marchCubes(const ParametricScalarField &field);
float evaluateFieldAt(const Vec3_t<float> &pos, const ParametricScalarField &field);
void emitTriangle(const Triangle_t &triangle);
const Triangle_t *getTrianglesArray() const { return mTriangles.data(); }
std::vector<Triangle_t> mTriangles; ///< Temporary array of triangles
};
#endif // LOOP_MESH_BUILDER_H
| 25.28125 | 88 | 0.746601 |
83a2e96325de2667036153e2fa9b3d0228ae3c37 | 35,687 | h | C | webrtc/include/third_party/blink/renderer/core/exported/web_view_impl.h | yxlao/webrtc-cpp-sample | 60bb1948f714693e7c8ade2fc6ffba218ea13859 | [
"MIT"
] | null | null | null | webrtc/include/third_party/blink/renderer/core/exported/web_view_impl.h | yxlao/webrtc-cpp-sample | 60bb1948f714693e7c8ade2fc6ffba218ea13859 | [
"MIT"
] | null | null | null | webrtc/include/third_party/blink/renderer/core/exported/web_view_impl.h | yxlao/webrtc-cpp-sample | 60bb1948f714693e7c8ade2fc6ffba218ea13859 | [
"MIT"
] | null | null | null | /*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT
* OWNER OR CONTRIBUTORS 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.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_VIEW_IMPL_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_VIEW_IMPL_H_
#include <memory>
#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/page/page.mojom-blink.h"
#include "third_party/blink/public/mojom/page/page_visibility_state.mojom-blink.h"
#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom-blink.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/public/platform/web_input_event_result.h"
#include "third_party/blink/public/platform/web_rect.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_navigation_policy.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/exported/web_page_popup_impl.h"
#include "third_party/blink/renderer/core/frame/resize_viewport_anchor.h"
#include "third_party/blink/renderer/core/loader/navigation_policy.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/context_menu_provider.h"
#include "third_party/blink/renderer/core/page/event_with_hit_test_results.h"
#include "third_party/blink/renderer/core/page/page_widget_delegate.h"
#include "third_party/blink/renderer/core/page/scoped_page_pauser.h"
#include "third_party/blink/renderer/platform/geometry/int_point.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h"
#include "third_party/blink/renderer/platform/graphics/apply_viewport_changes.h"
#include "third_party/blink/renderer/platform/graphics/graphics_layer.h"
#include "third_party/blink/renderer/platform/graphics/touch_action.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace cc {
class ScopedDeferMainFrameUpdate;
}
namespace blink {
namespace frame_test_helpers {
class WebViewHelper;
}
class BrowserControls;
class DevToolsEmulator;
class Frame;
class FullscreenController;
class PageScaleConstraintsSet;
class WebDevToolsAgentImpl;
class WebLocalFrame;
class WebLocalFrameImpl;
class WebSettingsImpl;
class WebViewClient;
class WebFrameWidgetImpl;
enum class FullscreenRequestType;
namespace mojom {
namespace blink {
class TextAutosizerPageInfo;
}
} // namespace mojom
using PaintHoldingCommitTrigger = cc::PaintHoldingCommitTrigger;
class CORE_EXPORT WebViewImpl final : public WebView,
public RefCounted<WebViewImpl>,
public mojom::blink::PageBroadcast {
public:
static WebViewImpl* Create(
WebViewClient*,
mojom::blink::PageVisibilityState visibility,
bool is_inside_portal,
bool compositing_enabled,
WebViewImpl* opener,
mojo::PendingAssociatedReceiver<mojom::blink::PageBroadcast> page_handle,
scheduler::WebAgentGroupScheduler& agent_group_scheduler);
// All calls to Create() should be balanced with a call to Close(). This
// synchronously destroys the WebViewImpl.
void Close() override;
static HashSet<WebViewImpl*>& AllInstances();
// Returns true if popup menus should be rendered by the browser, false if
// they should be rendered by WebKit (which is the default).
static bool UseExternalPopupMenus();
// Returns whether frames under this WebView are backed by a compositor.
bool does_composite() const { return does_composite_; }
// WebView methods:
void DidAttachLocalMainFrame() override;
void DidDetachLocalMainFrame() override;
void DidAttachRemoteMainFrame() override;
void DidDetachRemoteMainFrame() override;
void SetNoStatePrefetchClient(WebNoStatePrefetchClient*) override;
WebSettings* GetSettings() override;
WebString PageEncoding() const override;
void SetTabKeyCyclesThroughElements(bool value) override;
bool IsActive() const override;
void SetIsActive(bool value) override;
void SetWindowFeatures(const WebWindowFeatures&) override;
void SetOpenedByDOM() override;
WebFrame* MainFrame() override;
WebLocalFrame* FocusedFrame() override;
void SetFocusedFrame(WebFrame*) override;
void SmoothScroll(int target_x,
int target_y,
base::TimeDelta duration) override;
void AdvanceFocus(bool reverse) override;
double ZoomLevel() override;
double SetZoomLevel(double) override;
float PageScaleFactor() const override;
float MinimumPageScaleFactor() const override;
float MaximumPageScaleFactor() const override;
void SetDefaultPageScaleLimits(float min_scale, float max_scale) override;
void SetInitialPageScaleOverride(float) override;
void SetPageScaleFactor(float) override;
void SetVisualViewportOffset(const gfx::PointF&) override;
gfx::PointF VisualViewportOffset() const override;
gfx::SizeF VisualViewportSize() const override;
void SetScreenOrientationOverrideForTesting(
base::Optional<blink::mojom::ScreenOrientation> orientation) override;
void UseSynchronousResizeModeForTesting(bool enable) override;
void SetWindowRectSynchronouslyForTesting(
const gfx::Rect& new_window_rect) override;
void ResetScrollAndScaleState() override;
gfx::Size ContentsPreferredMinimumSize() override;
void UpdatePreferredSize() override;
void EnablePreferredSizeChangedMode() override;
void SetDeviceScaleFactor(float) override;
void SetZoomFactorForDeviceScaleFactor(float) override;
float ZoomFactorForDeviceScaleFactor() override {
return zoom_factor_for_device_scale_factor_;
}
bool AutoResizeMode() override;
void EnableAutoResizeForTesting(const gfx::Size& min_window_size,
const gfx::Size& max_window_size) override;
void DisableAutoResizeForTesting(const gfx::Size& new_window_size) override;
WebHitTestResult HitTestResultForTap(const gfx::Point&,
const gfx::Size&) override;
void EnableDeviceEmulation(const DeviceEmulationParams&) override;
void DisableDeviceEmulation() override;
void PerformCustomContextMenuAction(unsigned action) override;
void DidCloseContextMenu() override;
void CancelPagePopup() override;
WebPagePopupImpl* GetPagePopup() const override { return page_popup_.get(); }
void AcceptLanguagesChanged() override;
void SetPageFrozen(bool frozen) override;
WebFrameWidget* MainFrameWidget() override;
void SetBaseBackgroundColor(SkColor) override;
void SetDeviceColorSpaceForTesting(
const gfx::ColorSpace& color_space) override;
void PaintContent(cc::PaintCanvas*, const gfx::Rect&) override;
void RegisterRendererPreferenceWatcher(
CrossVariantMojoRemote<mojom::RendererPreferenceWatcherInterfaceBase>
watcher) override;
void SetRendererPreferences(const RendererPreferences& preferences) override;
const RendererPreferences& GetRendererPreferences() override;
void SetWebPreferences(const web_pref::WebPreferences& preferences) override;
const web_pref::WebPreferences& GetWebPreferences() override;
// Overrides the page's background and base background color. You
// can use this to enforce a transparent background, which is useful if you
// want to have some custom background rendered behind the widget.
//
// These may are only called for composited WebViews.
void SetBackgroundColorOverride(SkColor);
void ClearBackgroundColorOverride();
void SetBaseBackgroundColorOverride(SkColor);
void ClearBaseBackgroundColorOverride();
// Resize the WebView. You likely should be using
// MainFrameWidget()->Resize instead.
void Resize(const gfx::Size&);
// This method is used for testing.
// Resize the view at the same time as changing the state of the top
// controls. If |browser_controls_shrink_layout| is true, the embedder shrunk
// the WebView size by the browser controls height.
void ResizeWithBrowserControls(const gfx::Size& main_frame_widget_size,
float top_controls_height,
float bottom_controls_height,
bool browser_controls_shrink_layout);
// Same as ResizeWithBrowserControls(const gfx::Size&,float,float,bool), but
// includes all browser controls params such as the min heights.
void ResizeWithBrowserControls(const gfx::Size& main_frame_widget_size,
const gfx::Size& visible_viewport_size,
cc::BrowserControlsParams);
// Requests a page-scale animation based on the specified point/rect.
void AnimateDoubleTapZoom(const gfx::Point&, const WebRect& block_bounds);
// mojom::blink::PageBroadcast method:
void SetPageLifecycleState(
mojom::blink::PageLifecycleStatePtr state,
mojom::blink::PageRestoreParamsPtr page_restore_params,
SetPageLifecycleStateCallback callback) override;
void AudioStateChanged(bool is_audio_playing) override;
void SetInsidePortal(bool is_inside_portal) override;
void UpdateWebPreferences(
const blink::web_pref::WebPreferences& preferences) override;
void UpdateRendererPreferences(
const RendererPreferences& preferences) override;
void SetHistoryOffsetAndLength(int32_t history_offset,
int32_t history_length) override;
void DispatchPageshow(base::TimeTicks navigation_start);
void DispatchPagehide(mojom::blink::PagehideDispatch pagehide_dispatch);
void HookBackForwardCacheEviction(bool hook);
float DefaultMinimumPageScaleFactor() const;
float DefaultMaximumPageScaleFactor() const;
float ClampPageScaleFactorToLimits(float) const;
void ResetScaleStateImmediately();
base::Optional<mojom::blink::ScreenOrientation> ScreenOrientationOverride();
void InvalidateRect(const IntRect&);
void SetZoomFactorOverride(float);
void SetCompositorDeviceScaleFactorOverride(float);
TransformationMatrix GetDeviceEmulationTransform() const;
void EnableAutoResizeMode(const gfx::Size& min_viewport_size,
const gfx::Size& max_viewport_size);
void DisableAutoResizeMode();
void ActivateDevToolsTransform(const DeviceEmulationParams&);
void DeactivateDevToolsTransform();
SkColor BackgroundColor() const;
Color BaseBackgroundColor() const;
bool BackgroundColorOverrideEnabled() const {
return background_color_override_enabled_;
}
SkColor BackgroundColorOverride() const { return background_color_override_; }
Frame* FocusedCoreFrame() const;
// Returns the currently focused Element or null if no element has focus.
Element* FocusedElement() const;
WebViewClient* Client() { return web_view_client_; }
// Returns the page object associated with this view. This may be null when
// the page is shutting down, but will be valid at all other times.
Page* GetPage() const { return page_.Get(); }
WebDevToolsAgentImpl* MainFrameDevToolsAgentImpl();
DevToolsEmulator* GetDevToolsEmulator() const {
return dev_tools_emulator_.Get();
}
// Returns the main frame associated with this view. This will be null when
// the main frame is remote.
// Internally during startup/shutdown this can be null when no main frame
// (local or remote) is attached, but this should not generally matter to code
// outside this class.
WebLocalFrameImpl* MainFrameImpl() const;
// TODO(https://crbug.com/1139104): Remove this.
std::string GetNullFrameReasonForBug1139104() const;
// Changes the zoom and scroll for zooming into an editable element
// with bounds |element_bounds_in_document| and caret bounds
// |caret_bounds_in_document|.
void ZoomAndScrollToFocusedEditableElementRect(
const IntRect& element_bounds_in_document,
const IntRect& caret_bounds_in_document,
bool zoom_into_legible_scale);
bool StartPageScaleAnimation(const IntPoint& target_position,
bool use_anchor,
float new_scale,
base::TimeDelta duration);
// Handles context menu events orignated via the the keyboard. These
// include the VK_APPS virtual key and the Shift+F10 combine. Code is
// based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
// wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
// significant change in this function is the code to convert from a
// Keyboard event to the Right Mouse button down event.
WebInputEventResult SendContextMenuEvent();
// Notifies the WebView that a load has been committed. isNewNavigation
// will be true if a new session history item should be created for that
// load. isNavigationWithinPage will be true if the navigation does
// not take the user away from the current page.
void DidCommitLoad(bool is_new_navigation, bool is_navigation_within_page);
// Indicates two things:
// 1) This view may have a new layout now.
// 2) Layout is up-to-date.
// After calling WebWidget::updateAllLifecyclePhases(), expect to get this
// notification unless the view did not need a layout.
void MainFrameLayoutUpdated();
void ResizeAfterLayout();
void DidChangeContentsSize();
void PageScaleFactorChanged();
void MainFrameScrollOffsetChanged();
void TextAutosizerPageInfoChanged(
const mojom::blink::TextAutosizerPageInfo& page_info);
bool ShouldAutoResize() const { return should_auto_resize_; }
IntSize MinAutoSize() const { return min_auto_size_; }
IntSize MaxAutoSize() const { return max_auto_size_; }
void UpdateMainFrameLayoutSize();
void UpdatePageDefinedViewportConstraints(const ViewportDescription&);
WebPagePopupImpl* OpenPagePopup(PagePopupClient*);
bool HasOpenedPopup() const { return page_popup_.get(); }
void ClosePagePopup(PagePopup*);
// Callback from PagePopup when it is closed, which it can be done directly
// without coming through WebViewImpl.
void CleanupPagePopup();
// Ensure popup's size and position is correct based on its owner element's
// dimensions.
void UpdatePagePopup();
LocalDOMWindow* PagePopupWindow() const;
PageScheduler* Scheduler() const override;
void SetVisibilityState(mojom::blink::PageVisibilityState visibility_state,
bool is_initial_state) override;
mojom::blink::PageVisibilityState GetVisibilityState() override;
void SetPageLifecycleStateFromNewPageCommit(
mojom::blink::PageVisibilityState visibility,
mojom::blink::PagehideDispatch pagehide_dispatch) override;
// Called by a full frame plugin inside this view to inform it that its
// zoom level has been updated. The plugin should only call this function
// if the zoom change was triggered by the browser, it's only needed in case
// a plugin can update its own zoom, say because of its own UI.
void FullFramePluginZoomLevelChanged(double zoom_level);
// Requests a page-scale animation based on the specified rect.
void ZoomToFindInPageRect(const WebRect&);
void ComputeScaleAndScrollForBlockRect(
const gfx::Point& hit_point,
const WebRect& block_rect,
float padding,
float default_scale_when_already_legible,
float& scale,
IntPoint& scroll);
Node* BestTapNode(const GestureEventWithHitTestResults& targeted_tap_event);
void EnableTapHighlightAtPoint(
const GestureEventWithHitTestResults& targeted_tap_event);
void EnableFakePageScaleAnimationForTesting(bool);
bool FakeDoubleTapAnimationPendingForTesting() const {
return double_tap_zoom_pending_;
}
IntPoint FakePageScaleAnimationTargetPositionForTesting() const {
return fake_page_scale_animation_target_position_;
}
float FakePageScaleAnimationPageScaleForTesting() const {
return fake_page_scale_animation_page_scale_factor_;
}
bool FakePageScaleAnimationUseAnchorForTesting() const {
return fake_page_scale_animation_use_anchor_;
}
void EnterFullscreen(LocalFrame&,
const FullscreenOptions*,
FullscreenRequestType);
void ExitFullscreen(LocalFrame&);
void FullscreenElementChanged(Element* old_element,
Element* new_element,
const FullscreenOptions* options,
FullscreenRequestType);
// Sends a request to the main frame's view to resize, and updates the page
// scale limits if needed.
void SendResizeEventForMainFrame();
// Exposed for testing purposes.
bool HasHorizontalScrollbar();
bool HasVerticalScrollbar();
WebSettingsImpl* SettingsImpl();
BrowserControls& GetBrowserControls();
// Called anytime browser controls layout height or content offset have
// changed.
void DidUpdateBrowserControls();
void AddAutoplayFlags(int32_t) override;
void ClearAutoplayFlags() override;
int32_t AutoplayFlagsForTest() override;
gfx::Size GetPreferredSizeForTest() override;
gfx::Size Size();
IntSize MainFrameSize();
PageScaleConstraintsSet& GetPageScaleConstraintsSet() const;
FloatSize ElasticOverscroll() const { return elastic_overscroll_; }
class ChromeClient& GetChromeClient() const {
return *chrome_client_.Get();
}
bool ShouldZoomToLegibleScale(const Element&);
// Allows main frame updates to occur if they were previously blocked. They
// are blocked during loading a navigation, to allow Blink to proceed without
// being interrupted by useless work until enough progress is made that it
// desires composited output to be generated.
void StopDeferringMainFrameUpdate();
// This function checks the element ids of ScrollableAreas only and returns
// the equivalent DOM Node if such exists.
Node* FindNodeFromScrollableCompositorElementId(
cc::ElementId element_id) const;
void DidEnterFullscreen();
void DidExitFullscreen();
// Called when some JS code has instructed the window associated to the main
// frame to close, which will result in a request to the browser to close the
// Widget associated to it.
void CloseWindowSoon();
// Controls whether pressing Tab key advances focus to links.
bool TabsToLinks() const;
void SetTabsToLinks(bool);
// Prevent the web page from setting min/max scale via the viewport meta
// tag. This is an accessibility feature that lets folks zoom in to web
// pages even if the web page tries to block scaling.
void SetIgnoreViewportTagScaleLimits(bool);
// Sets the maximum page scale considered to be legible. Automatic zooms (e.g,
// double-tap or find in page) will have the page scale limited to this value
// times the font scale factor. Manual pinch zoom will not be affected by this
// limit.
void SetMaximumLegibleScale(float);
void SetMainFrameViewWidget(WebFrameWidgetImpl* widget);
WebFrameWidgetImpl* MainFrameViewWidget();
// Called when hovering over an anchor with the given URL.
void SetMouseOverURL(const KURL&);
// Called when keyboard focus switches to an anchor with the given URL.
void SetKeyboardFocusURL(const KURL&);
// Asks the browser process to activate this web view.
void Focus();
// Asks the browser process to take focus away from the WebView by focusing an
// adjacent UI element in the containing window.
void TakeFocus(bool reverse);
// Shows a previously created WebView (via window.open()).
void Show(const base::UnguessableToken& opener_frame_token,
NavigationPolicy policy,
const gfx::Rect& rect,
bool opened_by_user_gesture);
// Send the window rect to the browser and call `ack_callback` when the
// browser has processed it.
void SendWindowRectToMainFrameHost(const gfx::Rect& bounds,
base::OnceClosure ack_callback);
// TODO(crbug.com/1149992): This is called from the associated widget and this
// code should eventually move out of WebView into somewhere else.
void ApplyViewportChanges(const ApplyViewportChangesArgs& args);
// Indication that the root layer for the main frame widget has changed.
void DidChangeRootLayer(bool root_layer_exists);
// Sets the page focus.
void SetPageFocus(bool enable);
// This method is used for testing.
// Resizes the unscaled (page scale = 1.0) visual viewport. Normally the
// unscaled visual viewport is the same size as the main frame. The passed
// size becomes the size of the viewport when page scale = 1. This
// is used to shrink the visible viewport to allow things like the ChromeOS
// virtual keyboard to overlay over content but allow scrolling it into view.
void ResizeVisualViewport(const gfx::Size&);
private:
FRIEND_TEST_ALL_PREFIXES(WebFrameTest, DivScrollIntoEditableTest);
FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
DivScrollIntoEditablePreservePageScaleTest);
FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
DivScrollIntoEditableTestZoomToLegibleScaleDisabled);
FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
DivScrollIntoEditableTestWithDeviceScaleFactor);
FRIEND_TEST_ALL_PREFIXES(WebViewTest, SetBaseBackgroundColorBeforeMainFrame);
FRIEND_TEST_ALL_PREFIXES(WebViewTest, LongPressImage);
FRIEND_TEST_ALL_PREFIXES(WebViewTest, LongPressImageAndThenLongTapImage);
FRIEND_TEST_ALL_PREFIXES(WebViewTest, UpdateTargetURLWithInvalidURL);
FRIEND_TEST_ALL_PREFIXES(WebViewTest, TouchDragContextMenu);
friend class frame_test_helpers::WebViewHelper;
friend class SimCompositor;
friend class WebView; // So WebView::Create can call our constructor
friend class WTF::RefCounted<WebViewImpl>;
void ThemeChanged();
// Update the target url locally and tell the browser that the target URL has
// changed. If |url| is empty, show |fallback_url|.
void UpdateTargetURL(const WebURL& url, const WebURL& fallback_url);
// Helper functions to send the updated target URL to the right render frame
// in the browser process, and to handle its associated reply message.
void SendUpdatedTargetURLToBrowser(const KURL& target_url);
void TargetURLUpdatedInBrowser();
void SetPageScaleFactorAndLocation(float scale,
bool is_pinch_gesture_active,
const FloatPoint&);
void PropagateZoomFactorToLocalFrameRoots(Frame*, float);
void SetPageLifecycleStateInternal(
mojom::blink::PageLifecycleStatePtr new_state,
mojom::blink::PageRestoreParamsPtr page_restore_params);
float MaximumLegiblePageScale() const;
void RefreshPageScaleFactor();
IntSize ContentsSize() const;
void UpdateBrowserControlsConstraint(cc::BrowserControlsState constraint);
void UpdateICBAndResizeViewport(const IntSize& visible_viewport_size);
void ResizeViewWhileAnchored(cc::BrowserControlsParams params,
const IntSize& visible_viewport_size);
void UpdateBaseBackgroundColor();
void UpdateFontRenderingFromRendererPrefs();
// Request the window to close from the renderer by sending the request to the
// browser.
void DoDeferredCloseWindowSoon();
WebViewImpl(
WebViewClient*,
mojom::blink::PageVisibilityState visibility,
bool is_inside_portal,
bool does_composite,
WebViewImpl* opener,
mojo::PendingAssociatedReceiver<mojom::blink::PageBroadcast> page_handle,
scheduler::WebAgentGroupScheduler& agent_group_scheduler);
~WebViewImpl() override;
void ConfigureAutoResizeMode();
void DoComposite();
void ReallocateRenderer();
void SetDeviceEmulationTransform(const TransformationMatrix&);
void UpdateDeviceEmulationTransform();
// Helper function: Widens the width of |source| by the specified margins
// while keeping it smaller than page width.
//
// This method can only be called if the main frame is local.
WebRect WidenRectWithinPageBounds(const WebRect& source,
int target_margin,
int minimum_margin);
void EnablePopupMouseWheelEventListener(WebLocalFrameImpl* local_root);
void DisablePopupMouseWheelEventListener();
float DeviceScaleFactor() const;
LocalFrame* FocusedLocalFrameInWidget() const;
// Clear focus and text input state of the page. If there was a focused
// element, this will trigger updates to observers and send focus, selection,
// and text input-related events.
void RemoveFocusAndTextInputState();
// Finds the zoom and scroll parameters for zooming into an editable element
// with bounds |element_bounds_in_document| and caret bounds
// |caret_bounds_in_document|. If the original element belongs to the local
// root of MainFrameImpl(), then the bounds are exactly those of the element
// and caret. Otherwise (when the editable element is inside an OOPIF), the
// bounds are projection of the original element's bounds in the main frame
// which is inside the layout area of some remote frame in this frame tree.
void ComputeScaleAndScrollForEditableElementRects(
const IntRect& element_bounds_in_document,
const IntRect& caret_bounds_in_document,
bool zoom_into_legible_scale,
float& scale,
IntPoint& scroll,
bool& need_animation);
// Sends any outstanding TrackedFeaturesUpdate messages to the browser.
void ReportActiveSchedulerTrackedFeatures();
// Callback when this widget window has been displayed by the browser.
// Corresponds to a Show method call.
void DidShowCreatedWindow();
// Can be null (e.g. unittests, shared workers, etc).
WebViewClient* web_view_client_;
Persistent<ChromeClient> chrome_client_;
Persistent<Page> page_;
// This is the size of the page that the web contents will render into. This
// is usually, but not necessarily the same as the VisualViewport size. The
// VisualViewport is the 'inner' viewport, and can be smaller than the size of
// the page. This allows the browser to shrink the size of the displayed
// contents [e.g. to accomodate a keyboard] without forcing the web page to
// relayout. For more details, see the header for the VisualViewport class.
gfx::Size size_;
// If true, automatically resize the layout view around its content.
bool should_auto_resize_ = false;
// The lower bound on the size when auto-resizing.
IntSize min_auto_size_;
// The upper bound on the size when auto-resizing.
IntSize max_auto_size_;
// An object that can be used to manipulate m_page->settings() without linking
// against WebCore. This is lazily allocated the first time GetWebSettings()
// is called.
std::unique_ptr<WebSettingsImpl> web_settings_;
// The state of our target_url transmissions. When we receive a request to
// send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
// comes back - if a new request comes in before the ACK, we store the new
// URL in pending_target_url_ and set the status to TARGET_PENDING. If an
// ACK comes back and we are in TARGET_PENDING, we send the stored URL and
// revert to TARGET_INFLIGHT.
//
// We don't need a queue of URLs to send, as only the latest is useful.
enum {
TARGET_NONE,
TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
} target_url_status_ = TARGET_NONE;
// The URL we show the user in the status bar. We use this to determine if we
// want to send a new one (we do not need to send duplicates). It will be
// equal to either |mouse_over_url_| or |focus_url_|, depending on which was
// updated last.
KURL target_url_;
// The next target URL we want to send to the browser.
KURL pending_target_url_;
// The URL the user's mouse is hovering over.
KURL mouse_over_url_;
// The URL that has keyboard focus.
KURL focus_url_;
// Keeps track of the current zoom level. 0 means no zoom, positive numbers
// mean zoom in, negative numbers mean zoom out.
double zoom_level_ = 0.;
const double minimum_zoom_level_;
const double maximum_zoom_level_;
// Additional zoom factor used to scale the content by device scale factor.
double zoom_factor_for_device_scale_factor_ = 0.;
// This value, when multiplied by the font scale factor, gives the maximum
// page scale that can result from automatic zooms.
float maximum_legible_scale_ = 1.f;
// The scale moved to by the latest double tap zoom, if any.
float double_tap_zoom_page_scale_factor_ = 0.f;
// Have we sent a double-tap zoom and not yet heard back the scale?
bool double_tap_zoom_pending_ = false;
// Used for testing purposes.
bool enable_fake_page_scale_animation_for_testing_ = false;
IntPoint fake_page_scale_animation_target_position_;
float fake_page_scale_animation_page_scale_factor_ = 0.f;
bool fake_page_scale_animation_use_anchor_ = false;
float compositor_device_scale_factor_override_ = 0.f;
TransformationMatrix device_emulation_transform_;
// The popup associated with an input/select element. The popup is owned via
// closership (self-owned-but-deleted-via-close) by RenderWidget. We also hold
// a reference here because we can extend the lifetime of the popup while
// handling input events in order to compare its popup client after it was
// closed.
scoped_refptr<WebPagePopupImpl> page_popup_;
Persistent<DevToolsEmulator> dev_tools_emulator_;
// Whether the user can press tab to focus links.
bool tabs_to_links_ = false;
// WebViews, and WebWidgets, are used to host a Page. The WidgetClient()
// provides compositing support for the WebView.
// In some cases, a WidgetClient() is not provided, or it informs us that
// it won't be presenting content via a compositor.
//
// TODO(dcheng): All WebViewImpls should have an associated LayerTreeView,
// but for various reasons, that's not the case... WebView plugin, printing,
// workers, and tests don't use a compositor in their WebViews. Sometimes
// they avoid the compositor by using a null client, and sometimes by having
// the client return a null compositor. We should make things more consistent
// and clear.
const bool does_composite_;
bool matches_heuristics_for_gpu_rasterization_ = false;
std::unique_ptr<FullscreenController> fullscreen_controller_;
SkColor base_background_color_ = Color::kWhite;
bool base_background_color_override_enabled_ = false;
SkColor base_background_color_override_ = Color::kTransparent;
bool background_color_override_enabled_ = false;
SkColor background_color_override_ = Color::kTransparent;
float zoom_factor_override_ = 0.f;
FloatSize elastic_overscroll_;
// If true, we send IPC messages when |preferred_size_| changes.
bool send_preferred_size_changes_ = false;
// Whether the preferred size may have changed and |UpdatePreferredSize| needs
// to be called.
bool needs_preferred_size_update_ = true;
// Cache the preferred size of the page in order to prevent sending the IPC
// when layout() recomputes but doesn't actually change sizes.
gfx::Size preferred_size_in_dips_;
Persistent<EventListener> popup_mouse_wheel_event_listener_;
web_pref::WebPreferences web_preferences_;
blink::RendererPreferences renderer_preferences_;
// The local root whose document has |popup_mouse_wheel_event_listener_|
// registered.
WeakPersistent<WebLocalFrameImpl> local_root_with_empty_mouse_wheel_listener_;
// The WebWidget for the main frame. This is expected to be unset when the
// WebWidget destroys itself. This will be null if the main frame is remote.
WeakPersistent<WebFrameWidgetImpl> web_widget_;
// We defer commits when transitioning to a new page. ChromeClientImpl calls
// StopDeferringCommits() to release this when a new page is loaded.
std::unique_ptr<cc::ScopedDeferMainFrameUpdate>
scoped_defer_main_frame_update_;
Persistent<ResizeViewportAnchor> resize_viewport_anchor_;
// Handle to the local main frame host. Only valid when the MainFrame is
// local. It is ok to use WTF::Unretained(this) for callbacks made on this
// interface because the callbacks will be associated with the lifecycle
// of this AssociatedRemote and the lifetiime of the main LocalFrame.
mojo::AssociatedRemote<mojom::blink::LocalMainFrameHost>
local_main_frame_host_remote_;
// Handle to the remote main frame host. Only valid when the MainFrame is
// remote. It is ok to use WTF::Unretained(this) for callbacks made on this
// interface because the callbacks will be associated with the lifecycle
// of this AssociatedRemote and the lifetime of the main RemoteFrame.
mojo::AssociatedRemote<mojom::blink::RemoteMainFrameHost>
remote_main_frame_host_remote_;
base::Optional<mojom::blink::ScreenOrientation> screen_orientation_override_;
mojo::AssociatedReceiver<mojom::blink::PageBroadcast> receiver_;
// These are observing changes in |renderer_preferences_|. This is used for
// keeping WorkerFetchContext in sync.
mojo::RemoteSet<mojom::blink::RendererPreferenceWatcher>
renderer_preference_watchers_;
base::WeakPtrFactory<WebViewImpl> weak_ptr_factory_{this};
};
} // namespace blink
#endif
| 43.2046 | 86 | 0.760977 |
83a5d39f0fee5a001e8345f49396006823123818 | 1,520 | h | C | Marlin/src/module/thermistor/thermistor_332.h | tom-2273/Tronxy_SKR_mini_E3_V20 | bc4a8dc2c6c627e4bd7aa423794246f5b051448d | [
"CC0-1.0"
] | 97 | 2020-09-14T13:35:17.000Z | 2022-03-28T20:15:49.000Z | Marlin/src/module/thermistor/thermistor_332.h | tom-2273/Tronxy_SKR_mini_E3_V20 | bc4a8dc2c6c627e4bd7aa423794246f5b051448d | [
"CC0-1.0"
] | 8 | 2020-11-11T21:01:38.000Z | 2022-01-22T01:22:10.000Z | Marlin/src/module/thermistor/thermistor_332.h | tom-2273/Tronxy_SKR_mini_E3_V20 | bc4a8dc2c6c627e4bd7aa423794246f5b051448d | [
"CC0-1.0"
] | 49 | 2020-09-22T09:33:37.000Z | 2022-03-19T21:23:04.000Z | /**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#define OVM(V) OV((V)*(0.327/0.327))
// R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
constexpr temp_entry_t temptable_332[] PROGMEM = {
{ OVM( 268), 150 },
{ OVM( 293), 145 },
{ OVM( 320), 141 },
{ OVM( 379), 133 },
{ OVM( 445), 122 },
{ OVM( 516), 108 },
{ OVM( 591), 98 },
{ OVM( 665), 88 },
{ OVM( 737), 79 },
{ OVM( 801), 70 },
{ OVM( 857), 55 },
{ OVM( 903), 46 },
{ OVM( 939), 39 },
{ OVM( 954), 33 },
{ OVM( 966), 27 },
{ OVM( 977), 22 },
{ OVM( 999), 15 },
{ OVM(1004), 5 },
{ OVM(1008), 0 },
{ OVM(1012), -5 },
{ OVM(1016), -10 },
{ OVM(1020), -15 }
};
| 29.803922 | 79 | 0.616447 |
83a9739c8a5581c12b70c72f475d2136703edf83 | 510 | h | C | src/mesh/AsyncMeshBuilder.h | githubcraft/NextCraft | e758590434e418c24dd8e66177f853445716b50d | [
"Apache-2.0"
] | 14 | 2020-05-27T16:50:50.000Z | 2022-01-17T17:13:40.000Z | src/mesh/AsyncMeshBuilder.h | githubcraft/NextCraft | e758590434e418c24dd8e66177f853445716b50d | [
"Apache-2.0"
] | 2 | 2021-06-20T15:48:09.000Z | 2021-07-02T13:57:49.000Z | src/mesh/AsyncMeshBuilder.h | githubcraft/NextCraft | e758590434e418c24dd8e66177f853445716b50d | [
"Apache-2.0"
] | 5 | 2020-05-15T08:04:24.000Z | 2021-07-22T03:00:32.000Z | //
// Created by twome on 26/01/2020.
//
#ifndef NEXTCRAFT_ASYNCMESHBUILDER_H
#define NEXTCRAFT_ASYNCMESHBUILDER_H
#include <concurrentqueue.h>
#include "../model/world/Section.h"
class AsyncMeshBuilder {
private:
static bool running;
static moodycamel::ConcurrentQueue<chunk::Section **> *concurrentQueue;
static void Work();
public:
static void Initialize();
static void Schedule(chunk::Section **section);
static void Shutdown();
};
#endif //NEXTCRAFT_ASYNCMESHBUILDER_H
| 16.451613 | 75 | 0.727451 |
83a9ac2808908cf49e2014bf1960e4cdb95afc95 | 4,256 | c | C | release/src-rt-6.x.4708/linux/linux-2.6.36/arch/alpha/kernel/irq_i8259.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 21 | 2021-01-22T06:47:38.000Z | 2022-03-20T14:24:29.000Z | release/src-rt-6.x.4708/linux/linux-2.6.36/arch/alpha/kernel/irq_i8259.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 1 | 2018-08-21T03:43:09.000Z | 2018-08-21T03:43:09.000Z | release/src-rt-6.x.4708/linux/linux-2.6.36/arch/alpha/kernel/irq_i8259.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 12 | 2021-01-22T14:59:28.000Z | 2022-02-22T04:03:31.000Z | /*
* linux/arch/alpha/kernel/irq_i8259.c
*
* This is the 'legacy' 8259A Programmable Interrupt Controller,
* present in the majority of PC/AT boxes.
*
* Started hacking from linux-2.3.30pre6/arch/i386/kernel/i8259.c.
*/
#include <linux/init.h>
#include <linux/cache.h>
#include <linux/sched.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include "proto.h"
#include "irq_impl.h"
/* Note mask bit is true for DISABLED irqs. */
static unsigned int cached_irq_mask = 0xffff;
static DEFINE_SPINLOCK(i8259_irq_lock);
static inline void
i8259_update_irq_hw(unsigned int irq, unsigned long mask)
{
int port = 0x21;
if (irq & 8) mask >>= 8;
if (irq & 8) port = 0xA1;
outb(mask, port);
}
inline void
i8259a_enable_irq(unsigned int irq)
{
spin_lock(&i8259_irq_lock);
i8259_update_irq_hw(irq, cached_irq_mask &= ~(1 << irq));
spin_unlock(&i8259_irq_lock);
}
static inline void
__i8259a_disable_irq(unsigned int irq)
{
i8259_update_irq_hw(irq, cached_irq_mask |= 1 << irq);
}
void
i8259a_disable_irq(unsigned int irq)
{
spin_lock(&i8259_irq_lock);
__i8259a_disable_irq(irq);
spin_unlock(&i8259_irq_lock);
}
void
i8259a_mask_and_ack_irq(unsigned int irq)
{
spin_lock(&i8259_irq_lock);
__i8259a_disable_irq(irq);
/* Ack the interrupt making it the lowest priority. */
if (irq >= 8) {
outb(0xE0 | (irq - 8), 0xa0); /* ack the slave */
irq = 2;
}
outb(0xE0 | irq, 0x20); /* ack the master */
spin_unlock(&i8259_irq_lock);
}
unsigned int
i8259a_startup_irq(unsigned int irq)
{
i8259a_enable_irq(irq);
return 0; /* never anything pending */
}
void
i8259a_end_irq(unsigned int irq)
{
if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
i8259a_enable_irq(irq);
}
struct irq_chip i8259a_irq_type = {
.name = "XT-PIC",
.startup = i8259a_startup_irq,
.shutdown = i8259a_disable_irq,
.enable = i8259a_enable_irq,
.disable = i8259a_disable_irq,
.ack = i8259a_mask_and_ack_irq,
.end = i8259a_end_irq,
};
void __init
init_i8259a_irqs(void)
{
static struct irqaction cascade = {
.handler = no_action,
.name = "cascade",
};
long i;
outb(0xff, 0x21); /* mask all of 8259A-1 */
outb(0xff, 0xA1); /* mask all of 8259A-2 */
for (i = 0; i < 16; i++) {
irq_desc[i].status = IRQ_DISABLED;
irq_desc[i].chip = &i8259a_irq_type;
}
setup_irq(2, &cascade);
}
#if defined(CONFIG_ALPHA_GENERIC)
# define IACK_SC alpha_mv.iack_sc
#elif defined(CONFIG_ALPHA_APECS)
# define IACK_SC APECS_IACK_SC
#elif defined(CONFIG_ALPHA_LCA)
# define IACK_SC LCA_IACK_SC
#elif defined(CONFIG_ALPHA_CIA)
# define IACK_SC CIA_IACK_SC
#elif defined(CONFIG_ALPHA_PYXIS)
# define IACK_SC PYXIS_IACK_SC
#elif defined(CONFIG_ALPHA_TITAN)
# define IACK_SC TITAN_IACK_SC
#elif defined(CONFIG_ALPHA_TSUNAMI)
# define IACK_SC TSUNAMI_IACK_SC
#elif defined(CONFIG_ALPHA_IRONGATE)
# define IACK_SC IRONGATE_IACK_SC
#endif
/* Note that CONFIG_ALPHA_POLARIS is intentionally left out here, since
sys_rx164 wants to use isa_no_iack_sc_device_interrupt for some reason. */
#if defined(IACK_SC)
void
isa_device_interrupt(unsigned long vector)
{
/*
* Generate a PCI interrupt acknowledge cycle. The PIC will
* respond with the interrupt vector of the highest priority
* interrupt that is pending. The PALcode sets up the
* interrupts vectors such that irq level L generates vector L.
*/
int j = *(vuip) IACK_SC;
j &= 0xff;
handle_irq(j);
}
#endif
#if defined(CONFIG_ALPHA_GENERIC) || !defined(IACK_SC)
void
isa_no_iack_sc_device_interrupt(unsigned long vector)
{
unsigned long pic;
/*
* It seems to me that the probability of two or more *device*
* interrupts occurring at almost exactly the same time is
* pretty low. So why pay the price of checking for
* additional interrupts here if the common case can be
* handled so much easier?
*/
/*
* The first read of gives you *all* interrupting lines.
* Therefore, read the mask register and and out those lines
* not enabled. Note that some documentation has 21 and a1
* write only. This is not true.
*/
pic = inb(0x20) | (inb(0xA0) << 8); /* read isr */
pic &= 0xFFFB; /* mask out cascade & hibits */
while (pic) {
int j = ffz(~pic);
pic &= pic - 1;
handle_irq(j);
}
}
#endif
| 23.256831 | 78 | 0.718515 |
83aa9a6365f8f60800169f6793ffe2772de14673 | 62,036 | c | C | apps/pdraw_raspi/pdraw_raspi.c | Akaaba/pdraw | 2411d6b846e83202984f422eeb79553304e7bd03 | [
"BSD-3-Clause"
] | 4 | 2018-05-15T01:26:21.000Z | 2020-01-27T03:15:34.000Z | apps/pdraw_raspi/pdraw_raspi.c | Akaaba/pdraw | 2411d6b846e83202984f422eeb79553304e7bd03 | [
"BSD-3-Clause"
] | 1 | 2018-10-18T15:53:02.000Z | 2018-10-18T15:53:02.000Z | apps/pdraw_raspi/pdraw_raspi.c | Akaaba/pdraw | 2411d6b846e83202984f422eeb79553304e7bd03 | [
"BSD-3-Clause"
] | 4 | 2017-05-16T11:46:12.000Z | 2019-01-09T09:13:01.000Z | /**
* Parrot Drones Awesome Video Viewer Library
* RaspberryPi application
*
* Copyright (c) 2016 Aurelien Barre
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER 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.
*/
#include "pdraw_raspi.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <getopt.h>
#define ULOG_TAG pdraw_app
#include <ulog.h>
ULOG_DECLARE_TAG(pdraw_app);
static const char short_options[] = "hdu:f:bk:K:i:m:s:c:S:C:n:";
static const struct option long_options[] =
{
{ "help" , no_argument , NULL, 'h' },
{ "daemon" , no_argument , NULL, 'd' },
{ "url" , required_argument , NULL, 'u' },
{ "file" , required_argument , NULL, 'f' },
{ "arsdk-browse" , no_argument , NULL, 'b' },
{ "arsdk" , required_argument , NULL, 'k' },
{ "arsdk-start" , required_argument , NULL, 'K' },
{ "ip" , required_argument , NULL, 'i' },
{ "miface" , required_argument , NULL, 'm' },
{ "rstrmp" , required_argument , NULL, 's' },
{ "rctrlp" , required_argument , NULL, 'c' },
{ "lstrmp" , required_argument , NULL, 'S' },
{ "lctrlp" , required_argument , NULL, 'C' },
{ "screstream" , required_argument , NULL, 'n' },
{ 0, 0, 0, 0 }
};
static ARNETWORK_IOBufferParam_t c2dParams[] =
{
/* Non-acknowledged commands. */
{
.ID = PDRAW_ARSDK_CD_NONACK_ID,
.dataType = ARNETWORKAL_FRAME_TYPE_DATA,
.sendingWaitTimeMs = 20,
.ackTimeoutMs = ARNETWORK_IOBUFFERPARAM_INFINITE_NUMBER,
.numberOfRetry = ARNETWORK_IOBUFFERPARAM_INFINITE_NUMBER,
.numberOfCell = 2,
.dataCopyMaxSize = 128,
.isOverwriting = 1,
},
/* Acknowledged commands. */
{
.ID = PDRAW_ARSDK_CD_ACK_ID,
.dataType = ARNETWORKAL_FRAME_TYPE_DATA_WITH_ACK,
.sendingWaitTimeMs = 20,
.ackTimeoutMs = 500,
.numberOfRetry = 3,
.numberOfCell = 20,
.dataCopyMaxSize = 128,
.isOverwriting = 0,
},
/* Emergency commands. */
{
.ID = PDRAW_ARSDK_CD_EMERGENCY_ID,
.dataType = ARNETWORKAL_FRAME_TYPE_DATA_WITH_ACK,
.sendingWaitTimeMs = 10,
.ackTimeoutMs = 100,
.numberOfRetry = ARNETWORK_IOBUFFERPARAM_INFINITE_NUMBER,
.numberOfCell = 1,
.dataCopyMaxSize = 128,
.isOverwriting = 0,
},
};
static const size_t c2dParamsCount = sizeof(c2dParams) / sizeof(ARNETWORK_IOBufferParam_t);
static ARNETWORK_IOBufferParam_t d2cParams[] =
{
{
.ID = PDRAW_ARSDK_DC_NAVDATA_ID,
.dataType = ARNETWORKAL_FRAME_TYPE_DATA,
.sendingWaitTimeMs = 20,
.ackTimeoutMs = ARNETWORK_IOBUFFERPARAM_INFINITE_NUMBER,
.numberOfRetry = ARNETWORK_IOBUFFERPARAM_INFINITE_NUMBER,
.numberOfCell = 20,
.dataCopyMaxSize = 128,
.isOverwriting = 0,
},
{
.ID = PDRAW_ARSDK_DC_EVENT_ID,
.dataType = ARNETWORKAL_FRAME_TYPE_DATA_WITH_ACK,
.sendingWaitTimeMs = 20,
.ackTimeoutMs = 500,
.numberOfRetry = 3,
.numberOfCell = 20,
.dataCopyMaxSize = 128,
.isOverwriting = 0,
},
};
static const size_t d2cParamsCount = sizeof(d2cParams) / sizeof(ARNETWORK_IOBufferParam_t);
static int commandBufferIds[] = {
PDRAW_ARSDK_DC_NAVDATA_ID,
PDRAW_ARSDK_DC_EVENT_ID,
};
static const size_t commandBufferIdsCount = sizeof(commandBufferIds) / sizeof(int);
static int stopping = 0;
static void sighandler(int signum)
{
printf("Stopping PDrAW...\n");
ULOGI("Stopping...");
stopping = 1;
signal(SIGINT, SIG_DFL);
}
static void welcome()
{
printf(" ___ ___ ___ __ \n");
printf(" | _ \\ \\ _ _ /_\\ \\ / / \n");
printf(" | _/ |) | '_/ _ \\ \\/\\/ / \n");
printf(" |_| |___/|_|/_/ \\_\\_/\\_/ \n");
printf("\nParrot Drones Awesome Video Viewer\n\n");
}
static void usage(int argc, char *argv[])
{
printf("Usage: %s [options]\n"
"Options:\n"
"-h | --help Print this message\n"
"-d | --daemon Daemon mode (wait for available connection)\n"
"-u | --url <url> Stream from a URL\n"
"-f | --file <file_name> Offline MP4 file playing\n"
"-b | --arsdk-browse Browse for ARSDK devices (discovery)\n"
"-k | --arsdk <ip_address> ARSDK connection to drone with its IP address\n"
"-K | --arsdk-start <ip_address> ARSDK connection to drone with its IP address (connect only, do not process the stream)\n"
"-i | --ip <ip_address> Direct RTP/AVP H.264 reception with an IP address (ports must also be configured)\n"
"-m | --miface <ip_address> Multicast interface address (only in case of multicast reception)\n"
"-s | --rstrmp <port> Remote stream port for direct RTP/AVP reception\n"
"-c | --rctrlp <port> Remote control port for direct RTP/AVP reception\n"
"-S | --lstrmp <port> Local stream port for direct RTP/AVP reception\n"
"-C | --lctrlp <port> Local control port for direct RTP/AVP reception\n"
"-n | --screstream <ip_address> Connexion to a RTP restream from a SkyController\n"
"\n",
argv[0]);
}
static void summary(struct pdraw_app* app, int afterBrowse)
{
if ((app->daemon) && (!afterBrowse))
{
printf("Daemon mode. Waiting for connection...\n\n");
}
else if ((app->arsdkBrowse) && (!afterBrowse))
{
printf("Browse for ARSDK devices (discovery)\n\n");
}
else if (app->scRestream)
{
printf("Connection to a restream from SkyController (address %s)\n\n", app->ipAddr);
}
else if (app->arsdkConnect)
{
printf("ARSDK connection to address %s", app->ipAddr);
if (!app->receiveStream) printf(" (start stream only)");
printf("\n\n");
}
else if ((app->receiveStream) && (app->url[0] != '\0'))
{
printf("Streaming from URL '%s'\n\n", app->url);
}
else if (app->receiveStream)
{
printf("Direct RTP/AVP H.264 reception from address %s\n", app->ipAddr);
printf("remote ports: %d, %d | local ports: %d, %d\n\n",
app->remoteStreamPort, app->remoteControlPort, app->localStreamPort, app->localControlPort);
}
else if (app->playRecord)
{
printf("Offline playing of MP4 file '%s'\n\n", app->url);
}
else
{
printf("Nothing to do...\n\n");
}
}
int main(int argc, char *argv[])
{
int failed = 0, loop = 1;
int idx, c;
uint64_t lastRenderTime = 0;
struct pdraw_app *app;
welcome();
if (argc < 2)
{
usage(argc, argv);
exit(EXIT_FAILURE);
}
app = (struct pdraw_app*)malloc(sizeof(struct pdraw_app));
if (app != NULL)
{
/* Initialize configuration */
memset(app, 0, sizeof(struct pdraw_app));
app->arsdkDiscoveryPort = PDRAW_ARSDK_DISCOVERY_PORT;
app->arsdkD2CPort = PDRAW_ARSDK_D2C_PORT;
app->arsdkC2DPort = 0; // Will be read from json
app->localStreamPort = PDRAW_ARSDK_VIDEO_LOCAL_STREAM_PORT;
app->localControlPort = PDRAW_ARSDK_VIDEO_LOCAL_CONTROL_PORT;
app->run = 1;
}
else
{
failed = 1;
ULOGE("pdraw app alloc error!");
}
if (!failed)
{
/* Command-line parameters */
while ((c = getopt_long(argc, argv, short_options, long_options, &idx)) != -1)
{
switch (c)
{
case 0:
break;
case 'h':
usage(argc, argv);
free(app);
exit(EXIT_SUCCESS);
break;
case 'd':
app->daemon = 1;
app->arsdkBrowse = 1;
break;
case 'n':
strncpy(app->ipAddr, optarg, sizeof(app->ipAddr));
app->scRestream = 1;
app->receiveStream = 1;
break;
case 'b':
app->arsdkBrowse = 1;
break;
case 'k':
strncpy(app->ipAddr, optarg, sizeof(app->ipAddr));
app->arsdkConnect = 1;
app->arsdkStartStream = 1;
app->receiveStream = 1;
break;
case 'K':
strncpy(app->ipAddr, optarg, sizeof(app->ipAddr));
app->arsdkConnect = 1;
app->arsdkStartStream = 1;
break;
case 'i':
strncpy(app->ipAddr, optarg, sizeof(app->ipAddr));
app->receiveStream = 1;
break;
case 'm':
strncpy(app->ifaceAddr, optarg, sizeof(app->ifaceAddr));
break;
case 'f':
strncpy(app->url, optarg, sizeof(app->url));
app->playRecord = 1;
break;
case 'u':
strncpy(app->url, optarg, sizeof(app->url));
app->receiveStream = 1;
break;
case 's':
sscanf(optarg, "%d", &app->remoteStreamPort);
break;
case 'c':
sscanf(optarg, "%d", &app->remoteControlPort);
break;
case 'S':
sscanf(optarg, "%d", &app->localStreamPort);
break;
case 'C':
sscanf(optarg, "%d", &app->localControlPort);
break;
default:
usage(argc, argv);
free(app);
exit(EXIT_FAILURE);
break;
}
}
}
if ((!app->daemon) && (!app->arsdkBrowse) && (app->ipAddr[0] == '\0')
&& (app->url[0] == '\0'))
{
failed = 1;
fprintf(stderr, "Invalid address or file name\n\n");
usage(argc, argv);
ULOGE("invalid address or file name!");
}
if (!failed)
{
summary(app, 0);
printf("Starting PDrAW...\n");
ULOGI("Starting...");
signal(SIGINT, sighandler);
}
if ((!failed) && (app->daemon))
{
pid_t pid = fork();
if (pid == 0)
{
ULOGI("successfully forked");
}
else if (pid > 0)
{
ULOGI("terminating parent process");
free(app);
exit(EXIT_SUCCESS);
}
else
{
ULOGE("fork() failed");
failed = 1;
}
}
if (!failed)
{
failed = startUi(app);
}
while ((!failed) && (!stopping) && (loop))
{
app->disconnected = 0;
if ((!failed) && (app->arsdkBrowse))
{
failed = startArdiscoveryBrowse(app);
int selected = 0;
while ((!failed) && (!stopping) && (!selected))
{
int idx = -1;
//TODO: catch keyboard press
pthread_mutex_lock(&app->ardiscoveryBrowserMutex);
if (app->daemon)
{
idx = 0;
}
if ((idx >= 0) && (idx < app->ardiscoveryDeviceCount))
{
struct ardiscovery_browser_device *device;
int i;
for (device = app->ardiscoveryDeviceList, i = 0; device && i < idx; device = device->next, i++);
if ((device) && (i == idx))
{
switch (device->product)
{
case ARDISCOVERY_PRODUCT_ARDRONE:
case ARDISCOVERY_PRODUCT_BEBOP_2:
case ARDISCOVERY_PRODUCT_EVINRUDE:
case ARDISCOVERY_PRODUCT_SKYCONTROLLER:
case ARDISCOVERY_PRODUCT_SKYCONTROLLER_NG:
case ARDISCOVERY_PRODUCT_SKYCONTROLLER_2:
strncpy(app->ipAddr, device->ipAddr, sizeof(app->ipAddr));
app->arsdkDiscoveryPort = device->port;
app->arsdkConnect = 1;
app->arsdkStartStream = 1;
app->receiveStream = 1;
selected = 1;
break;
default:
break;
}
}
}
pthread_mutex_unlock(&app->ardiscoveryBrowserMutex);
sleep(1);
}
if (selected)
{
ARDISCOVERY_AvahiDiscovery_StopBrowsing(app->ardiscoveryBrowserData);
summary(app, 1);
}
else
{
failed = 1;
}
}
if ((!failed) && (app->scRestream))
{
failed = skyControllerRestreamConnect(app);
}
if (app->arsdkConnect)
{
if (!failed)
{
failed = ardiscoveryConnect(app);
}
if (!failed)
{
failed = startArnetwork(app);
}
}
if ((!failed) && ((app->receiveStream) || (app->playRecord)))
{
failed = startPdraw(app);
}
if (app->arsdkConnect)
{
if (!failed)
{
int cmdSend = 0;
cmdSend = sendDateAndTime(app);
}
if (!failed)
{
int cmdSend = 0;
cmdSend = sendAllStates(app);
}
if ((!failed) && (app->arsdkStartStream))
{
int cmdSend = 0;
cmdSend = sendStreamingVideoEnable(app);
}
if (!failed)
{
failed = startArcommand(app);
}
}
if (!failed)
{
printf("Rock'n'roll!\n");
ULOGI("Running...");
}
/* Run until interrupted */
while ((!failed) && (!stopping) && (!app->disconnected))
{
if (app->pdraw)
{
int ret = pdraw_render_video(app->pdraw, 0, 0, 0, 0, lastRenderTime);
if (ret < 0)
{
ULOGE("pdraw_render_video() failed (%d)", ret);
failed = 1;
}
eglSwapBuffers(app->display, app->surface);
struct timespec t1;
clock_gettime(CLOCK_MONOTONIC, &t1);
lastRenderTime = (uint64_t)t1.tv_sec * 1000000 + (uint64_t)t1.tv_nsec / 1000;
}
}
printf("Closing PDrAW...\n");
ULOGI("Closing...");
if (app != NULL)
{
app->run = 0; // break threads loops
resetUi(app);
stopPdraw(app);
stopArcommand(app);
stopArnetwork(app);
stopArdiscoveryBrowse(app);
}
if ((stopping) || (!app->daemon))
{
loop = 0;
}
else
{
failed = 0;
}
}
printf("Terminating PDrAW...\n");
ULOGI("Terminating...");
if (app != NULL)
{
app->run = 0; // break threads loops
stopUi(app);
free(app);
}
printf("Hasta la vista, PDrAW!\n");
ULOGI("Finished");
exit(EXIT_SUCCESS);
}
int loadPngFile(const char *fileName, uint8_t **buffer, int *width, int *height, int *isRgba)
{
int ret = 0;
png_byte header[8]; // 8 is the maximum size that can be checked
FILE *fp = NULL;
uint8_t *raw_image = NULL;
png_bytep *row_pointers = NULL;
int w = 0, h = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
int rgba = 0;
if ((!fileName) || (!buffer) || (!width) || (!height) || (!isRgba))
{
ULOGE("invalid pointer");
return -1;
}
/* open file and test for it being a png */
if (ret == 0)
{
fp = fopen(fileName, "rb");
if (!fp)
{
ULOGE("failed to open file '%s'", fileName);
ret = -1;
}
}
if (ret == 0)
{
fread(header, 1, 8, fp);
if (png_sig_cmp(header, 0, 8))
{
ULOGE("file '%s' is not recognized as a PNG file", fileName);
ret = -1;
}
}
/* initialize stuff */
if (ret == 0)
{
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
{
ULOGE("png_create_read_struct() failed");
ret = -1;
}
}
if (ret == 0)
{
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
ULOGE("png_create_info_struct() failed");
ret = -1;
}
}
if (ret == 0)
{
if (setjmp(png_jmpbuf(png_ptr)))
{
ULOGE("error during init_io()");
ret = -1;
}
}
if (ret == 0)
{
png_init_io(png_ptr, fp);
png_set_sig_bytes(png_ptr, 8);
png_read_info(png_ptr, info_ptr);
w = png_get_image_width(png_ptr, info_ptr);
h = png_get_image_height(png_ptr, info_ptr);
png_byte color_type = png_get_color_type(png_ptr, info_ptr);
png_byte bit_depth = png_get_bit_depth(png_ptr, info_ptr);
if (color_type & PNG_COLOR_MASK_ALPHA)
{
rgba = 1;
}
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
png_set_palette_to_rgb(png_ptr);
}
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
{
png_set_expand_gray_1_2_4_to_8(png_ptr);
}
/* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets. */
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
{
png_set_tRNS_to_alpha(png_ptr);
}
/* Round to 8 bit */
if (bit_depth == 16)
{
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
png_set_scale_16(png_ptr);
#else
png_set_strip_16(png_ptr);
#endif
}
png_read_update_info(png_ptr, info_ptr);
if (setjmp(png_jmpbuf(png_ptr)))
{
ULOGE("error during read_image()");
}
}
if (ret == 0)
{
raw_image = (uint8_t*)malloc(png_get_rowbytes(png_ptr, info_ptr) * h);
if (!raw_image)
{
ULOGE("allocation failed");
ret = -1;
}
}
if (ret == 0)
{
row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * h);
if (!row_pointers)
{
ULOGE("allocation failed");
ret = -1;
}
}
if (ret == 0)
{
int y;
for (y = 0; y < h; y++)
{
row_pointers[y] = (png_byte*)(raw_image + y * png_get_rowbytes(png_ptr,info_ptr));
}
}
/* read file */
if (ret == 0)
{
png_read_image(png_ptr, row_pointers);
}
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
free(row_pointers);
*width = (int)w;
*height = (int)h;
*buffer = raw_image;
*isRgba = rgba;
return 0;
}
int startUi(struct pdraw_app *app)
{
int ret = 0;
int32_t success = 0;
EGLBoolean result;
EGLint numConfig;
static EGL_DISPMANX_WINDOW_T nativeWindow;
DISPMANX_UPDATE_HANDLE_T dispmanUpdate;
VC_RECT_T dstRect;
VC_RECT_T srcRect;
static const EGLint attributeList[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE
};
static const EGLint contextAttributes[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLConfig config;
ULOGI("Start UI");
bcm_host_init();
if (ret == 0)
{
// get an EGL display connection
app->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (app->display == EGL_NO_DISPLAY)
{
ULOGE("Failed to get display");
ret = -1;
}
}
if (ret == 0)
{
// initialize the EGL display connection
result = eglInitialize(app->display, NULL, NULL);
if (result == EGL_FALSE)
{
ULOGE("eglInitialize() failed");
ret = -1;
}
}
if (ret == 0)
{
// get an appropriate EGL frame buffer configuration
result = eglSaneChooseConfigBRCM(app->display, attributeList, &config, 1, &numConfig);
if (result == EGL_FALSE)
{
ULOGE("eglSaneChooseConfigBRCM() failed");
ret = -1;
}
}
if (ret == 0)
{
// get an appropriate EGL frame buffer configuration
result = eglBindAPI(EGL_OPENGL_ES_API);
if (result == EGL_FALSE)
{
ULOGE("eglBindAPI() failed");
ret = -1;
}
}
if (ret == 0)
{
// create an EGL rendering context
app->context = eglCreateContext(app->display, config, EGL_NO_CONTEXT, contextAttributes);
if (app->context == EGL_NO_CONTEXT)
{
ULOGE("eglCreateContext() failed");
ret = -1;
}
}
if (ret == 0)
{
success = graphics_get_display_size(0 /* LCD */, &app->screenWidth, &app->screenHeight);
if (success < 0)
{
ULOGE("graphics_get_display_size() failed");
ret = -1;
}
}
if (ret == 0)
{
// create the background layer
memset(&app->dispmanBackgroundLayer, 0, sizeof(struct ui_background_layer));
app->dispmanBackgroundLayer.layer = 0;
VC_IMAGE_TYPE_T type = VC_IMAGE_RGBA16;
uint16_t colour = 0x000F;
uint32_t vc_image_ptr;
app->dispmanBackgroundLayer.resource = vc_dispmanx_resource_create(type, 1, 1, &vc_image_ptr);
if (app->dispmanBackgroundLayer.resource == 0)
{
ULOGE("vc_dispmanx_resource_create() failed");
ret = -1;
}
else
{
VC_RECT_T dst_rect;
vc_dispmanx_rect_set(&dst_rect, 0, 0, 1, 1);
result = vc_dispmanx_resource_write_data(app->dispmanBackgroundLayer.resource,
type, sizeof(colour), &colour, &dst_rect);
if (result != 0)
{
ULOGE("vc_dispmanx_resource_write_data() failed");
ret = -1;
}
}
}
if (ret == 0)
{
// create the splash layer
memset(&app->dispmanSplashLayer, 0, sizeof(struct ui_image_layer));
result = loadPngFile("pdraw_splash.png", &app->dispmanSplashLayer.buffer, &app->dispmanSplashLayer.width,
&app->dispmanSplashLayer.height, &app->dispmanSplashLayer.isRgba);
if (result != 0)
{
ULOGE("loadPngFile() failed");
ret = -1;
}
else
{
app->dispmanSplashLayer.layer = 1;
VC_IMAGE_TYPE_T type = (app->dispmanSplashLayer.isRgba) ? VC_IMAGE_RGBA32 : VC_IMAGE_RGB888;
uint32_t vc_image_ptr;
app->dispmanSplashLayer.resource = vc_dispmanx_resource_create(type, app->dispmanSplashLayer.width,
app->dispmanSplashLayer.height, &vc_image_ptr);
if (app->dispmanSplashLayer.resource == 0)
{
ULOGE("vc_dispmanx_resource_create() failed");
ret = -1;
}
else
{
VC_RECT_T dst_rect;
vc_dispmanx_rect_set(&dst_rect, 0, 0, app->dispmanSplashLayer.width, app->dispmanSplashLayer.height);
result = vc_dispmanx_resource_write_data(app->dispmanSplashLayer.resource, type,
app->dispmanSplashLayer.width * ((app->dispmanSplashLayer.isRgba) ? 4 : 3),
app->dispmanSplashLayer.buffer, &dst_rect);
if (result != 0)
{
ULOGE("vc_dispmanx_resource_write_data() failed");
ret = -1;
}
}
}
}
if (ret == 0)
{
app->dispmanDisplay = vc_dispmanx_display_open(0 /* LCD */);
dispmanUpdate = vc_dispmanx_update_start(0);
}
if (ret == 0)
{
// display background layer
VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE, 255, 0 };
VC_RECT_T src_rect;
vc_dispmanx_rect_set(&src_rect, 0, 0, 1, 1);
VC_RECT_T dst_rect;
vc_dispmanx_rect_set(&dst_rect, 0, 0, 0, 0);
app->dispmanBackgroundLayer.element = vc_dispmanx_element_add(dispmanUpdate, app->dispmanDisplay,
app->dispmanBackgroundLayer.layer,
&dst_rect,
app->dispmanBackgroundLayer.resource,
&src_rect,
DISPMANX_PROTECTION_NONE,
&alpha, NULL, DISPMANX_NO_ROTATE);
if (app->dispmanBackgroundLayer.element == 0)
{
ULOGE("vc_dispmanx_element_add() failed");
ret = -1;
}
}
if (ret == 0)
{
// display splash layer
VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE, 255, 0 };
VC_RECT_T src_rect;
vc_dispmanx_rect_set(&src_rect, 0, 0, app->dispmanSplashLayer.width << 16, app->dispmanSplashLayer.height << 16);
VC_RECT_T dst_rect;
// logo dimensions are the smallest screen dimension / 2
int32_t dim = (app->screenHeight < app->screenWidth) ? app->screenHeight / 2 : app->screenWidth / 2;
dim = ((dim + 15) & ~15); // align to 16 pixels
int32_t xOffset = (app->screenWidth - dim) / 2;
int32_t yOffset = (app->screenHeight - dim) / 2;
vc_dispmanx_rect_set(&dst_rect, xOffset, yOffset, dim, dim);
app->dispmanSplashLayer.element = vc_dispmanx_element_add(dispmanUpdate, app->dispmanDisplay,
app->dispmanSplashLayer.layer,
&dst_rect,
app->dispmanSplashLayer.resource,
&src_rect,
DISPMANX_PROTECTION_NONE,
&alpha, NULL, DISPMANX_NO_ROTATE);
if (app->dispmanSplashLayer.element == 0)
{
ULOGE("vc_dispmanx_element_add() failed");
ret = -1;
}
}
if (ret == 0)
{
// create an EGL window surface
dstRect.x = 0;
dstRect.y = 0;
dstRect.width = app->screenWidth;
dstRect.height = app->screenHeight;
srcRect.x = 0;
srcRect.y = 0;
srcRect.width = app->screenWidth << 16;
srcRect.height = app->screenHeight << 16;
app->dispmanPdrawElement = vc_dispmanx_element_add(dispmanUpdate, app->dispmanDisplay,
2/*layer*/, &dstRect, 0/*src*/,
&srcRect, DISPMANX_PROTECTION_NONE,
0 /*alpha*/, 0/*clamp*/, (DISPMANX_TRANSFORM_T)0/*transform*/);
nativeWindow.element = app->dispmanPdrawElement;
nativeWindow.width = app->screenWidth;
nativeWindow.height = app->screenHeight;
app->surface = eglCreateWindowSurface(app->display, config, &nativeWindow, NULL);
if (app->surface == EGL_NO_SURFACE)
{
ULOGE("eglCreateWindowSurface() failed");
ret = -1;
}
}
if (ret == 0)
{
vc_dispmanx_update_submit_sync(dispmanUpdate);
}
if (ret == 0)
{
// connect the context to the surface
result = eglMakeCurrent(app->display, app->surface, app->surface, app->context);
if (result == EGL_FALSE)
{
ULOGE("eglMakeCurrent() failed");
ret = -1;
}
}
if (ret == 0)
{
/* Set the swap interval to 2 frames to limit rendering to 30fps */
//TODO: what about when the video mode is not 60fps?
result = eglSwapInterval(app->display, 2);
if (result == EGL_FALSE)
{
ULOGE("eglSwapInterval() failed");
ret = -1;
}
}
ULOGI("UI started; width=%d height=%d", app->screenWidth, app->screenHeight);
return ret;
}
void resetUi(struct pdraw_app *app)
{
DISPMANX_UPDATE_HANDLE_T dispmanUpdate;
int s;
dispmanUpdate = vc_dispmanx_update_start(0);
s = vc_dispmanx_element_remove(dispmanUpdate, app->dispmanPdrawElement);
if (s != 0)
{
ULOGE("vc_dispmanx_element_remove() failed");
}
vc_dispmanx_update_submit_sync(dispmanUpdate);
}
void stopUi(struct pdraw_app *app)
{
DISPMANX_UPDATE_HANDLE_T dispmanUpdate;
int s;
eglSwapBuffers(app->display, app->surface);
eglDestroySurface(app->display, app->surface);
dispmanUpdate = vc_dispmanx_update_start(0);
s = vc_dispmanx_element_remove(dispmanUpdate, app->dispmanPdrawElement);
if (s != 0)
{
ULOGE("vc_dispmanx_element_remove() failed");
}
s = vc_dispmanx_element_remove(dispmanUpdate, app->dispmanSplashLayer.element);
if (s != 0)
{
ULOGE("vc_dispmanx_element_remove() failed");
}
s = vc_dispmanx_element_remove(dispmanUpdate, app->dispmanBackgroundLayer.element);
if (s != 0)
{
ULOGE("vc_dispmanx_element_remove() failed");
}
vc_dispmanx_update_submit_sync(dispmanUpdate);
s = vc_dispmanx_resource_delete(app->dispmanBackgroundLayer.resource);
if (s != 0)
{
ULOGE("vc_dispmanx_resource_delete() failed");
}
s = vc_dispmanx_resource_delete(app->dispmanSplashLayer.resource);
if (s != 0)
{
ULOGE("vc_dispmanx_resource_delete() failed");
}
free(app->dispmanSplashLayer.buffer);
s = vc_dispmanx_display_close(app->dispmanDisplay);
if (s != 0)
{
ULOGE("vc_dispmanx_display_close() failed");
}
eglMakeCurrent(app->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(app->display, app->context);
eglTerminate(app->display);
}
int startPdraw(struct pdraw_app *app)
{
int ret = 0;
struct pdraw_cbs cbs;
ULOGI("Start libpdraw");
if (ret == 0) {
int ret = pthread_mutex_init(&app->pdrawMutex, NULL);
if (ret != 0)
{
ULOGE("Mutex creation failed (%d)", ret);
}
}
if (ret == 0) {
int ret = pthread_cond_init(&app->pdrawCond, NULL);
if (ret != 0)
{
ULOGE("Cond creation failed (%d)", ret);
}
}
if (ret == 0)
{
memset(&cbs, 0, sizeof(cbs));
cbs.state_changed = &pdrawStateChanged;
cbs.open_resp = &pdrawOpenResp;
cbs.close_resp = &pdrawCloseResp;
cbs.play_resp = &pdrawPlayResp;
cbs.pause_resp = &pdrawPauseResp;
cbs.seek_resp = &pdrawSeekResp;
cbs.socket_created = &pdrawSocketCreated;
ret = pdraw_new(NULL, &cbs, app, &app->pdraw);
if (ret != 0)
{
ULOGE("pdraw_new() failed (%d)", ret);
}
}
if (ret == 0)
{
ret = pdraw_set_self_friendly_name(app->pdraw, "PDrAW-RasPi"); //TODO
if (ret != 0)
{
ULOGE("pdraw_set_self_friendly_name() failed (%d)", ret);
}
}
if (ret == 0)
{
ret = pdraw_set_self_serial_number(app->pdraw, "00000000"); //TODO
if (ret != 0)
{
ULOGE("pdraw_set_self_serial_number() failed (%d)", ret);
}
}
if (ret == 0)
{
ret = pdraw_set_self_software_version(app->pdraw, "PDrAW"); //TODO
if (ret != 0)
{
ULOGE("pdraw_set_self_software_version() failed (%d)", ret);
}
}
if (ret == 0)
{
if ((app->receiveStream) && (app->ipAddr[0] != '\0'))
{
ret = pdraw_open_url_mcast(app->pdraw, app->url, app->ifaceAddr);
}
else if (app->receiveStream)
{
ret = pdraw_open_single_stream(app->pdraw, "0.0.0.0", app->localStreamPort, app->localControlPort,
app->ipAddr, app->remoteStreamPort, app->remoteControlPort, app->ifaceAddr);
}
else if (app->playRecord)
{
ret = pdraw_open_url(app->pdraw, app->url);
}
if (ret != 0)
{
ULOGE("pdraw_open() failed (%d)", ret);
}
}
if (ret == 0)
{
ret = pdraw_start_video_renderer_egl(app->pdraw,
app->screenWidth, app->screenHeight,
0, 0, app->screenWidth, app->screenHeight,
1, 0, 0, (struct egl_display *)app->display);
if (ret < 0)
{
ULOGE("pdraw_start_video_renderer_egl() failed (%d)", ret);
}
}
return ret;
}
void stopPdraw(struct pdraw_app *app)
{
if (app->pdraw)
{
int ret;
ULOGI("Stop libpdraw");
ret = pdraw_stop_video_renderer(app->pdraw);
if (ret < 0)
{
ULOGE("pdraw_stop_video_renderer() failed (%d)", ret);
}
ret = pdraw_close(app->pdraw);
if (ret != 0)
{
ULOGE("pdraw_close() failed (%d)", ret);
}
while (app->pdrawRunning) {
pthread_mutex_lock(&app->pdrawMutex);
pthread_cond_wait(&app->pdrawCond, &app->pdrawMutex);
pthread_mutex_unlock(&app->pdrawMutex);
}
ret = pdraw_destroy(app->pdraw);
if (ret != 0)
{
ULOGE("pdraw_destroy() failed (%d)", ret);
}
app->pdraw = NULL;
}
pthread_mutex_destroy(&app->pdrawMutex);
pthread_cond_destroy(&app->pdrawCond);
}
void pdrawStateChanged(struct pdraw *pdraw,
enum pdraw_state state, void *userdata)
{
ULOGI("State changed: state=%s", pdraw_state_str(state));
}
void pdrawOpenResp(struct pdraw *pdraw, int status, void *userdata)
{
int ret;
struct pdraw_app *app = userdata;
ULOGD("Open response: status=%d", status);
if (app == NULL) {
ULOGE("invalid context");
return;
}
if (status != 0)
return;
app->pdrawRunning = 1;
ret = pdraw_play(app->pdraw);
if (ret != 0)
{
ULOGE("pdraw_play() failed (%d)", ret);
}
}
void pdrawCloseResp(struct pdraw *pdraw, int status, void *userdata)
{
struct pdraw_app *app = userdata;
ULOGD("Close response: status=%d", status);
if (app == NULL) {
ULOGE("invalid context");
return;
}
if (status != 0)
return;
app->pdrawRunning = 0;
pthread_cond_signal(&app->pdrawCond);
}
void pdrawPlayResp(struct pdraw *pdraw, int status,
uint64_t timestamp, void *userdata)
{
ULOGD("Play response: status=%d ts=%" PRIu64, status, timestamp);
}
void pdrawPauseResp(struct pdraw *pdraw, int status,
uint64_t timestamp, void *userdata)
{
ULOGD("Pause response: status=%d ts=%" PRIu64, status, timestamp);
}
void pdrawSeekResp(struct pdraw *pdraw, int status,
uint64_t timestamp, void *userdata)
{
ULOGD("Seek response: status=%d ts=%" PRIu64, status, timestamp);
}
void pdrawSocketCreated(struct pdraw *pdraw, int fd, void *userdata)
{
ULOGI("Socket created: fd=%d", fd);
}
int startArdiscoveryBrowse(struct pdraw_app *app)
{
int failed = 0;
eARDISCOVERY_ERROR err = ARDISCOVERY_OK;
ULOGI("Start ARDiscovery browsing");
if (!failed)
{
int ret = pthread_mutex_init(&app->ardiscoveryBrowserMutex, NULL);
if (ret != 0)
{
ULOGE("Mutex creation failed (%d)", ret);
failed = 1;
}
}
if (!failed)
{
char serviceTypes[6][128];
char *serviceTypesPtr[6];
uint8_t serviceTypesNb = 6, i;
snprintf(serviceTypes[0], 128, ARDISCOVERY_SERVICE_NET_DEVICE_FORMAT, ARDISCOVERY_getProductID(ARDISCOVERY_PRODUCT_ARDRONE));
snprintf(serviceTypes[1], 128, ARDISCOVERY_SERVICE_NET_DEVICE_FORMAT, ARDISCOVERY_getProductID(ARDISCOVERY_PRODUCT_BEBOP_2));
snprintf(serviceTypes[2], 128, ARDISCOVERY_SERVICE_NET_DEVICE_FORMAT, ARDISCOVERY_getProductID(ARDISCOVERY_PRODUCT_EVINRUDE));
snprintf(serviceTypes[3], 128, ARDISCOVERY_SERVICE_NET_DEVICE_FORMAT, ARDISCOVERY_getProductID(ARDISCOVERY_PRODUCT_SKYCONTROLLER));
snprintf(serviceTypes[4], 128, ARDISCOVERY_SERVICE_NET_DEVICE_FORMAT, ARDISCOVERY_getProductID(ARDISCOVERY_PRODUCT_SKYCONTROLLER_NG));
snprintf(serviceTypes[5], 128, ARDISCOVERY_SERVICE_NET_DEVICE_FORMAT, ARDISCOVERY_getProductID(ARDISCOVERY_PRODUCT_SKYCONTROLLER_2));
for (i = 0; i < serviceTypesNb; i++)
{
serviceTypesPtr[i] = serviceTypes[i];
}
app->ardiscoveryBrowserData = ARDISCOVERY_AvahiDiscovery_Browser_New(ardiscoveryBrowserCallback, (void*)app, serviceTypesPtr, serviceTypesNb, &err);
if (!app->ardiscoveryBrowserData)
{
ULOGE("ARDISCOVERY_AvahiDiscovery_Browser_New() failed: %d", err);
failed = 1;
}
}
if (!failed)
{
if (pthread_create(&(app->ardiscoveryBrowserThread), NULL, (void*(*)(void *))ARDISCOVERY_AvahiDiscovery_Browse, app->ardiscoveryBrowserData) != 0)
{
ULOGE("Creation of discovery browser thread failed");
failed = 1;
}
else
{
app->ardiscoveryBrowserThreadLaunched = 1;
}
}
return failed;
}
void stopArdiscoveryBrowse(struct pdraw_app *app)
{
ULOGI("Stop ARDiscovery browsing");
if (app->ardiscoveryBrowserData != NULL)
{
ARDISCOVERY_AvahiDiscovery_StopBrowsing(app->ardiscoveryBrowserData);
if (app->ardiscoveryBrowserThreadLaunched)
{
pthread_join(app->ardiscoveryBrowserThread, NULL);
app->ardiscoveryBrowserThreadLaunched = 0;
}
}
ARDISCOVERY_AvahiDiscovery_Browser_Delete(&app->ardiscoveryBrowserData);
struct ardiscovery_browser_device *device, *next;
for (device = app->ardiscoveryDeviceList; device; device = next)
{
next = device->next;
free(device->serviceName);
free(device->serviceType);
free(device->ipAddr);
free(device);
}
app->ardiscoveryDeviceList = NULL;
pthread_mutex_destroy(&app->ardiscoveryBrowserMutex);
}
eARDISCOVERY_ERROR ardiscoveryBrowserCallback(void *userdata, uint8_t state, const char *serviceName, const char *serviceType, const char *ipAddr, uint16_t port)
{
struct pdraw_app *app = (struct pdraw_app*)userdata;
struct ardiscovery_browser_device *device = NULL;
if (state)
{
ULOGI("ARSDK device discovered: %s %s %s %d", serviceName, serviceType, ipAddr, port);
device = malloc(sizeof(*device));
if (!device)
{
ULOGE("Allocation failed");
return ARDISCOVERY_ERROR;
}
else
{
memset(device, 0, sizeof(*device));
device->serviceName = strdup(serviceName);
device->serviceType = strdup(serviceType);
device->ipAddr = strdup(ipAddr);
device->port = port;
unsigned int productId = 0;
sscanf(serviceType, "_arsdk-%04x", &productId);
device->product = ARDISCOVERY_getProductFromProductID(productId);
pthread_mutex_lock(&app->ardiscoveryBrowserMutex);
device->next = app->ardiscoveryDeviceList;
if (app->ardiscoveryDeviceList)
{
app->ardiscoveryDeviceList->prev = device;
}
app->ardiscoveryDeviceList = device;
app->ardiscoveryDeviceCount++;
pthread_mutex_unlock(&app->ardiscoveryBrowserMutex);
}
}
else
{
ULOGI("ARSDK device removed: %s %s %s %d", serviceName, serviceType, ipAddr, port);
int found = 0;
pthread_mutex_lock(&app->ardiscoveryBrowserMutex);
for (device = app->ardiscoveryDeviceList; device; device = device->next)
{
if ((device->serviceName) && (!strcmp(device->serviceName, serviceName))
&& (device->serviceType) && (!strcmp(device->serviceType, serviceType))
&& (device->ipAddr) && (!strcmp(device->ipAddr, ipAddr))
&& (device->port == port))
{
found = 1;
break;
}
}
if (found)
{
free(device->serviceName);
free(device->serviceType);
free(device->ipAddr);
if (device->prev)
{
device->prev->next = device->next;
}
else
{
app->ardiscoveryDeviceList = device->next;
}
if (device->next)
{
device->next->prev = device->prev;
}
free(device);
app->ardiscoveryDeviceCount--;
}
pthread_mutex_unlock(&app->ardiscoveryBrowserMutex);
}
pthread_mutex_lock(&app->ardiscoveryBrowserMutex);
printf("\nDevice discovery:\n");
int i;
for (device = app->ardiscoveryDeviceList, i = 1; device; device = device->next, i++)
{
printf(" - %d - %s (%s) %s:%d\n", i, device->serviceName, device->serviceType, device->ipAddr, device->port);
}
if (app->ardiscoveryDeviceCount == 0)
{
printf(" - none\n");
}
pthread_mutex_unlock(&app->ardiscoveryBrowserMutex);
return ARDISCOVERY_OK;
}
int ardiscoveryConnect(struct pdraw_app *app)
{
int failed = 0;
eARDISCOVERY_ERROR err = ARDISCOVERY_OK;
ARDISCOVERY_Connection_ConnectionData_t *discoveryData;
ULOGI("ARDiscovery connection");
discoveryData = ARDISCOVERY_Connection_New(ardiscoveryConnectionSendJsonCallback,
ardiscoveryConnectionReceiveJsonCallback, app, &err);
if (discoveryData == NULL || err != ARDISCOVERY_OK)
{
ULOGE("Error while creating discoveryData: %s", ARDISCOVERY_Error_ToString(err));
failed = 1;
}
if (!failed)
{
err = ARDISCOVERY_Connection_ControllerConnection(discoveryData, app->arsdkDiscoveryPort, app->ipAddr);
if (err != ARDISCOVERY_OK)
{
ULOGE("Error while opening discovery connection: %s", ARDISCOVERY_Error_ToString(err));
failed = 1;
}
}
ARDISCOVERY_Connection_Delete(&discoveryData);
return failed;
}
eARDISCOVERY_ERROR ardiscoveryConnectionSendJsonCallback(uint8_t *dataTx, uint32_t *dataTxSize, void *customData)
{
struct pdraw_app *app = (struct pdraw_app*)customData;
eARDISCOVERY_ERROR err = ARDISCOVERY_OK;
if ((dataTx != NULL) && (dataTxSize != NULL) && (app != NULL))
{
*dataTxSize = sprintf((char*)dataTx, "{ \"%s\": %d, \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": %d, \"%s\": %d, \"%s\": %d, \"%s\": %d }",
ARDISCOVERY_CONNECTION_JSON_D2CPORT_KEY, app->arsdkD2CPort,
ARDISCOVERY_CONNECTION_JSON_CONTROLLER_NAME_KEY, "PDrAW",
ARDISCOVERY_CONNECTION_JSON_CONTROLLER_TYPE_KEY, "Unix",
ARDISCOVERY_CONNECTION_JSON_QOS_MODE_KEY, 1,
ARDISCOVERY_CONNECTION_JSON_ARSTREAM2_CLIENT_STREAM_PORT_KEY, app->localStreamPort,
ARDISCOVERY_CONNECTION_JSON_ARSTREAM2_CLIENT_CONTROL_PORT_KEY, app->localControlPort,
ARDISCOVERY_CONNECTION_JSON_ARSTREAM2_SUPPORTED_METADATA_VERSION_KEY, 1) + 1;
}
else
{
err = ARDISCOVERY_ERROR;
}
return err;
}
eARDISCOVERY_ERROR ardiscoveryConnectionReceiveJsonCallback(uint8_t *dataRx, uint32_t dataRxSize, char *ip, void *customData)
{
struct pdraw_app *app = (struct pdraw_app*)customData;
eARDISCOVERY_ERROR err = ARDISCOVERY_OK;
if ((dataRx != NULL) && (dataRxSize != 0) && (app != NULL))
{
char *json = (char*)malloc(dataRxSize + 1);
strncpy(json, (char*)dataRx, dataRxSize);
json[dataRxSize] = '\0';
ULOGD("Received JSON: %s", json);
free(json);
int error = 0;
json_object* jsonObj_All;
json_object* jsonObj_Item;
json_bool jsonRet;
/* Parse the whole Rx buffer */
if (error == 0)
{
jsonObj_All = json_tokener_parse((const char*)dataRx);
if (jsonObj_All == NULL)
error = -1;
}
/* Find the c2dPort */
if (error == 0)
{
jsonRet = json_object_object_get_ex(jsonObj_All, ARDISCOVERY_CONNECTION_JSON_C2DPORT_KEY, &jsonObj_Item);
if ((jsonRet) && (jsonObj_Item != NULL))
app->arsdkC2DPort = json_object_get_int(jsonObj_Item);
}
/* Find the remoteStreamPort */
if (error == 0)
{
jsonRet = json_object_object_get_ex(jsonObj_All, ARDISCOVERY_CONNECTION_JSON_ARSTREAM2_SERVER_STREAM_PORT_KEY, &jsonObj_Item);
if ((jsonRet) && (jsonObj_Item != NULL))
app->remoteStreamPort = json_object_get_int(jsonObj_Item);
}
/* Find the remoteControlPort */
if (error == 0)
{
jsonRet = json_object_object_get_ex(jsonObj_All, ARDISCOVERY_CONNECTION_JSON_ARSTREAM2_SERVER_CONTROL_PORT_KEY, &jsonObj_Item);
if ((jsonRet) && (jsonObj_Item != NULL))
app->remoteControlPort = json_object_get_int(jsonObj_Item);
}
}
else
{
err = ARDISCOVERY_ERROR;
}
return err;
}
int startArnetwork(struct pdraw_app *app)
{
int failed = 0;
eARNETWORK_ERROR netError = ARNETWORK_OK;
eARNETWORKAL_ERROR netAlError = ARNETWORKAL_OK;
int pingDelay = 0; // 0 means default, -1 means no ping
ULOGI("Start ARNetwork");
app->arnetworkalManager = ARNETWORKAL_Manager_New(&netAlError);
if (netAlError != ARNETWORKAL_OK)
{
failed = 1;
}
if (!failed)
{
netAlError = ARNETWORKAL_Manager_InitWifiNetwork(app->arnetworkalManager, app->ipAddr, app->arsdkC2DPort, app->arsdkD2CPort, 1);
if (netAlError != ARNETWORKAL_OK)
{
failed = 1;
}
}
if (!failed)
{
netAlError = ARNETWORKAL_Manager_SetSendClassSelector(app->arnetworkalManager, ARSAL_SOCKET_CLASS_SELECTOR_CS6);
if (netAlError != ARNETWORKAL_OK)
{
failed = 1;
}
netAlError = ARNETWORKAL_Manager_SetRecvClassSelector(app->arnetworkalManager, ARSAL_SOCKET_CLASS_SELECTOR_CS6);
if (netAlError != ARNETWORKAL_OK)
{
failed = 1;
}
}
if (!failed)
{
app->arnetworkManager = ARNETWORK_Manager_New(app->arnetworkalManager, c2dParamsCount, c2dParams, d2cParamsCount, d2cParams, pingDelay, arnetworkOnDisconnectCallback, app, &netError);
if (netError != ARNETWORK_OK)
{
failed = 1;
}
}
if (!failed)
{
if (pthread_create(&(app->arnetworkRxThread), NULL, ARNETWORK_Manager_ReceivingThreadRun, app->arnetworkManager) != 0)
{
ULOGE("Creation of rx thread failed");
failed = 1;
}
else
{
app->arnetworkRxThreadLaunched = 1;
}
if (pthread_create(&(app->arnetworkTxThread), NULL, ARNETWORK_Manager_SendingThreadRun, app->arnetworkManager) != 0)
{
ULOGE("Creation of tx thread failed");
failed = 1;
}
else
{
app->arnetworkTxThreadLaunched = 1;
}
}
if (failed)
{
if (netAlError != ARNETWORKAL_OK)
{
ULOGE("ARNetWorkAL Error: %s", ARNETWORKAL_Error_ToString(netAlError));
}
if (netError != ARNETWORK_OK)
{
ULOGE("ARNetWork Error: %s", ARNETWORK_Error_ToString(netError));
}
}
return failed;
}
void stopArnetwork(struct pdraw_app *app)
{
ULOGI("Stop ARNetwork");
if (app->arnetworkManager != NULL)
{
ARNETWORK_Manager_Stop(app->arnetworkManager);
if (app->arnetworkRxThreadLaunched)
{
pthread_join(app->arnetworkRxThread, NULL);
app->arnetworkRxThreadLaunched = 0;
}
if (app->arnetworkTxThreadLaunched)
{
pthread_join(app->arnetworkTxThread, NULL);
app->arnetworkTxThreadLaunched = 0;
}
}
if (app->arnetworkalManager != NULL)
{
ARNETWORKAL_Manager_Unlock(app->arnetworkalManager);
ARNETWORKAL_Manager_CloseWifiNetwork(app->arnetworkalManager);
}
ARNETWORK_Manager_Delete(&(app->arnetworkManager));
ARNETWORKAL_Manager_Delete(&(app->arnetworkalManager));
}
void arnetworkOnDisconnectCallback(ARNETWORK_Manager_t *manager, ARNETWORKAL_Manager_t *alManager, void *customData)
{
ULOGD("ARNetwork disconnection callback");
struct pdraw_app *app = (struct pdraw_app*)customData;
if (!app)
{
return;
}
app->disconnected = 1;
}
eARNETWORK_MANAGER_CALLBACK_RETURN arnetworkCmdCallback(int buffer_id, uint8_t *data, void *custom, eARNETWORK_MANAGER_CALLBACK_STATUS cause)
{
eARNETWORK_MANAGER_CALLBACK_RETURN retval = ARNETWORK_MANAGER_CALLBACK_RETURN_DEFAULT;
ULOGD("ARNetwork command callback %d, cause:%d ", buffer_id, cause);
if (cause == ARNETWORK_MANAGER_CALLBACK_STATUS_TIMEOUT)
{
retval = ARNETWORK_MANAGER_CALLBACK_RETURN_DATA_POP;
}
return retval;
}
void *arnetworkCmdReaderRun(void* data)
{
struct pdraw_app *app = NULL;
int bufferId = 0;
int failed = 0;
const size_t maxLength = 128 * 1024;
void *readData = malloc(maxLength);
if (readData == NULL)
{
failed = 1;
}
if (!failed)
{
if (data != NULL)
{
bufferId = ((struct arcmd_reader_data*)data)->readerBufferId;
app = ((struct arcmd_reader_data*)data)->app;
if (app == NULL)
{
failed = 1;
}
}
else
{
failed = 1;
}
}
if (!failed)
{
while (app->run)
{
eARNETWORK_ERROR netError = ARNETWORK_OK;
int length = 0;
int skip = 0;
netError = ARNETWORK_Manager_ReadDataWithTimeout(app->arnetworkManager, bufferId, (uint8_t*)readData, maxLength, &length, 1000);
if (netError != ARNETWORK_OK)
{
if (netError != ARNETWORK_ERROR_BUFFER_EMPTY)
{
ULOGE("ARNETWORK_Manager_ReadDataWithTimeout () failed: %s", ARNETWORK_Error_ToString(netError));
}
skip = 1;
}
if (!skip)
{
eARCOMMANDS_DECODER_ERROR cmdError = ARCOMMANDS_DECODER_OK;
cmdError = ARCOMMANDS_Decoder_DecodeCommand(app->arcmdDecoder, (uint8_t*)readData, length);
if ((cmdError != ARCOMMANDS_DECODER_OK) && (cmdError != ARCOMMANDS_DECODER_ERROR_NO_CALLBACK))
{
char msg[128];
ARCOMMANDS_Decoder_DescribeBuffer((uint8_t*)readData, length, msg, sizeof(msg));
ULOGE("ARCOMMANDS_Decoder_DecodeBuffer () failed: %d %s", cmdError, msg);
}
}
}
}
if (readData != NULL)
{
free(readData);
readData = NULL;
}
return NULL;
}
int startArcommand(struct pdraw_app *app)
{
int failed = 0;
app->arcmdDecoder = ARCOMMANDS_Decoder_NewDecoder(NULL);
if (app->arcmdDecoder == NULL)
{
ULOGE("Failed to create decoder");
failed = 1;
}
app->arcmdReaderThreads = (pthread_t*)calloc(commandBufferIdsCount, sizeof(pthread_t));
if (app->arcmdReaderThreads == NULL)
{
ULOGE("Allocation of reader threads failed");
failed = 1;
}
app->arcmdReaderThreadsLaunched = (int*)calloc(commandBufferIdsCount, sizeof(int));
if (app->arcmdReaderThreadsLaunched == NULL)
{
ULOGE("Allocation of reader threads failed");
failed = 1;
}
if (!failed)
{
app->arcmdThreadData = (struct arcmd_reader_data*)calloc(commandBufferIdsCount, sizeof(struct arcmd_reader_data));
if (app->arcmdThreadData == NULL)
{
ULOGE("Allocation of reader threads data failed");
failed = 1;
}
}
if (!failed)
{
size_t readerThreadIndex = 0;
for (readerThreadIndex = 0 ; readerThreadIndex < commandBufferIdsCount ; readerThreadIndex++)
{
app->arcmdThreadData[readerThreadIndex].app = app;
app->arcmdThreadData[readerThreadIndex].readerBufferId = commandBufferIds[readerThreadIndex];
if (pthread_create(&(app->arcmdReaderThreads[readerThreadIndex]), NULL, arnetworkCmdReaderRun, &(app->arcmdThreadData[readerThreadIndex])) != 0)
{
ULOGE("Creation of reader thread failed");
failed = 1;
}
else
{
app->arcmdReaderThreadsLaunched[readerThreadIndex] = 1;
}
}
}
return failed;
}
void stopArcommand(struct pdraw_app *app)
{
if ((app->arcmdReaderThreads != NULL) && (app->arcmdReaderThreadsLaunched != NULL))
{
size_t readerThreadIndex = 0;
for (readerThreadIndex = 0 ; readerThreadIndex < commandBufferIdsCount ; readerThreadIndex++)
{
if (app->arcmdReaderThreadsLaunched[readerThreadIndex])
{
pthread_join(app->arcmdReaderThreads[readerThreadIndex], NULL);
app->arcmdReaderThreadsLaunched[readerThreadIndex] = 0;
}
}
free(app->arcmdReaderThreads);
app->arcmdReaderThreads = NULL;
free(app->arcmdReaderThreadsLaunched);
app->arcmdReaderThreadsLaunched = NULL;
}
if (app->arcmdThreadData != NULL)
{
free(app->arcmdThreadData);
app->arcmdThreadData = NULL;
}
ARCOMMANDS_Decoder_DeleteDecoder(&app->arcmdDecoder);
}
int sendDateAndTime(struct pdraw_app *app)
{
int sentStatus = 1;
u_int8_t cmdBuffer[128];
int32_t cmdSize = 0;
eARCOMMANDS_GENERATOR_ERROR cmdError;
eARNETWORK_ERROR netError = ARNETWORK_ERROR;
ULOGD("Send date and time commands");
char strDate[30];
char strTime[30];
time_t rawDate;
struct tm* tmDateTime;
time(&rawDate);
tmDateTime = localtime(&rawDate);
strftime(strDate, 30, "%F", tmDateTime);
strftime(strTime, 30, "T%H%M%S%z", tmDateTime);
/* Send date command */
cmdError = ARCOMMANDS_Generator_GenerateCommonCommonCurrentDate(cmdBuffer, sizeof(cmdBuffer), &cmdSize, strDate);
if (cmdError == ARCOMMANDS_GENERATOR_OK)
{
netError = ARNETWORK_Manager_SendData(app->arnetworkManager, PDRAW_ARSDK_CD_ACK_ID, cmdBuffer, cmdSize, NULL, &(arnetworkCmdCallback), 1);
}
if ((cmdError != ARCOMMANDS_GENERATOR_OK) || (netError != ARNETWORK_OK))
{
ULOGW("Failed to send date command. cmdError:%d netError:%s", cmdError, ARNETWORK_Error_ToString(netError));
sentStatus = 0;
}
/* Send time command */
cmdError = ARCOMMANDS_Generator_GenerateCommonCommonCurrentTime(cmdBuffer, sizeof(cmdBuffer), &cmdSize, strTime);
if (cmdError == ARCOMMANDS_GENERATOR_OK)
{
netError = ARNETWORK_Manager_SendData(app->arnetworkManager, PDRAW_ARSDK_CD_ACK_ID, cmdBuffer, cmdSize, NULL, &(arnetworkCmdCallback), 1);
}
if ((cmdError != ARCOMMANDS_GENERATOR_OK) || (netError != ARNETWORK_OK))
{
ULOGW("Failed to send time command. cmdError:%d netError:%s", cmdError, ARNETWORK_Error_ToString(netError));
sentStatus = 0;
}
return sentStatus;
}
int sendAllStates(struct pdraw_app *app)
{
int sentStatus = 1;
u_int8_t cmdBuffer[128];
int32_t cmdSize = 0;
eARCOMMANDS_GENERATOR_ERROR cmdError;
eARNETWORK_ERROR netError = ARNETWORK_ERROR;
ULOGD("Send all states command");
/* Send all states command */
cmdError = ARCOMMANDS_Generator_GenerateCommonCommonAllStates(cmdBuffer, sizeof(cmdBuffer), &cmdSize);
if (cmdError == ARCOMMANDS_GENERATOR_OK)
{
netError = ARNETWORK_Manager_SendData(app->arnetworkManager, PDRAW_ARSDK_CD_ACK_ID, cmdBuffer, cmdSize, NULL, &(arnetworkCmdCallback), 1);
}
if ((cmdError != ARCOMMANDS_GENERATOR_OK) || (netError != ARNETWORK_OK))
{
ULOGW("Failed to send all states command. cmdError:%d netError:%s", cmdError, ARNETWORK_Error_ToString(netError));
sentStatus = 0;
}
return sentStatus;
}
int sendStreamingVideoEnable(struct pdraw_app *app)
{
int sentStatus = 1;
u_int8_t cmdBuffer[128];
int32_t cmdSize = 0;
eARCOMMANDS_GENERATOR_ERROR cmdError;
eARNETWORK_ERROR netError = ARNETWORK_ERROR;
ULOGD("Send streaming video enable command");
/* Send streaming begin command */
cmdError = ARCOMMANDS_Generator_GenerateARDrone3MediaStreamingVideoEnable(cmdBuffer, sizeof(cmdBuffer), &cmdSize, 1);
if (cmdError == ARCOMMANDS_GENERATOR_OK)
{
netError = ARNETWORK_Manager_SendData(app->arnetworkManager, PDRAW_ARSDK_CD_ACK_ID, cmdBuffer, cmdSize, NULL, &(arnetworkCmdCallback), 1);
}
if ((cmdError != ARCOMMANDS_GENERATOR_OK) || (netError != ARNETWORK_OK))
{
ULOGW("Failed to send streaming video enable command. cmdError:%d netError:%s", cmdError, ARNETWORK_Error_ToString(netError));
sentStatus = 0;
}
return sentStatus;
}
int skyControllerRestreamConnect(struct pdraw_app *app)
{
int failed = 0;
char url[100];
snprintf(url, sizeof(url), "http://%s:7711/video", app->ipAddr);
ULOGI("SkyController restream connection: %s", url);
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, url);
FILE *devnull = fopen("/dev/null", "w+");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, devnull);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
ULOGE("curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
failed = 1;
}
curl_easy_cleanup(curl);
fclose(devnull);
}
curl_global_cleanup();
app->remoteStreamPort = 5004;
app->remoteControlPort = 5005;
app->localStreamPort = 55004;
app->localControlPort = 55005;
return failed;
}
| 29.526892 | 191 | 0.553695 |