関数sortWinData マニュアル

(The documentation of function sortWinData)

Last Update: 2025/6/11


◆機能・用途(Purpose)

WINデータのチャンネルブロックをチャンネルテーブルにおける登場順にソートする。
Sort channel blocks of a WIN data to the order of channel table.


◆形式(Format)

#include <win/convert.h>
inline void sortWinData
(const int NsecondBlock,struct win_secondBlock ∗winData,
 const struct win_channelTable channelTable)


◆引数(Arguments)

NsecondBlock 秒ブロックの個数。 関数win_countSecondBlock の戻り値を与える。
The number of second blocks obtained by function win_countSecondBlock.
winData WINファイルから読み込んだWINデータ(秒ブロックのデータを並べた配列; 関数read_win_fileの戻り値)を与える。 各配列要素は1つの秒ブロックのデータを表す構造体であり、 そのメンバchannelBlockにはチャンネルブロックのデータを並べた配列が格納されている。 この関数内でこの「チャンネルブロックのデータを並べた配列」がソートされる。
Give a WIN data that was read from a WIN file (an array composed of the data of second blocks; the return value of function read_win_file). Each array component represents the data for each second block, which is a structure. The member channelBlock of this structure is an array composed of the data of channel blocks. Within this function, this “array composed of the data of channel blocks” is sorted.
channelTable チャンネルテーブルのデータ。 関数win_selectChannelTable の戻り値を与える。
A channel table data given by function win_selectChannelTable.


◆動作(Behaviour)

引数winDataの各配列要素(秒ブロックのデータ)は構造体であり、 そのメンバchannelBlockはチャンネルブロックのデータを並べた配列である。 このチャンネルブロックのデータの配列を以下のように整形する。 整形後の配列で置換する(元の配列は残さない)。
Each array component of argument winData is a structure that represents the data of a second block. The member channelBlock of this structure is an array composed of the data of channel blocks. Reformat this array of the data of channel blocks as follows. The original array is replaced by the reformatted array.

チャンネル
Channels
処理
Processings
チャンネルテーブルとブロックのデータの両方に登場するチャンネル
Channels that are present both in a channel table and the data of second blocks
チャンネルテーブルにおける登場順と同じ順番になるように並べ替える。
Sorted in the order of channel table.
チャンネルテーブルには登場するがブロックのデータには登場しないチャンネル
Channels that are present in a channel table but absent in the data of second blocks
メンバsize=0のダミーのチャンネルブロックデータを追加する。
A dummy channel block data with a member size=0 is added.
チャンネルテーブルには登場せず秒ブロックのデータのみにチャンネル
Channels that are absent in a channel table but presernt in the data of second blocks
該当する配列要素を削除する。
The corresponding array components are removed.


◆使用例(Example)

int NsecondBlock =win_countSecondBlock("data.win");

struct win_data winData =read_win_file("data.win");

struct win_channelCodeList channels =win_readChannelCode("channel_codes.txt");

struct win_channelTable channelTable_all =win_readChannelTable("channels.tbl");

struct win_channelTable channelTable_use =win_selectChannelTable(channelTable_all,channels);

sortWinData (NsecondBlock, winData, channelTable_use);